On 9/12/2014 9:22 AM, JR Cary wrote:
On 9/12/14, 7:27 AM, Tim Prince wrote:
On 9/12/2014 6:14 AM, JR Cary wrote:
This must be a very old topic.
I would like to run mpi with one process per node, e.g., using
-cpus-per-rank=1. Then I want to use openmp inside of that.
But other times I will run with a rank on each physical core.
Inside my code I would like to detect which situation I am in.
Is there an openmpi api call to determine that?
omp_get_num_threads() should work. Unless you want to choose a
different non-parallel algorithm for this case, a single thread omp
parallel region works fine.
You should soon encounter cases where you want intermediate choices,
such as 1 rank per CPU package and 1 thread per core, even if you
stay away from platforms with more than 12 cores per CPU.
I may not understand, so I will try to ask in more detail.
Suppose I am running on a four-core processor (and my code likes one
thread per core).
In case 1 I do
mpiexec -np 2 myexec
and I want to know that each mpi process should use 2 threads.
If instead I did
mpiexec -np 4 myexec
I want to know that each mpi process should use one thread.
Will omp_get_num_threads() should return a different value for those
two cases?
Perhaps I am not invoking mpiexec correctly.
I use MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED,
&threadSupport), and regardless
of what how I invoke mpiexec (-n 1, -n 2, -n 4), I see 2 openmp processes
and 1 openmp threads (have not called omp_set_num_threads).
When I run serial, I see 8 openmp processes and 1 openmp threads.
So I must be missing an arg to mpiexec?
This is a 4-core haswell with hyperthreading to get 8.
Sorry, I assumed you were setting OMP_NUM_THREADS for your runs. If you
don't do that, each instance of OpenMP will try to run 8 threads, where
you probably want just 1 thread per core. I turn off hyperthreading in
BIOS on my machines, as I never run anything which would benefit from it.