Skip to content

Instantly share code, notes, and snippets.

@DiKorsch
Last active March 8, 2019 17:21
Show Gist options
  • Save DiKorsch/dc8c4283ac2bdae4322e to your computer and use it in GitHub Desktop.
Save DiKorsch/dc8c4283ac2bdae4322e to your computer and use it in GitHub Desktop.
libnuma example from a presentation for a NUMA seminar
#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;
}
@holzfelix
Copy link

can you maybe give a full working example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment