The OMP_PROC_BIND=CLOSE approach works, except it will bind threads to 1
hardware thread only (when HT is present). For example, doing the following
to run 2 procs per node each with 4 threads, the thread affinity info
(queried through sched_getaffinity()) comes out as below.
mpirun -np 2 --map-by
Thank you, Ralph and Gilles.
I didn't know about the OMPI_COMM_WORLD_LOCAL_RANK variable. Essentially,
this means I should be able to wrap my application call in a shell script
and have mpirun invoke that. Then within the script I can query this
variable and set correct OMP env variable, correct?
Can't you simply
export OMP_PROC_BIND=1
assuming mpirun has the correct command line (e.g. correctly bind tasks
on x cores so the x OpenMP threads will be individually bound to each
core), each is bound to disjoint cpusets, so i guess GOMP will bind
OpenMP threads within the given cpuset.
Why don’t you have your application look at the OMPI_COMM_WORLD_LOCAL_RANK
envar, and then use that to calculate the offset location for your threads
(i.e., local rank 0 is on socket 0, local rank 1 is on socket 1, etc.). You can
then putenv the correct value of the GOMP envar
> On Jun 28, 201
Hi,
I am trying to do something like below with OpenMPI and OpenMP (threads).
[image: Inline image 1]
I was trying to use the explicit thread affinity with GOMP_CPU_AFFINITY
environment variable as described here (
https://gcc.gnu.org/onlinedocs/libgomp/GOMP_005fCPU_005fAFFINITY.html).
However,