SWDEV-508776 - support VGPRs validation (#274)
Clarify some VGPRs terms description.
Fix some wrong query logics of availableVGPRs_ and
availableRegistersPerCU_ in device info.
Add hipDeviceAttributeMaxAvailableVgprsPerThread
attribute query.
Remove hardcoding of following
info_.vgprAllocGranularity_
info_.vgprsPerSimd_
[ROCm/clr commit: 397f303d97]
Bu işleme şunda yer alıyor:
@@ -448,6 +448,9 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device)
|
||||
case hipDeviceAttributeNumberOfXccs:
|
||||
*pi = static_cast<int>(g_devices[device]->devices()[0]->info().numberOfXccs_);
|
||||
break;
|
||||
case hipDeviceAttributeMaxAvailableVgprsPerThread:
|
||||
*pi = static_cast<int>(g_devices[device]->devices()[0]->info().availableVGPRs_);
|
||||
break;
|
||||
default:
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ hipError_t ihipOccupancyMaxActiveBlocksPerMultiprocessor(
|
||||
}
|
||||
|
||||
if (VgprWaves == 0) {
|
||||
// This should not happen ideally, but in case the usedVGPRs_/availableVGPRs_ values are
|
||||
// This should not happen ideally, but in case the value is
|
||||
// incorrect, it can lead to a crash. By returning error, API can exit gracefully.
|
||||
return hipErrorUnknown;
|
||||
}
|
||||
|
||||
@@ -552,10 +552,12 @@ struct Info : public amd::EmbeddedObject {
|
||||
uint32_t wavefrontWidth_;
|
||||
//! Available number of SGPRs
|
||||
uint32_t availableSGPRs_;
|
||||
//! Available number of VGPRs
|
||||
uint32_t availableVGPRs_;
|
||||
//! Available number of registers per CU
|
||||
uint32_t availableRegistersPerCU_;
|
||||
|
||||
uint32_t availableVGPRs_; //!< Number of addressable VGPRs per thread in DWORDs
|
||||
uint32_t vgprsPerSimd_; //!< Number of VGPRs per SIMD in DWORDs
|
||||
uint32_t vgprAllocGranularity_; //!< Number of VGPRs allocation granularity per thread in DWORDs
|
||||
uint32_t availableRegistersPerCU_; //!< Number of VGPRs per CU in DWORDs
|
||||
|
||||
//! Number of global memory channels
|
||||
uint32_t globalMemChannels_;
|
||||
//! Number of banks in each global memory channel
|
||||
@@ -650,9 +652,7 @@ struct Info : public amd::EmbeddedObject {
|
||||
uint32_t driverNodeId_;
|
||||
//! Number of Physical SGPRs per SIMD
|
||||
uint32_t sgprsPerSimd_;
|
||||
//! Number of VGPRs per SIMD
|
||||
uint32_t vgprsPerSimd_;
|
||||
uint32_t vgprAllocGranularity_;
|
||||
|
||||
uint32_t numSDMAengines_; //!< Number of available SDMA engines
|
||||
|
||||
uint32_t luidLowPart_; //!< Luid low 4 bytes, available in Windows only
|
||||
|
||||
@@ -619,7 +619,7 @@ Kernel::Kernel(const amd::Device& dev, const std::string& name, const Program& p
|
||||
workGroupInfo_.usedGPRs_ = 0;
|
||||
workGroupInfo_.availableSGPRs_ = 0;
|
||||
workGroupInfo_.usedSGPRs_ = 0;
|
||||
workGroupInfo_.availableVGPRs_ = 0;
|
||||
workGroupInfo_.availableVGPRs_ = dev.info().availableVGPRs_;
|
||||
workGroupInfo_.usedVGPRs_ = 0;
|
||||
workGroupInfo_.availableLDSSize_ = 0;
|
||||
workGroupInfo_.usedLDSSize_ = 0;
|
||||
|
||||
@@ -218,8 +218,8 @@ class Kernel : public amd::HeapObject {
|
||||
size_t usedGPRs_; //!< GPRs used by the program
|
||||
size_t availableSGPRs_; //!< SGPRs available to the program
|
||||
size_t usedSGPRs_; //!< SGPRs used by the program
|
||||
size_t availableVGPRs_; //!< VGPRs available to the program
|
||||
size_t usedVGPRs_; //!< VGPRs used by the program
|
||||
size_t availableVGPRs_; //!< VGPRs addressable to the program per thread in DWORDs
|
||||
size_t usedVGPRs_; //!< VGPRs used by the program per thread in DWORDs
|
||||
size_t availableLDSSize_; //!< available LDS size
|
||||
size_t usedLDSSize_; //!< used LDS size
|
||||
size_t availableStackSize_; //!< available stack size
|
||||
|
||||
@@ -678,8 +678,9 @@ void NullDevice::fillDeviceInfo(const Pal::DeviceProperties& palProp,
|
||||
static_cast<size_t>(palProp.gpuMemoryProperties.virtualMemAllocGranularity);
|
||||
info_.vgprAllocGranularity_ = palProp.gfxipProperties.shaderCore.vgprAllocGranularity;
|
||||
info_.vgprsPerSimd_ = palProp.gfxipProperties.shaderCore.vgprsPerSimd;
|
||||
info_.availableVGPRs_ = palProp.gfxipProperties.shaderCore.numAvailableVgprs;
|
||||
info_.sgprsPerSimd_ = palProp.gfxipProperties.shaderCore.sgprsPerSimd;
|
||||
info_.availableRegistersPerCU_ = info_.vgprsPerSimd_ * info_.simdPerCU_ * 32;
|
||||
info_.availableRegistersPerCU_ = info_.vgprsPerSimd_ * info_.simdPerCU_ * info_.wavefrontWidth_;
|
||||
#if IS_WINDOWS
|
||||
info_.luidLowPart_ = palProp.osProperties.luidLowPart;
|
||||
info_.luidHighPart_ = palProp.osProperties.luidHighPart;
|
||||
|
||||
@@ -1634,12 +1634,21 @@ bool Device::populateOCLDeviceConstants() {
|
||||
// Get Values from from Comgr
|
||||
amd_comgr_metadata_node_t isaMeta;
|
||||
if (getIsaMeta(std::move(isa().isaName()), isaMeta)) {
|
||||
std::string vgprValue;
|
||||
info_.availableVGPRs_ = (getValueFromIsaMeta(isaMeta, "AddressableNumVGPRs", vgprValue))
|
||||
? (atoi(vgprValue.c_str()) * info_.simdPerCU_)
|
||||
: 0;
|
||||
std::string addressableNumVGPRs, totalNumVGPRs, vGPRAllocGranule;
|
||||
info_.availableVGPRs_ = getValueFromIsaMeta(isaMeta, "AddressableNumVGPRs",
|
||||
addressableNumVGPRs) ? atoi(addressableNumVGPRs.c_str()) : 0;
|
||||
info_.vgprsPerSimd_ = getValueFromIsaMeta(isaMeta, "TotalNumVGPRs",
|
||||
totalNumVGPRs) ? atoi(totalNumVGPRs.c_str()) : 0;
|
||||
info_.vgprAllocGranularity_ = getValueFromIsaMeta(isaMeta, "VGPRAllocGranule",
|
||||
vGPRAllocGranule) ? atoi(vGPRAllocGranule.c_str()) : 0;
|
||||
|
||||
info_.availableRegistersPerCU_ = info_.availableVGPRs_ * 64; // 64 registers per VGPR
|
||||
info_.availableRegistersPerCU_ = info_.vgprsPerSimd_ * info_.simdPerCU_ *
|
||||
info_.wavefrontWidth_;
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_INIT,
|
||||
"addressableNumVGPRs=%u, totalNumVGPRs=%u, vGPRAllocGranule=%u," \
|
||||
" availableRegistersPerCU_=%u",
|
||||
info_.availableVGPRs_, info_.vgprsPerSimd_, info_.vgprAllocGranularity_,
|
||||
info_.availableRegistersPerCU_);
|
||||
|
||||
std::string sgprValue;
|
||||
info_.availableSGPRs_ = (getValueFromIsaMeta(isaMeta, "AddressableNumSGPRs", sgprValue))
|
||||
@@ -1648,6 +1657,8 @@ bool Device::populateOCLDeviceConstants() {
|
||||
if (!releaseIsaMeta(isaMeta)) {
|
||||
LogInfo("Can not release the isa meta node");
|
||||
}
|
||||
} else {
|
||||
ClPrint(amd::LOG_ERROR, amd::LOG_INIT, "getIsaMeta(%s) failed!", isa().isaName().c_str());
|
||||
}
|
||||
|
||||
// Generic support for HMM interfaces
|
||||
@@ -1694,82 +1705,6 @@ bool Device::populateOCLDeviceConstants() {
|
||||
}
|
||||
HIP_MEM_POOL_USE_VM &= info_.virtualMemoryManagement_;
|
||||
|
||||
switch (isa().versionMajor()) {
|
||||
case (12):
|
||||
if (isa().versionMinor() == 0) {
|
||||
switch (isa().versionStepping()) {
|
||||
case (0):
|
||||
case (1):
|
||||
default:
|
||||
info_.vgprAllocGranularity_ = 24;
|
||||
info_.vgprsPerSimd_ = 1536;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (11):
|
||||
if (isa().versionMinor() == 0) {
|
||||
switch (isa().versionStepping()) {
|
||||
case (0):
|
||||
case (1):
|
||||
case (5):
|
||||
info_.vgprAllocGranularity_ = 24;
|
||||
info_.vgprsPerSimd_ = 1536;
|
||||
break;
|
||||
case (2):
|
||||
case (3):
|
||||
default:
|
||||
info_.vgprAllocGranularity_ = 16;
|
||||
info_.vgprsPerSimd_ = 1024;
|
||||
break;
|
||||
}
|
||||
} else if (isa().versionMinor() == 5) {
|
||||
switch (isa().versionStepping()) {
|
||||
case (1):
|
||||
info_.vgprAllocGranularity_ = 24;
|
||||
info_.vgprsPerSimd_ = 1536;
|
||||
break;
|
||||
default:
|
||||
info_.vgprAllocGranularity_ = 16;
|
||||
info_.vgprsPerSimd_ = 1024;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
info_.vgprAllocGranularity_ = 16;
|
||||
info_.vgprsPerSimd_ = 1024;
|
||||
}
|
||||
break;
|
||||
case (10):
|
||||
switch (isa().versionMinor()) {
|
||||
case (0):
|
||||
case (1):
|
||||
info_.vgprAllocGranularity_ = 8;
|
||||
info_.vgprsPerSimd_ = 1024;
|
||||
break;
|
||||
case (3):
|
||||
default:
|
||||
info_.vgprAllocGranularity_ = 16;
|
||||
info_.vgprsPerSimd_ = 1024;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case (9):
|
||||
if ((isa().versionMinor() == 0 && isa().versionStepping() == 10) ||
|
||||
isa().versionMinor() == 4 || isa().versionMinor() == 5) {
|
||||
info_.vgprAllocGranularity_ = 8;
|
||||
info_.vgprsPerSimd_ = 512;
|
||||
} else {
|
||||
info_.vgprAllocGranularity_ = 4;
|
||||
info_.vgprsPerSimd_ = 256;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// For gfx<=8
|
||||
info_.vgprAllocGranularity_ = 4;
|
||||
info_.vgprsPerSimd_ = 256;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isa().versionMajor() < 8) {
|
||||
info_.sgprsPerSimd_ = 512;
|
||||
} else if (isa().versionMajor() < 10) {
|
||||
|
||||
Yeni konuda referans
Bir kullanıcı engelle