diff --git a/hipamd/src/hip_hcc.cpp b/hipamd/src/hip_hcc.cpp index dd08f2bb2e..8011160cc1 100644 --- a/hipamd/src/hip_hcc.cpp +++ b/hipamd/src/hip_hcc.cpp @@ -130,6 +130,7 @@ std::vector g_hip_visible_devices; hsa_agent_t g_cpu_agent; hsa_agent_t* g_allAgents; // CPU agents + all the visible GPU agents. unsigned g_numLogicalThreads; +bool g_initDeviceFound = false; std::atomic g_lastShortTid(1); @@ -1405,7 +1406,8 @@ void ihipInit() { hsa_status_t err = hsa_iterate_agents(findCpuAgent, &g_cpu_agent); if (err != HSA_STATUS_INFO_BREAK) { // didn't find a CPU. - throw ihipException(hipErrorRuntimeOther); + g_initDeviceFound = false; + return; } g_deviceArray = new ihipDevice_t*[deviceCnt]; @@ -1440,14 +1442,21 @@ void ihipInit() { tprintf(DB_SYNC, "pid=%u %-30s g_numLogicalThreads=%u\n", getpid(), "", g_numLogicalThreads); + + g_initDeviceFound = true; } namespace hip_impl { hipError_t hip_init() { static std::once_flag hip_initialized; std::call_once(hip_initialized, ihipInit); - ihipCtxStackUpdate(); - return hipSuccess; + if (g_initDeviceFound) { + ihipCtxStackUpdate(); + return hipSuccess; + } + else { + return hipErrorInsufficientDriver; + } } }