From 2ccaf82efcee980ea9e88da6b7706731b7e58715 Mon Sep 17 00:00:00 2001 From: Ioannis Assiouras Date: Thu, 15 Dec 2022 08:01:21 -0500 Subject: [PATCH] SWDEV-373630 - Added input checks in hipOccupancy query functions. Change-Id: I2b3e47a094acf5968e714bd853c4497995ef386b [ROCm/clr commit: a38296158cb6717fd92ce91835f6a63364482bf7] --- projects/clr/hipamd/src/hip_platform.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/projects/clr/hipamd/src/hip_platform.cpp b/projects/clr/hipamd/src/hip_platform.cpp index 1624e080b0..1e12cfd4fa 100644 --- a/projects/clr/hipamd/src/hip_platform.cpp +++ b/projects/clr/hipamd/src/hip_platform.cpp @@ -397,7 +397,7 @@ hipError_t hipOccupancyMaxPotentialBlockSize(int* gridSize, int* blockSize, cons hipFunction_t func = nullptr; hipError_t hip_error = PlatformState::instance().getStatFunc(&func, f, ihipGetDevice()); if ((hip_error != hipSuccess) || (func == nullptr)) { - HIP_RETURN(hipErrorInvalidValue); + HIP_RETURN(hipErrorInvalidDeviceFunction); } const amd::Device& device = *hip::getCurrentDevice()->devices()[0]; int max_blocks_per_grid = 0; @@ -416,7 +416,7 @@ hipError_t hipOccupancyMaxPotentialBlockSize(int* gridSize, int* blockSize, cons hipError_t hipModuleOccupancyMaxPotentialBlockSize(int* gridSize, int* blockSize, hipFunction_t f, size_t dynSharedMemPerBlk, int blockSizeLimit) { HIP_INIT_API(hipModuleOccupancyMaxPotentialBlockSize, f, dynSharedMemPerBlk, blockSizeLimit); - if ((gridSize == nullptr) || (blockSize == nullptr)) { + if ((gridSize == nullptr) || (blockSize == nullptr) || (f == nullptr)) { HIP_RETURN(hipErrorInvalidValue); } const amd::Device& device = *hip::getCurrentDevice()->devices()[0]; @@ -440,7 +440,7 @@ hipError_t hipModuleOccupancyMaxPotentialBlockSizeWithFlags(int* gridSize, int* unsigned int flags) { HIP_INIT_API(hipModuleOccupancyMaxPotentialBlockSizeWithFlags, f, dynSharedMemPerBlk, blockSizeLimit, flags); - if ((gridSize == nullptr) || (blockSize == nullptr)) { + if ((gridSize == nullptr) || (blockSize == nullptr) || (f == nullptr)) { HIP_RETURN(hipErrorInvalidValue); } if (flags != hipOccupancyDefault && flags != hipOccupancyDisableCachingOverride) { @@ -465,7 +465,7 @@ hipError_t hipModuleOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks, hi size_t dynSharedMemPerBlk) { HIP_INIT_API(hipModuleOccupancyMaxActiveBlocksPerMultiprocessor, f, blockSize, dynSharedMemPerBlk); - if (numBlocks == nullptr) { + if (numBlocks == nullptr || (f == nullptr)) { HIP_RETURN(hipErrorInvalidValue); } const amd::Device& device = *hip::getCurrentDevice()->devices()[0]; @@ -484,7 +484,7 @@ hipError_t hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags( int* numBlocks, hipFunction_t f, int blockSize, size_t dynSharedMemPerBlk, unsigned int flags) { HIP_INIT_API(hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, f, blockSize, dynSharedMemPerBlk, flags); - if (numBlocks == nullptr) { + if (numBlocks == nullptr || (f == nullptr)) { HIP_RETURN(hipErrorInvalidValue); } if (flags != hipOccupancyDefault && flags != hipOccupancyDisableCachingOverride) { @@ -512,7 +512,7 @@ hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessor(int* numBlocks, const vo hipFunction_t func = nullptr; hipError_t hip_error = PlatformState::instance().getStatFunc(&func, f, ihipGetDevice()); if ((hip_error != hipSuccess) || (func == nullptr)) { - HIP_RETURN(hipErrorInvalidValue); + HIP_RETURN(hipErrorInvalidDeviceFunction); } const amd::Device& device = *hip::getCurrentDevice()->devices()[0]; @@ -542,7 +542,7 @@ hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int* numBlocks, hipFunction_t func = nullptr; hipError_t hip_error = PlatformState::instance().getStatFunc(&func, f, ihipGetDevice()); if ((hip_error != hipSuccess) || (func == nullptr)) { - HIP_RETURN(hipErrorInvalidValue); + HIP_RETURN(hipErrorInvalidDeviceFunction); } const amd::Device& device = *hip::getCurrentDevice()->devices()[0];