14 #ifndef HWLOC_OPENCL_H
15 #define HWLOC_OPENCL_H
18 #include <hwloc/autogen/config.h>
19 #include <hwloc/helper.h>
20 #ifdef HWLOC_LINUX_SYS
21 #include <hwloc/linux.h>
25 #include <OpenCL/cl.h>
26 #include <OpenCL/cl_ext.h>
29 #include <CL/cl_ext.h>
68 static __hwloc_inline
int
70 cl_device_id device __hwloc_attribute_unused,
73 #if (defined HWLOC_LINUX_SYS) && (defined CL_DEVICE_TOPOLOGY_AMD)
75 #define HWLOC_OPENCL_DEVICE_SYSFS_PATH_MAX 128
76 char path[HWLOC_OPENCL_DEVICE_SYSFS_PATH_MAX];
78 cl_device_topology_amd amdtopo;
86 clret = clGetDeviceInfo(device, CL_DEVICE_TOPOLOGY_AMD,
sizeof(amdtopo), &amdtopo, NULL);
87 if (CL_SUCCESS != clret) {
91 if (CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD != amdtopo.raw.type) {
96 sprintf(path,
"/sys/bus/pci/devices/0000:%02x:%02x.%01x/local_cpus",
97 (
unsigned) amdtopo.pcie.bus, (
unsigned) amdtopo.pcie.device, (
unsigned) amdtopo.pcie.function);
98 sysfile = fopen(path,
"r");
131 unsigned platform_index,
unsigned device_index)
133 unsigned x = (unsigned) -1, y = (
unsigned) -1;
138 && sscanf(osdev->
name,
"opencl%ud%u", &x, &y) == 2
139 && platform_index == x && device_index == y)
160 cl_device_id device __hwloc_attribute_unused)
162 #ifdef CL_DEVICE_TOPOLOGY_AMD
164 cl_device_topology_amd amdtopo;
167 clret = clGetDeviceInfo(device, CL_DEVICE_TOPOLOGY_AMD,
sizeof(amdtopo), &amdtopo, NULL);
168 if (CL_SUCCESS != clret) {
172 if (CL_DEVICE_TOPOLOGY_TYPE_PCIE_AMD != amdtopo.raw.type) {
180 if (strncmp(osdev->
name,
"opencl", 6))