P4 to Git Change 1595124 by skudchad@skudchad_test2_win_opencl on 2018/08/17 14:05:25
SWDEV-145570 - [HIP] Implement environment variables and subsequent changes for HIP. This gets hipEnvVar passing ReviewBoardURL = http://ocltc.amd.com/reviews/r/15641/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_device.cpp#15 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#224 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#310 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#104 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#95 edit ... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#297 edit
This commit is contained in:
@@ -403,19 +403,37 @@ bool Device::init() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<bool> selectedDevices;
|
||||
selectedDevices.resize(gpu_agents_.size(), true);
|
||||
std::unordered_map<int, bool> selectedDevices;
|
||||
bool useDeviceList = false;
|
||||
|
||||
if (!flagIsDefault(GPU_DEVICE_ORDINAL)) {
|
||||
std::fill(selectedDevices.begin(), selectedDevices.end(), false);
|
||||
if ((GPU_DEVICE_ORDINAL != '\0') || (HIP_VISIBLE_DEVICES[0] != '\0')
|
||||
|| (CUDA_VISIBLE_DEVICES != '\0')) {
|
||||
useDeviceList = true;
|
||||
std::string ordinals = IS_HIP ? ((HIP_VISIBLE_DEVICES[0] != '\0') ?
|
||||
HIP_VISIBLE_DEVICES : CUDA_VISIBLE_DEVICES)
|
||||
: GPU_DEVICE_ORDINAL;
|
||||
|
||||
std::string ordinals(GPU_DEVICE_ORDINAL);
|
||||
size_t end, pos = 0;
|
||||
do {
|
||||
bool deviceIdValid = true;
|
||||
end = ordinals.find_first_of(',', pos);
|
||||
size_t index = atoi(ordinals.substr(pos, end - pos).c_str());
|
||||
selectedDevices.resize(index + 1);
|
||||
selectedDevices[index] = true;
|
||||
int index = atoi(ordinals.substr(pos, end - pos).c_str());
|
||||
if (index < 0 || static_cast<size_t>(index) >= gpu_agents_.size()) {
|
||||
deviceIdValid = false;
|
||||
}
|
||||
// FIXME Allow atleast one valid deviceId so compilation etc doesnt break
|
||||
// but set validOrdinal_ flag
|
||||
if (!deviceIdValid && (selectedDevices.size() != 0)) {
|
||||
// Exit the loop as anything to the right of invalid deviceId
|
||||
// has to be discarded unless its the first one
|
||||
break;
|
||||
}
|
||||
|
||||
if (!deviceIdValid && (selectedDevices.size() == 0)) {
|
||||
Device::setvalidOrdinal(false);
|
||||
}
|
||||
|
||||
selectedDevices[index] = deviceIdValid;
|
||||
pos = end + 1;
|
||||
} while (end != std::string::npos);
|
||||
}
|
||||
@@ -538,10 +556,13 @@ bool Device::init() {
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedDevices[ordinal++] &&
|
||||
(flagIsDefault(GPU_DEVICE_NAME) || GPU_DEVICE_NAME == 0 || GPU_DEVICE_NAME[0] == '\0' ||
|
||||
!strcmp(GPU_DEVICE_NAME, roc_device->info_.name_))) {
|
||||
roc_device.release()->registerDevice();
|
||||
if (!useDeviceList && (flagIsDefault(GPU_DEVICE_NAME) || GPU_DEVICE_NAME == 0
|
||||
|| GPU_DEVICE_NAME[0] == '\0' || !strcmp(GPU_DEVICE_NAME, roc_device->info_.name_))) {
|
||||
roc_device.release()->registerDevice();
|
||||
} else if (useDeviceList && selectedDevices[ordinal++]) {
|
||||
roc_device.release()->registerDevice();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
مرجع در شماره جدید
Block a user