HSA memory alloc/copy/free refactoring

[ROCm/rocprofiler commit: d04f7095f4]
Este commit está contenido en:
Evgeny
2018-04-20 11:15:26 -05:00
padre 12fbe76eab
commit 0a8e945d88
Se han modificado 10 ficheros con 87 adiciones y 36 borrados
+2 -2
Ver fichero
@@ -446,8 +446,8 @@ class Context {
else EXC_RAISING(HSA_STATUS_ERROR, "SQTT data out of output buffer");
}
hsa_status_t status = hsa_memory_copy(dest, src, size);
if (status == HSA_STATUS_SUCCESS) {
const bool suc = util::HsaRsrcFactory::CopyToHost(dest, src, size);
if (suc) {
*header = size;
callback_data->ptr = dest + align_size(size, sizeof(uint32_t));
rinfo->data.result_bytes.instance_count = sample_id + 1;
+2 -2
Ver fichero
@@ -88,8 +88,8 @@ class Profile {
}
virtual ~Profile() {
info_vector_.clear();
if (profile_.command_buffer.ptr) hsa_memory_free(profile_.command_buffer.ptr);
if (profile_.output_buffer.ptr) hsa_memory_free(profile_.output_buffer.ptr);
if (profile_.command_buffer.ptr) util::HsaRsrcFactory::MemoryFree(profile_.command_buffer.ptr);
if (profile_.output_buffer.ptr) util::HsaRsrcFactory::MemoryFree(profile_.output_buffer.ptr);
if (profile_.events) free(const_cast<event_t*>(profile_.events));
if (profile_.parameters) free(const_cast<parameter_t*>(profile_.parameters));
if (completion_signal_.handle) {
@@ -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
//