[libc-commits] [openmp] [libc] [amdgpu][openmp] Treat missing TIMESTAMP_FREQUENCY as non-fatal (PR #70987)
Jon Chesterfield via libc-commits
libc-commits at lists.llvm.org
Wed Nov 1 15:36:21 PDT 2023
https://github.com/JonChesterfield updated https://github.com/llvm/llvm-project/pull/70987
>From f81de3121d75bc9e7dbc59caa7311ac9d9d7674f Mon Sep 17 00:00:00 2001
From: Jon Chesterfield <jonathanchesterfield at gmail.com>
Date: Wed, 1 Nov 2023 21:23:06 +0000
Subject: [PATCH] [amdgpu][openmp] Treat missing TIMESTAMP_FREQUENCY as
non-fatal
---
libc/utils/gpu/loader/amdgpu/Loader.cpp | 31 ++++++++++---------
.../plugins-nextgen/amdgpu/src/rtl.cpp | 10 +++---
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/libc/utils/gpu/loader/amdgpu/Loader.cpp b/libc/utils/gpu/loader/amdgpu/Loader.cpp
index 2f99076a720e2aa..b1b3aa6ce028ca5 100644
--- a/libc/utils/gpu/loader/amdgpu/Loader.cpp
+++ b/libc/utils/gpu/loader/amdgpu/Loader.cpp
@@ -487,21 +487,22 @@ int load(int argc, char **argv, char **envp, void *image, size_t size,
handle_error(err);
hsa_amd_agents_allow_access(1, &dev_agent, nullptr, host_clock_freq);
- if (hsa_status_t err =
- hsa_agent_get_info(dev_agent,
- static_cast<hsa_agent_info_t>(
- HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY),
- host_clock_freq))
- handle_error(err);
-
- void *freq_addr;
- if (hsa_status_t err = hsa_executable_symbol_get_info(
- freq_sym, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS, &freq_addr))
- handle_error(err);
-
- if (hsa_status_t err = hsa_memcpy(freq_addr, dev_agent, host_clock_freq,
- host_agent, sizeof(uint64_t)))
- handle_error(err);
+ if (HSA_STATUS_SUCCESS ==
+ hsa_agent_get_info(dev_agent,
+ static_cast<hsa_agent_info_t>(
+ HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY),
+ host_clock_freq)) {
+
+ void *freq_addr;
+ if (hsa_status_t err = hsa_executable_symbol_get_info(
+ freq_sym, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS,
+ &freq_addr))
+ handle_error(err);
+
+ if (hsa_status_t err = hsa_memcpy(freq_addr, dev_agent, host_clock_freq,
+ host_agent, sizeof(uint64_t)))
+ handle_error(err);
+ }
}
// Obtain a queue with the minimum (power of two) size, used to send commands
diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
index 71207f767fdcc60..378cad8f8ca4f15 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -1810,10 +1810,12 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
return Err;
GridValues.GV_Warp_Size = WavefrontSize;
- // Get the frequency of the steady clock.
- if (auto Err = getDeviceAttr(HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY,
- ClockFrequency))
- return Err;
+ // Get the frequency of the steady clock. If the attribute is missing
+ // assume running on an older libhsa and default to 0, omp_get_wtime
+ // will be inaccurate but otherwise programs can still run.
+ if (auto Err = getDeviceAttrRaw(HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY,
+ ClockFrequency))
+ ClockFrequency = 0;
// Load the grid values dependending on the wavefront.
if (WavefrontSize == 32)
More information about the libc-commits
mailing list