Return hipErrorInsufficientDriver status when CPU device not found (#1064)

* Return hipErrorInsufficientDriver status when CPU device not found - no exception thrown

* Return hipErrorInsufficientDriver status when CPU device not found
This commit is contained in:
wkwchau
2019-05-07 06:28:25 -04:00
gecommit door Maneesh Gupta
bovenliggende 46ac83a429
commit ebf986dcee
+12 -3
Bestand weergeven
@@ -130,6 +130,7 @@ std::vector<int> 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<int> 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(), "<ihipInit>",
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;
}
}
}