~ubuntu-branches/ubuntu/saucy/numactl/saucy-proposed

« back to all changes in this revision

Viewing changes to test/prefered.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:
5
5
#include <assert.h>
6
6
#include <unistd.h>
7
7
#include <stdlib.h>
 
8
#include <numa.h>
8
9
 
9
10
#define err(x) perror(x),exit(1)
10
11
 
11
12
int main(void)
12
13
{
 
14
        int max = numa_max_node();
13
15
        unsigned long nodes, mask;
14
16
        int sz = getpagesize();
15
17
        char *mem = mmap(NULL, sz*2, PROT_READ|PROT_WRITE, 
22
24
        if (mem == (char *)-1)
23
25
                err("mmap");
24
26
 
25
 
        for (i = 1; i >= 0; i--) { 
 
27
        for (i = max; i >= 0; i--) { 
26
28
                printf("%d\n", i); 
27
29
 
28
30
                nodes = 1UL << i;
31
33
                
32
34
                mem[off] = 0;
33
35
                        
34
 
                if (get_mempolicy(&pol, &mask, 2, mem+off, MPOL_F_ADDR) < 0) 
 
36
                if (get_mempolicy(&pol, &mask, 64, mem+off, MPOL_F_ADDR) < 0) 
35
37
                        err("get_mempolicy");
36
38
        
37
39
                assert(pol == MPOL_PREFERRED);
38
40
                assert(mask & (1UL << i)); 
39
41
 
 
42
 
 
43
                node = 0x123;
 
44
                
40
45
                if (get_mempolicy(&node, NULL, 0, mem+off, MPOL_F_ADDR|MPOL_F_NODE) < 0)
41
46
                        err("get_mempolicy2"); 
42
47
 
 
48
                printf("node %d\n", i);
 
49
 
43
50
                assert(node == i);      
44
51
 
45
52
                off += sz;