Created
February 18, 2015 21:53
-
-
Save eerpini/b724820e5c3b02bfcc77 to your computer and use it in GitHub Desktop.
Get the memory at each node in a NUMA system.
This file contains hidden or 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> | |
#include <stdlib.h> | |
int main(int argc, char **argv){ | |
long free; | |
int num_cpus = 4; | |
long node_size = -1L; | |
int i; | |
if(numa_available() == -1){ | |
printf("ERROR : Numa not available on the system\n"); | |
return EXIT_FAILURE; | |
} | |
num_cpus = numa_num_configured_cpus(); | |
if(numa_num_configured_nodes() != num_cpus){ | |
printf("INFO : The number of thread nodes [%d] is different from the number of thread CPUs [%d]\n", | |
numa_num_configured_nodes(), | |
num_cpus); | |
} else { | |
printf("INFO : The number of thread nodes and thread CPUs is [%d]\n", | |
num_cpus); | |
} | |
for(i=0;i<num_cpus; i++){ | |
node_size = numa_node_size(i, &free); | |
printf("INFO : CPU [%d] : Memory Available [%ld] MB, Free Memory [%ld] MB\n", | |
i, node_size/(1024*1024), free/(1024*1024)); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment