/* NUMA test for multicore processors * Tyler Simon * 7/4/2009 * Notes: * Dynamically selects number of cores * Modify MEM_MB for your per core memory size * * I recommend keeping ITER at 1, but if it makes you feel better increase * it, you should get the same BW either way. Check by running with ITER=1, * then ITER=5. * * Enable DEBUG to get per core process stats, I am lazy so execute with numa not ./numa if you can * * To Compile: c++ -o numa numa.C * To Run: numa * * Output: * [from core] [to core] [BW in MB/sec] * * You should get an output file _numa.txt for plotting */ #include #include #include #include #include #include #include #define MEM_MB 200 #define MEM_SIZE MEM_MB*1024L*1024L #define ITER 1 #define DEBUG 1 char execmd[255]; double getTime() { struct timeval tp; static double last_timestamp = 0.0; double timestamp; gettimeofday (&tp, 0); timestamp = (double) tp.tv_sec * 1e6 + tp.tv_usec; return timestamp; } int getNumCPU() { cpu_set_t mask; if (sched_getaffinity(0,sizeof(cpu_set_t),&mask)) { fprintf (stderr, "Unable to retrieve affinity\n"); exit(1); } int nproc = 0,i; for(i=0; i