diff --git a/libc/utils/gpu/loader/amdgpu/Loader.cpp b/libc/utils/gpu/loader/amdgpu/Loader.cpp index 2f99076a720e2..b1b3aa6ce028c 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_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_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 71207f767fdcc..378cad8f8ca4f 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)