Report nominal GPU wallclock frequency.

Adds agent info query HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY.

Change-Id: Ib9108d51f9df89f8566291258aab3d1b87243441
Этот коммит содержится в:
Sean Keely
2022-06-24 22:47:35 -05:00
коммит произвёл David Yat Sin
родитель 33e8919743
Коммит dec37625ed
5 изменённых файлов: 53 добавлений и 4 удалений
+4 -2
Просмотреть файл
@@ -87,7 +87,7 @@ if (ROCM_CCACHE_BUILD)
endif() # if (ROCM_CCACHE_BUILD)
## Get version strings
get_version ( "1.5.0" )
get_version ( "1.6.0" )
if ( ${ROCM_PATCH_VERSION} )
set ( VERSION_PATCH ${ROCM_PATCH_VERSION})
endif()
@@ -95,8 +95,10 @@ set ( SO_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
set ( PACKAGE_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_COMMIT_COUNT}" )
## Find external dependencies.
find_package(PkgConfig)
find_package(LibElf REQUIRED)
find_package(hsakmt 1.0 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
pkg_check_modules(drm REQUIRED IMPORTED_TARGET libdrm)
## Create the rocr target.
add_library( ${CORE_RUNTIME_TARGET} "" )
@@ -265,7 +267,7 @@ if(${IMAGE_SUPPORT})
endif()
## Link dependencies.
target_link_libraries ( ${CORE_RUNTIME_TARGET} PRIVATE hsakmt::hsakmt )
target_link_libraries ( ${CORE_RUNTIME_TARGET} PRIVATE hsakmt::hsakmt PkgConfig::drm)
target_link_libraries ( ${CORE_RUNTIME_TARGET} PRIVATE elf::elf dl pthread rt )
## Set the VERSION and SOVERSION values
+3
Просмотреть файл
@@ -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
Просмотреть файл
@@ -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
Просмотреть файл
@@ -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;
+7 -1
Просмотреть файл
@@ -324,7 +324,13 @@ typedef enum hsa_amd_agent_info_s {
* owned by the agent.
* The type of this attribute is uint64_t.
*/
HSA_AMD_AGENT_INFO_MEMORY_AVAIL = 0xA015
HSA_AMD_AGENT_INFO_MEMORY_AVAIL = 0xA015,
/**
* Timestamp value increase rate, in Hz. The timestamp (clock) frequency is
* in the range 1-400MHz.
* The type of this attribute is uint64_t.
*/
HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY = 0xA016
} hsa_amd_agent_info_t;
typedef struct hsa_amd_hdp_flush_s {