HSA memory alloc/copy/free refactoring

[ROCm/rocprofiler commit: d04f7095f4]
This commit is contained in:
Evgeny
2018-04-20 11:15:26 -05:00
parent 12fbe76eab
commit 0a8e945d88
10 changed files with 87 additions and 36 deletions
@@ -331,6 +331,7 @@ uint8_t* HsaRsrcFactory::AllocateLocalMemory(const AgentInfo* agent_info, size_t
status = hsa_memory_allocate(agent_info->kernarg_region, size, (void**)&buffer);
}
CHECK_STATUS("hsa_memory_allocate", status);
return (status == HSA_STATUS_SUCCESS) ? buffer : NULL;
}
@@ -348,14 +349,21 @@ uint8_t* HsaRsrcFactory::AllocateSysMemory(const AgentInfo* agent_info, size_t s
uint8_t* buffer = NULL;
status = hsa_memory_allocate(agent_info->kernarg_region, size, (void**)&buffer);
CHECK_STATUS("hsa_memory_allocate", status);
return (status == HSA_STATUS_SUCCESS) ? buffer : NULL;
}
// Transfer data method
bool HsaRsrcFactory::TransferData(void* dest_buff, void* src_buff, uint32_t length,
bool host_to_dev) {
hsa_status_t status;
status = hsa_memory_copy(dest_buff, src_buff, length);
// Memcopy method
bool HsaRsrcFactory::CopyToHost(void* dest_buff, const void* src_buff, uint32_t length) {
const hsa_status_t status = hsa_memory_copy(dest_buff, src_buff, length);
CHECK_STATUS("hsa_memory_copy", status);
return (status == HSA_STATUS_SUCCESS);
}
// Free method
bool HsaRsrcFactory::MemoryFree(void* ptr) {
const hsa_status_t status = hsa_memory_free(ptr);
CHECK_STATUS("hsa_memory_free", status);
return (status == HSA_STATUS_SUCCESS);
}
@@ -215,8 +215,11 @@ class HsaRsrcFactory {
//
uint8_t* AllocateSysMemory(const AgentInfo* agent_info, size_t size);
// Transfer data method
bool TransferData(void* dest_buff, void* src_buff, uint32_t length, bool host_to_dev);
// Memcopy method
static bool CopyToHost(void* dest_buff, const void* src_buff, uint32_t length);
// Free method
static bool MemoryFree(void* ptr);
// Loads an Assembled Brig file and Finalizes it into Device Isa
//