Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit dba5398

Browse files
author
Jatin Chaudhary
committed
Adding and populating available registers per cu value
Change-Id: Ide012038a9d74b20166ce1e69a9f2c0cbdce0d73
1 parent cb5bf1c commit dba5398

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

device/device.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ struct Info : public amd::EmbeddedObject {
473473
uint32_t wavefrontWidth_;
474474
//! Available number of SGPRs
475475
uint32_t availableSGPRs_;
476+
//! Available number of VGPRs
477+
uint32_t availableVGPRs_;
478+
//! Available number of registers per CU
479+
uint32_t availableRegistersPerCU_;
476480
//! Number of global memory channels
477481
uint32_t globalMemChannels_;
478482
//! Number of banks in each global memory channel

device/rocm/rocdevice.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "CL/cl_ext.h"
3232

3333
#include "vdi_common.hpp"
34+
#include "device/comgrctx.hpp"
3435
#include "device/rocm/rocdevice.hpp"
3536
#include "device/rocm/rocblit.hpp"
3637
#include "device/rocm/rocvirtual.hpp"
@@ -58,6 +59,31 @@
5859
#define OPENCL_C_VERSION_STR XSTR(OPENCL_C_MAJOR) "." XSTR(OPENCL_C_MINOR)
5960

6061
#ifndef WITHOUT_HSA_BACKEND
62+
namespace {
63+
inline bool getIsaMeta(const char* targetId, amd_comgr_metadata_node_t& isaMeta) {
64+
amd_comgr_status_t status;
65+
status = amd::Comgr::get_isa_metadata(targetId, &isaMeta);
66+
return (status == AMD_COMGR_STATUS_SUCCESS) ? true : false;
67+
}
68+
bool getValueFromIsaMeta(amd_comgr_metadata_node_t& isaMeta, const char* key,
69+
std::string& retValue) {
70+
amd_comgr_status_t status;
71+
amd_comgr_metadata_node_t valMeta;
72+
size_t size = 0;
73+
74+
status = amd::Comgr::metadata_lookup(isaMeta, key, &valMeta);
75+
if (status == AMD_COMGR_STATUS_SUCCESS) {
76+
status = amd::Comgr::get_metadata_string(valMeta, &size, NULL);
77+
}
78+
if (status == AMD_COMGR_STATUS_SUCCESS) {
79+
retValue.resize(size - 1);
80+
status = amd::Comgr::get_metadata_string(valMeta, &size, &(retValue[0]));
81+
}
82+
83+
return (status == AMD_COMGR_STATUS_SUCCESS) ? true : false;
84+
}
85+
} // namespace
86+
6187
namespace device {
6288
extern const char* BlitSourceCode;
6389
}
@@ -1433,6 +1459,21 @@ bool Device::populateOCLDeviceConstants() {
14331459
info_.maxOnDeviceQueues_ = 1;
14341460
info_.maxOnDeviceEvents_ = settings().numDeviceEvents_;
14351461

1462+
// Get Values from from Comgr
1463+
amd_comgr_metadata_node_t isaMeta;
1464+
if (getIsaMeta(info_.targetId_, isaMeta)) {
1465+
std::string vgprValue;
1466+
info_.availableVGPRs_ = (getValueFromIsaMeta(isaMeta, "AddressableNumVGPRs", vgprValue))
1467+
? (atoi(vgprValue.c_str()) * info_.simdPerCU_)
1468+
: 0;
1469+
1470+
info_.availableRegistersPerCU_ = info_.availableVGPRs_ * 64; // 64 registers per VGPR
1471+
1472+
std::string sgprValue;
1473+
info_.availableSGPRs_ = (getValueFromIsaMeta(isaMeta, "AddressableNumSGPRs", sgprValue))
1474+
? (atoi(sgprValue.c_str()))
1475+
: 0;
1476+
}
14361477
return true;
14371478
}
14381479

0 commit comments

Comments
 (0)