~ubuntu-branches/ubuntu/trusty/numactl/trusty

« back to all changes in this revision

Viewing changes to test/distance.c

  • Committer: Bazaar Package Importer
  • Author(s): Ian Wienand
  • Date: 2006-01-04 10:25:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060104102527-1seu1f5eafl9iuoc
Tags: 0.9-1
* New upstream
* Most patches accepted into upstream; see upstream changelog or
  debian/patches/README in source package for history

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Test numa_distance */
 
2
#include <numa.h>
 
3
#include <stdio.h>
 
4
#include <stdlib.h>
 
5
 
 
6
int main(void)
 
7
{
 
8
        int numnodes, a, b;
 
9
        if (numa_available() < 0) {
 
10
                printf("no numa support in kernel\n");
 
11
                exit(1);
 
12
        }
 
13
 
 
14
        numnodes = numa_max_node()+1;
 
15
        for (a = 0; a < numnodes; a++) { 
 
16
                printf("%03d: ", a); 
 
17
                if (numa_distance(a, a) != 10) { 
 
18
                        printf("%d: self distance is not 10 (%d)\n", 
 
19
                               a, numa_distance(a,a));
 
20
                        exit(1);
 
21
                }
 
22
                for (b = 0; b < numnodes; b++) { 
 
23
                        int d1 = numa_distance(a, b); 
 
24
                        int d2 = numa_distance(b, a);
 
25
                        printf("%03d ", d1);
 
26
                        if (d1 != d2) {
 
27
                                printf("\n(%d,%d)->(%d,%d) wrong!\n",a,b,d1,d2); 
 
28
                                exit(1);
 
29
                        }
 
30
                }
 
31
                printf("\n");
 
32
        } 
 
33
        return 0;       
 
34
}
 
35