Merge "[hip-vdi]Fix for TF build failure [SWDEV-225827]" into amd-master-next
[ROCm/clr commit: 4cd02f20cf]
This commit is contained in:
@@ -3437,6 +3437,13 @@ hipError_t hipBindTextureToMipmappedArray(const texture<T, dim, readMode>& tex,
|
||||
}
|
||||
|
||||
#if __HIP_VDI__ && !defined(__HCC__)
|
||||
|
||||
template <typename F>
|
||||
inline hipError_t hipOccupancyMaxPotentialBlockSize(uint32_t* gridSize, uint32_t* blockSize,
|
||||
F kernel, size_t dynSharedMemPerBlk, uint32_t blockSizeLimit) {
|
||||
return hipOccupancyMaxPotentialBlockSize(gridSize, blockSize,(hipFunction_t)kernel, dynSharedMemPerBlk, blockSizeLimit);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline hipError_t hipLaunchCooperativeKernel(T f, dim3 gridDim, dim3 blockDim,
|
||||
void** kernelParams, unsigned int sharedMemBytes, hipStream_t stream) {
|
||||
|
||||
+1
-3
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
// Test the Grid_Launch syntax.
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
@@ -46,10 +46,8 @@ int main(int argc, char* argv[]) {
|
||||
// test case for using kernel function pointer
|
||||
uint32_t gridSize = 0;
|
||||
uint32_t blockSize = 0;
|
||||
#if defined(__HIP_PLATFORM_HCC__) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__)
|
||||
hipOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, f1, 0, 0);
|
||||
assert(gridSize != 0 && blockSize != 0);
|
||||
#endif
|
||||
|
||||
// test case for using kernel function pointer with template
|
||||
gridSize = 0;
|
||||
|
||||
@@ -135,6 +135,7 @@ hipModuleLoad
|
||||
hipModuleLoadData
|
||||
hipModuleLoadDataEx
|
||||
hipModuleUnload
|
||||
hipOccupancyMaxPotentialBlockSize
|
||||
hipOccupancyMaxActiveBlocksPerMultiprocessor
|
||||
hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
|
||||
hipFuncGetAttributes
|
||||
|
||||
@@ -135,6 +135,7 @@ global:
|
||||
hipModuleLoadData;
|
||||
hipModuleLoadDataEx;
|
||||
hipModuleUnload;
|
||||
hipOccupancyMaxPotentialBlockSize;
|
||||
hipOccupancyMaxActiveBlocksPerMultiprocessor;
|
||||
hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags;
|
||||
hipFuncGetAttributes;
|
||||
|
||||
@@ -604,13 +604,12 @@ hipError_t ihipCreateGlobalVarObj(const char* name, hipModule_t hmod, amd::Memor
|
||||
|
||||
|
||||
namespace hip_impl {
|
||||
|
||||
hipError_t ihipOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks,
|
||||
hipFunction_t f,
|
||||
int blockSize,
|
||||
size_t dynamicSMemSize)
|
||||
hipError_t ihipOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks, int* numGrids,
|
||||
hipFunction_t f, int blockSize,
|
||||
size_t dynamicSMemSize, bool bCalcPotentialBlkSz)
|
||||
{
|
||||
HIP_INIT_API(NONE, f, blockSize, dynamicSMemSize);
|
||||
HIP_INIT_API(NONE, f, blockSize, dynamicSMemSize, bCalcPotentialBlkSz);
|
||||
if(numBlocks == nullptr){HIP_RETURN(hipErrorInvalidValue);}
|
||||
int deviceId = ihipGetDevice();
|
||||
// FIXME: Function may not be a device function and may have been obtaiend via
|
||||
// hipModuleGetFunction and thus not in the functions_ map. Check the map
|
||||
@@ -627,12 +626,16 @@ hipError_t ihipOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks,
|
||||
if (!kernel) {
|
||||
HIP_RETURN(hipErrorOutOfMemory);
|
||||
}
|
||||
if (blockSize == 0) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
amd::Device* device = hip::getCurrentDevice()->devices()[0];
|
||||
const device::Kernel::WorkGroupInfo* wrkGrpInfo = kernel->getDeviceKernel(*device)->workGroupInfo();
|
||||
|
||||
if (blockSize == 0) {
|
||||
if (bCalcPotentialBlkSz == false){
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
else {
|
||||
blockSize = device->info().maxWorkGroupSize_; // maxwavefrontperblock
|
||||
}
|
||||
}
|
||||
// Find threads accupancy per CU => simd_per_cu * GPR usage
|
||||
constexpr size_t MaxWavesPerSimd = 8; // Limited by SPI 32 per CU, hence 8 per SIMD
|
||||
size_t VgprWaves = wrkGrpInfo->availableVGPRs_ / amd::alignUp(wrkGrpInfo->usedVGPRs_, 4);
|
||||
@@ -658,12 +661,33 @@ hipError_t ihipOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks,
|
||||
int lds_occupancy = static_cast<int>(device->info().localMemSize_ / total_used_lds);
|
||||
*numBlocks = std::min(*numBlocks, lds_occupancy);
|
||||
}
|
||||
if (bCalcPotentialBlkSz){
|
||||
if (numGrids == nullptr){
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
*numGrids = *numBlocks * device->info().numRTCUs_;
|
||||
}
|
||||
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
// FIXME: Need to replace `uint32_t` with `int` finally.
|
||||
hipError_t hipOccupancyMaxPotentialBlockSize(uint32_t* gridSize, uint32_t* blockSize,
|
||||
hipFunction_t f, size_t dynSharedMemPerBlk,
|
||||
uint32_t blockSizeLimit)
|
||||
{
|
||||
int numGrids = 0;
|
||||
int numBlocks = 0;
|
||||
hipError_t Ret = hip_impl::ihipOccupancyMaxActiveBlocksPerMultiprocessor(&numBlocks, &numGrids, f, 0, dynSharedMemPerBlk,true);
|
||||
if (Ret == hipSuccess){
|
||||
*blockSize = numBlocks;
|
||||
*gridSize = numGrids;
|
||||
}
|
||||
HIP_RETURN(Ret);
|
||||
}
|
||||
|
||||
// FIXME: Need to replace `uint32_t` with `int` finally.
|
||||
hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessor(uint32_t* numBlocks,
|
||||
hipFunction_t f,
|
||||
@@ -671,7 +695,7 @@ hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessor(uint32_t* numBlocks,
|
||||
size_t dynamicSMemSize)
|
||||
{
|
||||
int NB;
|
||||
hipError_t Ret = hip_impl::ihipOccupancyMaxActiveBlocksPerMultiprocessor(&NB, f, blockSize, dynamicSMemSize);
|
||||
hipError_t Ret = hip_impl::ihipOccupancyMaxActiveBlocksPerMultiprocessor(&NB, nullptr, f, blockSize, dynamicSMemSize, false);
|
||||
*numBlocks = NB;
|
||||
HIP_RETURN(Ret);
|
||||
}
|
||||
@@ -684,7 +708,7 @@ hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(uint32_t* numBl
|
||||
unsigned int flags)
|
||||
{
|
||||
int NB;
|
||||
hipError_t Ret = hip_impl::ihipOccupancyMaxActiveBlocksPerMultiprocessor(&NB, f, blockSize, dynamicSMemSize);
|
||||
hipError_t Ret = hip_impl::ihipOccupancyMaxActiveBlocksPerMultiprocessor(&NB, nullptr, f, blockSize, dynamicSMemSize, false);
|
||||
*numBlocks = NB;
|
||||
HIP_RETURN(Ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user