diff --git a/projects/hip/rocclr/hip_device_runtime.cpp b/projects/hip/rocclr/hip_device_runtime.cpp index 9ed1c64145..414d51f513 100644 --- a/projects/hip/rocclr/hip_device_runtime.cpp +++ b/projects/hip/rocclr/hip_device_runtime.cpp @@ -449,7 +449,11 @@ hipError_t hipDeviceSynchronize ( void ) { } int ihipGetDevice() { - return hip::getCurrentDevice()->deviceId(); + hip::Device* device = hip::getCurrentDevice(); + if(device == nullptr){ + return -1; + } + return device->deviceId(); } hipError_t hipGetDevice ( int* deviceId ) {