forked from numactl/numactl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream_main.c
43 lines (37 loc) · 828 Bytes
/
stream_main.c
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
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <sys/mman.h>
#include <stdlib.h>
#include "numa.h"
#include "numaif.h"
#include "util.h"
#include "stream_lib.h"
void usage(void)
{
exit(1);
}
char *policy = "default";
/* Run STREAM with a numa policy */
int main(int ac, char **av)
{
struct bitmask *nodes;
char *map;
long size;
int policy;
policy = parse_policy(av[1], av[2]);
nodes = numa_allocate_nodemask();
if (av[1] && av[2])
nodes = numa_parse_nodestring(av[2]);
if (!nodes) {
printf ("<%s> is invalid\n", av[2]);
exit(1);
}
size = stream_memsize();
map = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
0, 0);
if (map == (char*)-1) exit(1);
if (mbind(map, size, policy, nodes->maskp, nodes->size, 0) < 0)
perror("mbind"), exit(1);
stream_init(map);
stream_test(NULL);
return 0;
}