Report nominal GPU wallclock frequency.

Adds agent info query HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY.

Change-Id: Ib9108d51f9df89f8566291258aab3d1b87243441
Tento commit je obsažen v:
Sean Keely
2022-06-24 22:47:35 -05:00
odevzdal David Yat Sin
rodič 33e8919743
revize dec37625ed
5 změnil soubory, kde provedl 53 přidání a 4 odebrání
+3
Zobrazit soubor
@@ -450,6 +450,9 @@ class GpuAgent : public GpuAgentInt {
double historical_clock_ratio_;
// @brief s_memrealtime nominal clock frequency
uint64_t wallclock_frequency_;
// @brief Array of GPU cache property.
std::vector<HsaCacheProperties> cache_props_;
+4
Zobrazit soubor
@@ -359,6 +359,10 @@ hsa_status_t CpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
case HSA_AMD_AGENT_INFO_ASIC_REVISION:
*((uint32_t*)value) = static_cast<uint32_t>(properties_.Capability.ui32.ASICRevision);
break;
case HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY:
return core::Runtime::runtime_singleton_->GetSystemInfo(HSA_SYSTEM_INFO_TIMESTAMP_FREQUENCY,
value);
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
+35 -1
Zobrazit soubor
@@ -67,10 +67,16 @@
#include "core/inc/amd_trap_handler_v1.h"
#include "core/inc/amd_blit_shaders.h"
// Generated header
#include "amd_trap_handler_v2.h"
#if defined(__linux__)
// libdrm headers
#include <xf86drm.h>
#include <amdgpu.h>
#endif
// Size of scratch (private) segment pre-allocated per thread, in bytes.
#define DEFAULT_SCRATCH_BYTES_PER_THREAD 2048
#define MAX_WAVE_SCRATCH 8387584 // See COMPUTE_TMPRING_SIZE.WAVESIZE
@@ -159,6 +165,31 @@ GpuAgent::GpuAgent(HSAuint32 node, const HsaNodeProperties& node_props, bool xna
max_queues_ = std::min(128U, max_queues_);
#endif
#if !defined(__linux__)
wallclock_frequency_ = 0;
#else
// Get wallclock freq from libdrm.
int drm_fd = drmOpenRender(node_props.DrmRenderMinor);
if (drm_fd < 0)
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Agent creation failed.\nlibdrm open failed.\n");
MAKE_SCOPE_GUARD([&]() { drmClose(drm_fd); });
amdgpu_device_handle device_handle;
uint32_t major_version;
uint32_t minor_version;
if (amdgpu_device_initialize(drm_fd, &major_version, &minor_version, &device_handle) < 0) {
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Agent creation failed.\nlibdrm error.\n");
}
MAKE_SCOPE_GUARD([&]() { amdgpu_device_deinitialize(device_handle); });
amdgpu_gpu_info info;
if (amdgpu_query_gpu_info(device_handle, &info) < 0)
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Agent creation failed.\nlibdrm query failed.\n");
// Reported by libdrm in KHz.
wallclock_frequency_ = uint64_t(info.gpu_counter_freq) * 1000ull;
#endif
// Populate region list.
InitRegionList();
@@ -1047,6 +1078,9 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
*((uint64_t*)value) = availableBytes;
break;
}
case HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY:
*((uint64_t*)value) = wallclock_frequency_;
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;