Last active
March 8, 2019 17:21
-
-
Save DiKorsch/dc8c4283ac2bdae4322e to your computer and use it in GitHub Desktop.
libnuma example from a presentation for a NUMA seminar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <numa.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
if(numa_available() < 0){ | |
printf("System does not support NUMA API!\n"); | |
} | |
int n = numa_max_node(); | |
int size = 1024*1024; | |
printf("There are %d nodes on your system\n", n + 1); | |
void *mem = numa_alloc_onnode(size, n); | |
if(mem == NULL){ | |
printf("could not allocate memory on node %d!\n", n); | |
} | |
numa_free(mem, size); | |
if (numa_run_on_node(n) != 0) { | |
printf("could not assign current thread to node %d!\n", n); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you maybe give a full working example?