From 0e2b348ef47c6a60da78c5f17878070ff09ee5ee Mon Sep 17 00:00:00 2001 From: Anusha Godavarthy Surya Date: Wed, 6 Jul 2022 10:52:10 -0700 Subject: [PATCH] SWDEV-344166 - Updated HIP APIs to return hipErrorNoDevice when there are no devices in the system Change-Id: I636828ff39d3b404f89bcc6e2cb7348d92c897ff --- hipamd/src/hip_internal.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hipamd/src/hip_internal.hpp b/hipamd/src/hip_internal.hpp index a847f16cc8..8a283954ae 100644 --- a/hipamd/src/hip_internal.hpp +++ b/hipamd/src/hip_internal.hpp @@ -118,8 +118,11 @@ static amd::Monitor g_hipInitlock{"hipInit lock"}; HIP_CB_SPAWNER_OBJECT(cid); // This macro should be called at the beginning of every HIP API. -#define HIP_INIT_API(cid, ...) \ - HIP_INIT_API_INTERNAL(0, cid, __VA_ARGS__) +#define HIP_INIT_API(cid, ...) \ + HIP_INIT_API_INTERNAL(0, cid, __VA_ARGS__) \ + if (g_devices.size() == 0) { \ + HIP_RETURN(hipErrorNoDevice); \ + } #define HIP_INIT_API_NO_RETURN(cid, ...) \ HIP_INIT_API_INTERNAL(1, cid, __VA_ARGS__) @@ -173,7 +176,7 @@ static amd::Monitor g_hipInitlock{"hipInit lock"}; // Sync APIs cannot be called when stream capture is active #define CHECK_STREAM_CAPTURING() \ if (!g_captureStreams.empty()) { \ - return hipErrorStreamCaptureImplicit; \ + return hipErrorStreamCaptureImplicit; \ } #define STREAM_CAPTURE(name, stream, ...) \ @@ -182,7 +185,7 @@ static amd::Monitor g_hipInitlock{"hipInit lock"}; reinterpret_cast(stream)->GetCaptureStatus() == \ hipStreamCaptureStatusActive) { \ hipError_t status = capture##name(stream, ##__VA_ARGS__); \ - return status; \ + return status; \ } #define EVENT_CAPTURE(name, event, ...) \