Skip to content

Commit f81de31

Browse files
[amdgpu][openmp] Treat missing TIMESTAMP_FREQUENCY as non-fatal
1 parent 2260ebf commit f81de31

File tree

2 files changed

+22
-19
lines changed
  • libc/utils/gpu/loader/amdgpu
  • openmp/libomptarget/plugins-nextgen/amdgpu/src

2 files changed

+22
-19
lines changed

libc/utils/gpu/loader/amdgpu/Loader.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -487,21 +487,22 @@ int load(int argc, char **argv, char **envp, void *image, size_t size,
487487
handle_error(err);
488488
hsa_amd_agents_allow_access(1, &dev_agent, nullptr, host_clock_freq);
489489

490-
if (hsa_status_t err =
491-
hsa_agent_get_info(dev_agent,
492-
static_cast<hsa_agent_info_t>(
493-
HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY),
494-
host_clock_freq))
495-
handle_error(err);
496-
497-
void *freq_addr;
498-
if (hsa_status_t err = hsa_executable_symbol_get_info(
499-
freq_sym, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS, &freq_addr))
500-
handle_error(err);
501-
502-
if (hsa_status_t err = hsa_memcpy(freq_addr, dev_agent, host_clock_freq,
503-
host_agent, sizeof(uint64_t)))
504-
handle_error(err);
490+
if (HSA_STATUS_SUCCESS ==
491+
hsa_agent_get_info(dev_agent,
492+
static_cast<hsa_agent_info_t>(
493+
HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY),
494+
host_clock_freq)) {
495+
496+
void *freq_addr;
497+
if (hsa_status_t err = hsa_executable_symbol_get_info(
498+
freq_sym, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS,
499+
&freq_addr))
500+
handle_error(err);
501+
502+
if (hsa_status_t err = hsa_memcpy(freq_addr, dev_agent, host_clock_freq,
503+
host_agent, sizeof(uint64_t)))
504+
handle_error(err);
505+
}
505506
}
506507

507508
// Obtain a queue with the minimum (power of two) size, used to send commands

openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,10 +1810,12 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
18101810
return Err;
18111811
GridValues.GV_Warp_Size = WavefrontSize;
18121812

1813-
// Get the frequency of the steady clock.
1814-
if (auto Err = getDeviceAttr(HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY,
1815-
ClockFrequency))
1816-
return Err;
1813+
// Get the frequency of the steady clock. If the attribute is missing
1814+
// assume running on an older libhsa and default to 0, omp_get_wtime
1815+
// will be inaccurate but otherwise programs can still run.
1816+
if (auto Err = getDeviceAttrRaw(HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY,
1817+
ClockFrequency))
1818+
ClockFrequency = 0;
18171819

18181820
// Load the grid values dependending on the wavefront.
18191821
if (WavefrontSize == 32)

0 commit comments

Comments
 (0)