diff --git a/hipamd/src/hip_platform.cpp b/hipamd/src/hip_platform.cpp index f4a4ab4b74..2ace8e3174 100644 --- a/hipamd/src/hip_platform.cpp +++ b/hipamd/src/hip_platform.cpp @@ -372,6 +372,12 @@ hipError_t ihipOccupancyMaxActiveBlocksPerMultiprocessor( VgprWaves = maxVGPRs / amd::alignUp(wrkGrpInfo->usedVGPRs_, VgprGranularity); } + if (VgprWaves == 0) { + // This should not happen ideally, but in case the usedVGPRs_/availableVGPRs_ values are + // incorrect, it can lead to a crash. By returning error, API can exit gracefully. + return hipErrorUnknown; + } + size_t GprWaves = VgprWaves; if (wrkGrpInfo->usedSGPRs_ > 0) { size_t maxSGPRs = device.info().sgprsPerSimd_; diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index f5b6597f71..5c9d383435 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -1812,8 +1812,8 @@ bool Device::populateOCLDeviceConstants() { } break; case (9): - if ((isa().versionMinor() == 0 && isa().versionStepping() == 10) || - (isa().versionMinor() == 4 && isa().versionStepping() == 0)) { + if ((isa().versionMinor() == 0 && isa().versionStepping() == 10) || // For gfx90a (MI200) + (isa().versionMinor() == 4)) { // For gfx94x (MI300) info_.vgprAllocGranularity_ = 8; info_.vgprsPerSimd_ = 512; } else {