From 1154872b0d35a899da934e4d849311b9dcc4834c Mon Sep 17 00:00:00 2001 From: pensun Date: Sat, 27 Feb 2016 14:14:08 -0600 Subject: [PATCH] improve the HIP_VISIBLE_DEVICES implementation [ROCm/hip commit: 1f606261c1c724d2d009f8ca7d82ba5b8c945fff] --- projects/hip/src/hip_hcc.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 945248c11f..e9de7f53a6 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -291,6 +291,7 @@ thread_local int tls_defaultDevice = 0; // Global initialization. std::once_flag hip_initialized; ihipDevice_t *g_devices; // Array of all non-emulated (ie GPU) accelerators in the system. +bool g_visible_device = false; // Set the flag when HIP_VISIBLE_DEVICES is set unsigned g_deviceCnt; //================================================================================================= @@ -299,7 +300,7 @@ unsigned g_deviceCnt; //Forward Declarations: //================================================================================================= INLINE bool ihipIsValidDevice(unsigned deviceIndex); - +INLINE bool ihipIsVisibleDevice(unsigned deviceIndex); //================================================================================================= // Implementation: //================================================================================================= @@ -865,6 +866,7 @@ void ihipReadEnv_I(int *var_ptr, const char *var_name1, const char *var_name2, c std::string device_id; // Clean up the defult value g_hip_visible_devices.clear(); + g_visible_device = true; // Read the visible device numbers while (std::getline(ss, device_id, ',')) { if (atoi(device_id.c_str()) >= 0) { @@ -965,9 +967,10 @@ void ihipInit() for (int i=0; i"); - } INLINE bool ihipIsValidDevice(unsigned deviceIndex)