Make sure the list of HSA agents is valid

If HIP_VISIBLE_DEVICES is active, then make sure the list of HSA
agents contains the valid agents

Change-Id: I584aad999a230ab7f88a0cfe20dcd0abe79c43a5


[ROCm/clr commit: ae4aceb55e]
Bu işleme şunda yer alıyor:
German Andryeyev
2020-05-09 05:29:54 -04:00
ebeveyn ca678c2ffd
işleme b5f464e2af
+5 -11
Dosyayı Görüntüle
@@ -450,16 +450,12 @@ bool Device::init() {
return false;
}
std::unordered_map<int, bool> selectedDevices;
bool useDeviceList = false;
std::string ordinals = amd::IS_HIP ? ((HIP_VISIBLE_DEVICES[0] != '\0') ?
HIP_VISIBLE_DEVICES : CUDA_VISIBLE_DEVICES)
: GPU_DEVICE_ORDINAL;
if (ordinals[0] != '\0') {
useDeviceList = true;
size_t end, pos = 0;
std::vector<hsa_agent_t> valid_agents;
do {
bool deviceIdValid = true;
end = ordinals.find_first_of(',', pos);
@@ -472,14 +468,14 @@ bool Device::init() {
// Exit the loop as anything to the right of invalid deviceId
// has to be discarded
break;
} else {
valid_agents.push_back(gpu_agents_[index]);
}
selectedDevices[index] = deviceIdValid;
pos = end + 1;
} while (end != std::string::npos);
gpu_agents_ = valid_agents;
}
size_t ordinal = 0;
for (auto agent : gpu_agents_) {
std::unique_ptr<Device> roc_device(new Device(agent));
@@ -600,9 +596,7 @@ bool Device::init() {
}
}
if (!useDeviceList || selectedDevices[ordinal++]) {
roc_device.release()->registerDevice();
}
roc_device.release()->registerDevice();
}
if (0 != Device::numDevices(CL_DEVICE_TYPE_GPU, false)) {