What is _mp_p2 from the profiler?

Hi,

I am trying to use openMP to speedup a subroutine. I get two mp routines taking up considerable time:

_mp_p2 28% (81.66 seconds)
and
_mp_barrier 3% (9.33 seconds)

I am guessing the barrier is showing considerable time because I have a critical region, so I am guessing there are some threads that are waiting to execute the critical region and that time accumulates as _mp_barrier.

However, I do not know what _mp_p2 is. Usually a lot of time is spent in the routine grid, which is what I am using OMP on, but it seems that much of grid’s time has been transfered to this _mp_p2.

Hi Ben,

“_mp_p2” is a spin lock for critical sections. The 81 seconds is not wall clock time, rather the combined time of all threads spent spinning on a semaphore. One thing you can do is set the environment variable “MP_SPIN” to a small value, like 1. MP_SPIN defines the number of times the semaphore is checked before putting the thread to sleep. By setting it to a small value, the thread will enter a sleep state sooner and the “_mp_p2” routine shouldn’t show up in your profile.

  • Mat

Thanks Mat.

Though, I think in my case it is wallclock time, because for some reason the profiler thinks I only have a single-threaded program. (And the time only adds up correctly when it is counted as wallclock time.)