Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

mpi routines inside openmp parallel region

Richard_Gordon
Beginner
380 Views
Does anyone know if it is illegal to call mpi routines (specifically MPI_ALLGATHER) inside a openmp parallel region (for example PARALLEL DO)? The structure I'm trying to describe is like this:
[fortran]program main
  use mymod
  ...

  !$OMP PARALLEL DO ...
  call mysub(...)
  !$OMP END PARALLEL DO

end program

module mymod

contains
  subroutine mysub(...)
    use mpi
    ...    
    
    call MPI_ALLGATHER(...)

  end subroutine mysub

end module[/fortran]
Some code like the above gave a bug. Eventually I figured out if I commented the !$OMP pragmas that the error disappeared. (Btw, I thought using -openmp-stubs would cause the same behavior as commenting the pragmas, but that wasn't the case.)
The error by the way was weird: "assertion failed in ch3_progress.c". I thought it was a fault mpi installation (because of thishttp://lists.mcs.anl.gov/pipermail/mpich-discuss/2008-December/000195.html) on the cluster, but I tried mpich1 and mpich2 and both failed at the same point but worked before then.
By the way, the ifort version is old (10.1 20080312) but I'm not an admin on the cluster so there's little I can do about that. The MPI versions mpich-1.2.7p1 and mpich2-1.0.5p3. And I'm using linux.
Thanks.
0 Kudos
1 Reply
TimP
Honored Contributor III
380 Views
It's "illegal" to mix threading with MPI, unless you use MPI_Init_thread() to ask your MPI to support the type of threading you intend to use. It would hardly be "weird" to encounter an assertion failure when you mix threading with MPI in a way different from what you announced.
0 Kudos
Reply