From a1e5fb0c3c7dbbcce0a6335882231d0879ced083 Mon Sep 17 00:00:00 2001 From: foreman Date: Fri, 20 Dec 2019 13:02:52 -0600 Subject: [PATCH] P4 to Git Change 2049240 by lmoriche@lmoriche_opencl_dev2 on 2019/12/20 13:54:17 SWDEV-216705 - [hipclang-vdi-rocm][FBA-80]Test crash when all GPUs are hidden by ROCR_VISIBLE_DEVICES Return an error instead of dereferencing a null pointer. This should address the issue described in the ticket, but more places need fixing in the runtime to avoid crashes for corner cases. Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_platform.cpp#59 edit [ROCm/hip commit: 0c35aa5f1c13a375e774253164e35881abbef664] --- projects/hip/api/hip/hip_platform.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/api/hip/hip_platform.cpp b/projects/hip/api/hip/hip_platform.cpp index 1aa356cd36..c91199c077 100644 --- a/projects/hip/api/hip/hip_platform.cpp +++ b/projects/hip/api/hip/hip_platform.cpp @@ -569,6 +569,9 @@ extern "C" hipError_t hipLaunchKernel(const void *hostFunction, stream); int deviceId = ihipGetDevice(); + if (deviceId == -1) { + HIP_RETURN(hipErrorNoDevice); + } hipFunction_t func = PlatformState::instance().getFunc(hostFunction, deviceId); if (func == nullptr) { HIP_RETURN(hipErrorInvalidDeviceFunction);