diff --git a/hipamd/api/hip/hip_device.cpp b/hipamd/api/hip/hip_device.cpp index 4da7e42f4c..30ad2f3af1 100644 --- a/hipamd/api/hip/hip_device.cpp +++ b/hipamd/api/hip/hip_device.cpp @@ -96,10 +96,8 @@ hipError_t ihipDeviceGetCount(int* count) { return hipErrorInvalidValue; } - auto* deviceHandle = g_devices[0]->devices()[0]; - // Get all available devices - *count = deviceHandle->isOrdinalValid() ? g_devices.size() : 0; + *count = g_devices.size(); return hipSuccess; } diff --git a/hipamd/api/hip/hip_internal.hpp b/hipamd/api/hip/hip_internal.hpp index 472051a379..325f0b7cd3 100644 --- a/hipamd/api/hip/hip_internal.hpp +++ b/hipamd/api/hip/hip_internal.hpp @@ -29,10 +29,9 @@ THE SOFTWARE. #include #define HIP_INIT() \ - std::call_once(hip::g_ihipInitialized, hip::init); \ - assert(g_devices.size() > 0); \ - if (hip::g_context == nullptr) { \ - hip::g_context = g_devices[0]; \ + std::call_once(hip::g_ihipInitialized, hip::init); \ + if (hip::g_context == nullptr && g_devices.size() > 0) { \ + hip::g_context = g_devices[0]; \ } // This macro should be called at the beginning of every HIP API. diff --git a/hipamd/api/hip/hip_platform.cpp b/hipamd/api/hip/hip_platform.cpp index 2adf74f7ce..ba0d50865d 100644 --- a/hipamd/api/hip/hip_platform.cpp +++ b/hipamd/api/hip/hip_platform.cpp @@ -59,6 +59,9 @@ extern "C" hipModule_t __hipRegisterFatBinary(const void* data) { HIP_INIT(); + if(g_devices.empty()) { + return nullptr; + } const __CudaFatBinaryWrapper* fbwrapper = reinterpret_cast(data); if (fbwrapper->magic != __hipFatMAGIC2 || fbwrapper->version != 1) { return nullptr;