From 59fcaf482127f458765b88197e540a8a99452b99 Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 7 Jul 2017 17:29:57 -0400
Subject: [PATCH] P4 to Git Change 1431618 by jatang@jatang-opencl-hsa-stg1 on
2017/07/07 16:47:09
SWDEV-126057 - Fix a segfault of libamdocl-rocr64.so when there's no vega10 is in the system.
When there's no supported device, Device::devices_ is not created. So we add a check.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#56 edit
[ROCm/clr commit: a00fa77a6ed6300b053016369191dea1576c6017]
---
.../rocclr/runtime/device/rocm/rocdevice.cpp | 20 ++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp b/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp
index bc9cb20466..3926c7eb41 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp
@@ -512,15 +512,17 @@ bool Device::init() {
}
}
- // Loop through all available devices
- for (auto device1: Device::devices()) {
- // Find all agents that can have access to the current device
- for (auto agent: static_cast(device1)->p2pAgents()) {
- // Find cl_device_id associated with the current agent
- for (auto device2: Device::devices()) {
- if (agent.handle == static_cast(device2)->getBackendDevice().handle) {
- // Device2 can have access to device1
- device2->p2pDevices_.push_back(as_cl(device1));
+ if (0 != Device::numDevices(CL_DEVICE_TYPE_GPU, false)) {
+ // Loop through all available devices
+ for (auto device1: Device::devices()) {
+ // Find all agents that can have access to the current device
+ for (auto agent: static_cast(device1)->p2pAgents()) {
+ // Find cl_device_id associated with the current agent
+ for (auto device2: Device::devices()) {
+ if (agent.handle == static_cast(device2)->getBackendDevice().handle) {
+ // Device2 can have access to device1
+ device2->p2pDevices_.push_back(as_cl(device1));
+ }
}
}
}