HSA memory alloc/copy/free refactoring

Dieser Commit ist enthalten in:
Evgeny
2018-04-20 11:15:26 -05:00
Ursprung b2bf09b9e0
Commit d04f7095f4
10 geänderte Dateien mit 87 neuen und 36 gelöschten Zeilen
+13 -5
Datei anzeigen
@@ -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);
}
+5 -2
Datei anzeigen
@@ -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
//