Back to index

numactl  2.0.8~rc4
stream_main.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <sys/mman.h>
00003 #include <stdlib.h>
00004 #include "numa.h"
00005 #include "numaif.h"
00006 #include "util.h"
00007 #include "stream_lib.h"
00008 
00009 void usage(void)
00010 {
00011        exit(1);
00012 }
00013 
00014 char *policy = "default";
00015 
00016 /* Run STREAM with a numa policy */
00017 int main(int ac, char **av)
00018 {
00019        struct bitmask *nodes;
00020        char *map;
00021        long size;
00022        int policy;
00023 
00024        policy = parse_policy(av[1], av[2]);
00025 
00026         nodes = numa_allocate_nodemask();
00027 
00028        if (av[1] && av[2])
00029               nodes = numa_parse_nodestring(av[2]);
00030        if (!nodes) {
00031               printf ("<%s> is invalid\n", av[2]);
00032               exit(1);
00033        }
00034        size = stream_memsize();
00035        map = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
00036                  0, 0);
00037        if (map == (char*)-1) exit(1);
00038        if (mbind(map, size, policy, nodes->maskp, nodes->size, 0) < 0)
00039               perror("mbind"), exit(1);
00040        stream_init(map);
00041        stream_test(NULL);
00042        return 0;
00043 }