Skip to content

Instantly share code, notes, and snippets.

@BloodyD BloodyD/libnuma-ex.c
Last active Mar 8, 2019

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Mar 8, 2019

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
You can’t perform that action at this time.