From 572efac7a5f2cd942d035e6dcee2eda23dd6ef01 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 [ROCm/hip commit: c54590ebbd3afc787888ddd02da753f22150f4c6] --- projects/hip/rocclr/hip_device_runtime.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 ) {