Jeff Hammond <[email protected]> writes:
N threads calling MPI_Barrier corresponds to N different, unrelated barriers. A thread calling MPI_Barrier will only synchronize with other processes, not any other threads.
MPI_Barrier only acts between processes. It has no effect on threads. Just use comm=MPI_COMM_SELF and think about the behavior of MPI_Barrier. That is the one-process limit of the multithreaded problem.
Antonio, the MPI Forum is considering proposals for something they are calling "endpoints", that would enable use of MPI between threads. If accepted, the new interfaces would provide a way to create communicators that could be used in the way you suggested. Until then, you have to synchronize threads using other mechanisms (locks, barriers, OpenMP, etc).