From 3dfe48b5821f35a05a5549f3bde647daf49fcd03 Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Tue, 11 Apr 2023 14:21:57 +0000 Subject: [PATCH] SWDEV-390597 - Return No Device error for hipSetDevice and hipSetDeviceFlags. Change-Id: I457b1197a8f1b71a8bbbdf09f193f643c61700b6 --- hipamd/src/hip_device_runtime.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hipamd/src/hip_device_runtime.cpp b/hipamd/src/hip_device_runtime.cpp index fb6df662d7..ed6c119463 100644 --- a/hipamd/src/hip_device_runtime.cpp +++ b/hipamd/src/hip_device_runtime.cpp @@ -559,18 +559,21 @@ hipError_t hipGetDeviceFlags ( unsigned int* flags ) { hipError_t hipSetDevice ( int device ) { HIP_INIT_API(hipSetDevice, device); - if (static_cast(device) < g_devices.size()) { hip::setCurrentDevice(device); HIP_RETURN(hipSuccess); + } else if (g_devices.empty()) { + HIP_RETURN(hipErrorNoDevice); } HIP_RETURN(hipErrorInvalidDevice); } hipError_t hipSetDeviceFlags ( unsigned int flags ) { HIP_INIT_API(hipSetDeviceFlags, flags); - + if (g_devices.empty()) { + HIP_RETURN(hipErrorNoDevice); + } constexpr uint32_t supportedFlags = hipDeviceScheduleMask | hipDeviceMapHost | hipDeviceLmemResizeToMax; constexpr uint32_t mutualExclusiveFlags =