From bb32492438e0dfd73afd7241a356b85767664c4a Mon Sep 17 00:00:00 2001 From: jujiang Date: Wed, 10 Jun 2020 13:25:00 -0400 Subject: [PATCH] Fix for SWDEV-239415 to handle hipGetDevice properly while no GPU present Change-Id: I252cbbf9a89fc76fe1be1fbb8f45778e96c70fb2 --- hipamd/rocclr/hip_device_runtime.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hipamd/rocclr/hip_device_runtime.cpp b/hipamd/rocclr/hip_device_runtime.cpp index 9ed1c64145..414d51f513 100644 --- a/hipamd/rocclr/hip_device_runtime.cpp +++ b/hipamd/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 ) {