File: distance.c

package info (click to toggle)
numactl 2.0.11-2.1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 1,912 kB
  • ctags: 922
  • sloc: sh: 11,860; ansic: 6,542; makefile: 104
file content (35 lines) | stat: -rw-r--r-- 705 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* Test numa_distance */
#include <numa.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int numnodes, a, b;
	if (numa_available() < 0) {
		printf("no numa support in kernel\n");
		exit(1);
	}

        numnodes = numa_num_configured_nodes();
	for (a = 0; a < numnodes; a++) { 
		printf("%03d: ", a); 
		if (numa_distance(a, a) != 10) { 
			printf("%d: self distance is not 10 (%d)\n", 
			       a, numa_distance(a,a));
			exit(1);
		}
		for (b = 0; b < numnodes; b++) { 
			int d1 = numa_distance(a, b); 
			int d2 = numa_distance(b, a);
			printf("%03d ", d1);
			if (d1 != d2) {
				printf("\n(%d,%d)->(%d,%d) wrong!\n",a,b,d1,d2); 
				exit(1);
			}
		}
		printf("\n");
	} 
	return 0;	
}