Setting output buffer to always local

Change-Id: I82bf9f4cb922221d4a2b7ae15adb0f208a0ba70e


[ROCm/rocprofiler commit: b354c54ed7]
This commit is contained in:
Giovanni LB
2024-05-24 15:35:18 -03:00
committed by Giovanni Baraldi
parent 150869be6a
commit d24a280079
@@ -62,16 +62,6 @@
} \
} while (0)
typedef void(*aqlprofile_att_parser_iterate_event_cb_t)(
int trace_event_id,
const char* trace_event_metadata,
void* userdata
);
extern "C" void aqlprofile_att_parser_iterate_event_list(
aqlprofile_att_parser_iterate_event_cb_t callback,
void* userdata
);
namespace Packet {
static const size_t MEM_PAGE_BYTES = 0x1000;
static const size_t MEM_PAGE_MASK = MEM_PAGE_BYTES - 1;
@@ -502,9 +492,6 @@ hsa_ven_amd_aqlprofile_profile_t* InitializeDeviceProfilingAqlPackets(
return profile;
}
// ATT
bool g_output_buffer_local = true;
// Allocate system memory accessible by both CPU and GPU
uint8_t* AllocateSysMemory(hsa_agent_t gpu_agent, size_t size, hsa_amd_memory_pool_t* cpu_pool) {
size_t ag_list_count = 1; // rocprofiler::hsa_support::GetCPUAgentList().size();
@@ -539,26 +526,17 @@ uint8_t* AllocateLocalMemory(size_t size, hsa_amd_memory_pool_t* gpu_pool) {
return ptr;
}
void check_wave_event(int, const char* event_name, void* userdata)
{
if (std::string_view(event_name).find("waves") == 0)
*reinterpret_cast<bool*>(userdata) = true;
}
hsa_status_t Allocate(hsa_agent_t gpu_agent, hsa_ven_amd_aqlprofile_profile_t* profile,
size_t att_buffer_size) {
rocprofiler::HSAAgentInfo& agentInfo =
rocprofiler::HSASupport_Singleton::GetInstance().GetHSAAgentInfo(gpu_agent.handle);
profile->command_buffer.ptr =
AllocateSysMemory(gpu_agent, profile->command_buffer.size, &agentInfo.cpu_pool_);
profile->output_buffer.size = att_buffer_size;
profile->output_buffer.ptr = AllocateLocalMemory(profile->output_buffer.size,
&agentInfo.gpu_pool_);
g_output_buffer_local = false;
aqlprofile_att_parser_iterate_event_list(check_wave_event, &g_output_buffer_local);
profile->output_buffer.ptr = (g_output_buffer_local)
? AllocateLocalMemory(profile->output_buffer.size, &agentInfo.gpu_pool_)
: AllocateSysMemory(gpu_agent, profile->output_buffer.size, &agentInfo.cpu_pool_);
return (profile->command_buffer.ptr && profile->output_buffer.ptr) ? HSA_STATUS_SUCCESS
: HSA_STATUS_ERROR;
}