GlobalArrays/ga

Question about Thread safe with openmp

Closed this issue · 2 comments

jsboer commented

Hi, Does GA support mulithreads call?
I mean, in the following situations, can they all get right result?

  • in openmp parallel region, all threads call GA->get simultaneously
  • in openmp prarllel region, all threads will call GA->get, but one time only one thread can call GA->get.
  • in openmp parallel region, only one thread call GA->get, other threads will never call GA->get.

thank you!

Probably not, based on the last time I checked and the static arrays GA used. It's also likely that even if it's thread-safe, it uses coarse-grain locking to do so, and thus you're better off just using OpenMP critical or equivalent.

The problem with thread safety in Comm libs is that they have to do it unconditionally. If you do it, you don't apply any overhead unless you need it. That is, GA calls outside of threaded regions don't need any thread safety overhead.

jsboer commented

Probably not, based on the last time I checked and the static arrays GA used. It's also likely that even if it's thread-safe, it uses coarse-grain locking to do so, and thus you're better off just using OpenMP critical or equivalent.

The problem with thread safety in Comm libs is that they have to do it unconditionally. If you do it, you don't apply any overhead unless you need it. That is, GA calls outside of threaded regions don't need any thread safety overhead.

Ok, that's help, thank you!