|
31 | 31 | #include "CL/cl_ext.h" |
32 | 32 |
|
33 | 33 | #include "vdi_common.hpp" |
| 34 | +#include "device/comgrctx.hpp" |
34 | 35 | #include "device/rocm/rocdevice.hpp" |
35 | 36 | #include "device/rocm/rocblit.hpp" |
36 | 37 | #include "device/rocm/rocvirtual.hpp" |
|
58 | 59 | #define OPENCL_C_VERSION_STR XSTR(OPENCL_C_MAJOR) "." XSTR(OPENCL_C_MINOR) |
59 | 60 |
|
60 | 61 | #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 | + |
61 | 87 | namespace device { |
62 | 88 | extern const char* BlitSourceCode; |
63 | 89 | } |
@@ -1433,6 +1459,21 @@ bool Device::populateOCLDeviceConstants() { |
1433 | 1459 | info_.maxOnDeviceQueues_ = 1; |
1434 | 1460 | info_.maxOnDeviceEvents_ = settings().numDeviceEvents_; |
1435 | 1461 |
|
| 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 | + } |
1436 | 1477 | return true; |
1437 | 1478 | } |
1438 | 1479 |
|
|
0 commit comments