1
2 /* Originally from Galen Arnold, NCSA arnoldg@ncsa.illinois.edu
3 * modified by Guochun Shi
4 *
5 */
6
9
10 #ifdef NUMA_NVML
11 #include <nvml.h>
12 #endif
13
14
16 {
17 #ifdef NUMA_NVML
18 nvmlReturn_t result;
19
20 result = nvmlInit();
21 if (NVML_SUCCESS != result)
22 {
23 warningQuda(
"Failed to determine NUMA affinity for device %d (NVML Init failed)", devid);
24 return -1;
25 }
26 nvmlDevice_t device;
27 result = nvmlDeviceGetHandleByIndex(devid, &device);
28 if (NVML_SUCCESS != result)
29 {
30 warningQuda(
"Failed to determine NUMA affinity for device %d (NVML DeviceGetHandle failed)", devid);
31 return -1;
32 }
33 result = nvmlDeviceSetCpuAffinity(device);
34 if (NVML_SUCCESS != result)
35 {
36 warningQuda(
"Failed to determine NUMA affinity for device %d (NVML DeviceSetCpuAffinity failed)", devid);
37 return -1;
38 }
39 else{
40 printfQuda(
"Set NUMA affinity for device %d (NVML DeviceSetCpuAffinity)\n", devid);
41 }
42 result = nvmlShutdown();
43 if (NVML_SUCCESS != result)
44 {
45 warningQuda(
"Failed to determine NUMA affinity for device %d (NVML Shutdown failed)", devid);
46 return -1;
47 }
48 return 0;
49 #else
50 warningQuda(
"Failed to determine NUMA affinity for device %d (NVML not supported in quda build)", devid);
51 return -1;
52 #endif
53 }
int setNumaAffinityNVML(int devid)