Back to index

numactl  2.0.8~rc4
distance.c
Go to the documentation of this file.
00001 /* Test numa_distance */
00002 #include <numa.h>
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 
00006 int main(void)
00007 {
00008        int numnodes, a, b;
00009        if (numa_available() < 0) {
00010               printf("no numa support in kernel\n");
00011               exit(1);
00012        }
00013 
00014         numnodes = numa_num_configured_nodes();
00015        for (a = 0; a < numnodes; a++) { 
00016               printf("%03d: ", a); 
00017               if (numa_distance(a, a) != 10) { 
00018                      printf("%d: self distance is not 10 (%d)\n", 
00019                             a, numa_distance(a,a));
00020                      exit(1);
00021               }
00022               for (b = 0; b < numnodes; b++) { 
00023                      int d1 = numa_distance(a, b); 
00024                      int d2 = numa_distance(b, a);
00025                      printf("%03d ", d1);
00026                      if (d1 != d2) {
00027                             printf("\n(%d,%d)->(%d,%d) wrong!\n",a,b,d1,d2); 
00028                             exit(1);
00029                      }
00030               }
00031               printf("\n");
00032        } 
00033        return 0;     
00034 }
00035