From bd399106ae7247bc4d422ce1a84519f2997bd9c3 Mon Sep 17 00:00:00 2001 From: cadolphe Date: Wed, 4 Oct 2023 17:07:08 -0400 Subject: [PATCH] SWDEV-368741 - Check for uninstalled hsa-amd-aqlprofile to avoid Segmentation Fault Change-Id: I0c0c7a2ea7c35237332ddd7c2461e4d9ff8e2f1c [ROCm/clr commit: 243b86dd23e0ff7009a5afdf8f646dc960951728] --- .../opencl/tests/ocltst/module/runtime/OCLPerfCounters.cpp | 4 +++- projects/clr/rocclr/device/rocm/rocvirtual.cpp | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/projects/clr/opencl/tests/ocltst/module/runtime/OCLPerfCounters.cpp b/projects/clr/opencl/tests/ocltst/module/runtime/OCLPerfCounters.cpp index 0e7de54e0d..84ac050c77 100644 --- a/projects/clr/opencl/tests/ocltst/module/runtime/OCLPerfCounters.cpp +++ b/projects/clr/opencl/tests/ocltst/module/runtime/OCLPerfCounters.cpp @@ -760,8 +760,10 @@ void OCLPerfCounters::run(void) { _wrapper->clSetDeviceClockModeAMD(global_device, setClockModeInput, &setClockModeOutput); - _wrapper->clGetPerfCounterInfoAMD(perfCounter, CL_PERFCOUNTER_DATA, + error_ = _wrapper->clGetPerfCounterInfoAMD(perfCounter, CL_PERFCOUNTER_DATA, sizeof(cl_ulong), &result, NULL); + CHECK_RESULT(error_ != CL_SUCCESS, + "clGetPerfCounterInfoAMD failed (Hint (Linux): install hsa-amd-aqlprofile)\n"); err = _wrapper->clReleasePerfCounterAMD(perfCounter); CHECK_RESULT(err != CL_SUCCESS, "Release PerfCounter failed\n"); diff --git a/projects/clr/rocclr/device/rocm/rocvirtual.cpp b/projects/clr/rocclr/device/rocm/rocvirtual.cpp index 74bc741db1..42eb546eab 100644 --- a/projects/clr/rocclr/device/rocm/rocvirtual.cpp +++ b/projects/clr/rocclr/device/rocm/rocvirtual.cpp @@ -3636,6 +3636,11 @@ void VirtualGPU::submitPerfCounter(amd::PerfCounterCommand& vcmd) { // one to get the profile object amd::PerfCounter* amdCounter = static_cast(counters[0]); PerfCounter* counter = static_cast(amdCounter->getDeviceCounter()); + if (counter == nullptr) { + LogError("Invalid Performance Counter"); + vcmd.setStatus(CL_INVALID_OPERATION); + return; + } PerfCounterProfile* profileRef = counter->profileRef(); // create the AQL packet for stop profiling