Skip to content
Snippets Groups Projects
Commit ee213e37 authored by Andreas Herten's avatar Andreas Herten
Browse files

Add files for dual NUMA domain run

parent 08e7d8e2
Branches
No related tags found
No related merge requests found
CC:=mpicc
CFLAGS:=-fopenmp
.PHONY: all
all: omp_id
omp_id: omp_id.c
$(CC) $(CFLAGS) $< -o $@
omp_id.c 0 → 100644
#define _GNU_SOURCE // sched_getcpu(3) is glibc-specific (see the man page)
#include <stdio.h>
#include <mpi.h>
#include <sched.h>
#include <omp.h>
int main(int argc, char** argv) {
MPI_Init(NULL, NULL);
fprintf(stderr, "LEGEND: 'MPI' = MPI Rank; 'CPU' = CPU Core ID, 'MCPU' = Master CPU Core ID; 'OMP' = OpenMP Thread ID, 'MOMP' = Master OpenMP Thread ID; 'F' = Fork\n");
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
int thread_num_master = omp_get_thread_num();
int cpu_num_master = sched_getcpu();
printf("MPI\tF\tMOMP\tOMP\tMCPU\tCPU\n");
printf("%3d\t\t%4d\t%3d\t%4d\t%3d\n", world_rank, thread_num_master, thread_num_master, cpu_num_master ,cpu_num_master);
#pragma omp parallel
{
int thread_num = omp_get_thread_num();
int cpu_num = sched_getcpu();
printf("%3d\t\t%4d\t%3d\t%4d\t%3d\n", world_rank, thread_num_master, thread_num, cpu_num_master ,cpu_num);
}
MPI_Finalize();
return 0;
}
#!/usr/bin/env bash
## Get odd NUMA domain (which is always close to a GPU)
numa_domains=$(numactl -s | grep nodebind | sed "s/nodebind: //")
for domain in $numa_domains; do
if [ $((domain%2)) == 1 ]; then
odd_domain=$domain
fi
done
## GPU for odd NUMA domain
gpu_id=$(bash get_close_gpu.sh $odd_domain)
## Get cores of NUMA domain
numa_cores=$(numactl -s | grep physcpubind | sed "s/physcpubind: //")
numa_cores_array=($numa_cores) ## convert to array
## Split list of cores into single GPU-close core one the remaining ones
N_CORES_PER_DOMAIN=6 ## this can probably be retrieved from the systems somewhere^TM
core_gpu=${numa_cores_array[$N_CORES_PER_DOMAIN]} ## this implicitly assumes even NUMA domain before odd NUMA domain
core_rest=${numa_cores_array[@]/$core_gpu}
core_resorted=( $core_gpu $core_rest )
_OMP_PLACES=""
for i in "${core_resorted[@]}"
do
_OMP_PLACES+="{$i},"
done
if [[ -z "$OMP_PLACES" ]]; then
export OMP_PLACES=${_OMP_PLACES::-1} # removing trailing comma
else
echo "OMP_PLACES already set. Not touching it."
fi
#echo $OMP_PLACES
$1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment