From 067c7316bacb8c99e04df4ea9f9128266ccde5be Mon Sep 17 00:00:00 2001 From: Anusha GodavarthySurya Date: Fri, 23 Dec 2022 10:37:48 +0000 Subject: [PATCH] SWDEV-373173 - Correct max VGPRs and VGPR Granularity in Occupancy calculation for different asics Change-Id: Ib213ed8767a793a832776fba7c0811c2f023a8ad --- hipamd/src/hip_platform.cpp | 68 ++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/hipamd/src/hip_platform.cpp b/hipamd/src/hip_platform.cpp index afcbaab007..93bdf4f837 100644 --- a/hipamd/src/hip_platform.cpp +++ b/hipamd/src/hip_platform.cpp @@ -333,20 +333,62 @@ hipError_t ihipOccupancyMaxActiveBlocksPerMultiprocessor( MaxWavesPerSimd = 16; } size_t VgprWaves = MaxWavesPerSimd; - size_t maxVGPRs; - uint32_t VgprGranularity; - if (device.isa().versionMajor() <= 9) { - if (device.isa().versionMajor() == 9 && device.isa().versionMinor() == 0 && - device.isa().versionStepping() == 10) { - maxVGPRs = 512; - VgprGranularity = 8; - } else { - maxVGPRs = 256; + uint32_t VgprGranularity = 0; + size_t maxVGPRs = 0; + size_t wavefrontSize = wrkGrpInfo->wavefrontSize_; + switch (device.isa().versionMajor()) { + case (11): + if (device.isa().versionMinor() == 0) { + switch (device.isa().versionStepping()) { + case (0): + case (1): + VgprGranularity = (wavefrontSize == 32) ? 24 : 12; + maxVGPRs = (wavefrontSize == 32) ? 1536 : 768; + break; + case (2): + case (3): + VgprGranularity = (wavefrontSize == 32) ? 16 : 8; + maxVGPRs = (wavefrontSize == 32) ? 1024 : 512; + break; + default: + VgprGranularity = 8; + maxVGPRs = 1024; + break; + } + } + break; + case (10): + switch (device.isa().versionMinor()) { + case (0): + case (1): + VgprGranularity = (wavefrontSize == 32) ? 8 : 4; + maxVGPRs = (wavefrontSize == 32) ? 1024 : 512; + break; + case (3): + VgprGranularity = (wavefrontSize == 32) ? 16 : 8; + maxVGPRs = (wavefrontSize == 32) ? 1024 : 512; + break; + default: + VgprGranularity = 8; + maxVGPRs = 1024; + break; + } + break; + case (9): + if ((device.isa().versionMinor() == 0 && device.isa().versionStepping() == 10) || + (device.isa().versionMinor() == 4 && device.isa().versionStepping() == 0)) { + VgprGranularity = 8; + maxVGPRs = 512; + } else { + VgprGranularity = 4; + maxVGPRs = 256; + } + break; + default: + // For gfx<=8 VgprGranularity = 4; - } - } else { - maxVGPRs = 1024; - VgprGranularity = 8; + maxVGPRs = 256; + break; } if (wrkGrpInfo->usedSGPRs_ > 0) { VgprWaves = maxVGPRs / amd::alignUp(wrkGrpInfo->usedVGPRs_, VgprGranularity);