@@ -423,32 +423,35 @@ int load(int argc, char **argv, char **envp, void *image, size_t size,
423
423
handle_error (err);
424
424
425
425
// Obtain the GPU's fixed-frequency clock rate and copy it to the GPU.
426
- void *host_clock_freq;
427
- if (hsa_status_t err =
428
- hsa_amd_memory_pool_allocate (finegrained_pool, sizeof (uint64_t ),
429
- /* flags=*/ 0 , &host_clock_freq))
430
- handle_error (err);
431
- hsa_amd_agents_allow_access (1 , &dev_agent, nullptr , host_clock_freq);
432
-
433
- if (hsa_status_t err = hsa_agent_get_info (
434
- dev_agent,
435
- static_cast <hsa_agent_info_t >(HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY),
436
- host_clock_freq))
437
- handle_error (err);
438
-
426
+ // If the clock_freq symbol is missing, no work to do.
439
427
hsa_executable_symbol_t freq_sym;
440
- if (hsa_status_t err = hsa_executable_get_symbol_by_name (
441
- executable, " __llvm_libc_clock_freq" , &dev_agent, &freq_sym))
442
- handle_error (err);
428
+ if (HSA_STATUS_SUCCESS ==
429
+ hsa_executable_get_symbol_by_name (executable, " __llvm_libc_clock_freq" ,
430
+ &dev_agent, &freq_sym)) {
431
+
432
+ void *host_clock_freq;
433
+ if (hsa_status_t err =
434
+ hsa_amd_memory_pool_allocate (finegrained_pool, sizeof (uint64_t ),
435
+ /* flags=*/ 0 , &host_clock_freq))
436
+ handle_error (err);
437
+ hsa_amd_agents_allow_access (1 , &dev_agent, nullptr , host_clock_freq);
443
438
444
- void *freq_addr;
445
- if (hsa_status_t err = hsa_executable_symbol_get_info (
446
- freq_sym, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS, &freq_addr))
447
- handle_error (err);
439
+ if (hsa_status_t err =
440
+ hsa_agent_get_info (dev_agent,
441
+ static_cast <hsa_agent_info_t >(
442
+ HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY),
443
+ host_clock_freq))
444
+ handle_error (err);
448
445
449
- if (hsa_status_t err = hsa_memcpy (freq_addr, dev_agent, host_clock_freq,
450
- host_agent, sizeof (uint64_t )))
451
- handle_error (err);
446
+ void *freq_addr;
447
+ if (hsa_status_t err = hsa_executable_symbol_get_info (
448
+ freq_sym, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS, &freq_addr))
449
+ handle_error (err);
450
+
451
+ if (hsa_status_t err = hsa_memcpy (freq_addr, dev_agent, host_clock_freq,
452
+ host_agent, sizeof (uint64_t )))
453
+ handle_error (err);
454
+ }
452
455
453
456
// Obtain a queue with the minimum (power of two) size, used to send commands
454
457
// to the HSA runtime and launch execution on the device.
0 commit comments