source: XIOS/dev/branch_openmp/extern/src_ep_dev/ep_barrier.cpp @ 1287

Last change on this file since 1287 was 1287, checked in by yushan, 7 years ago

EP updated

File size: 1.2 KB
Line 
1#include "ep_lib.hpp"
2#include <mpi.h>
3#include "ep_declaration.hpp"
4
5namespace ep_lib
6{
7
8  int MPI_Barrier(MPI_Comm comm)
9  {
10    if(comm.is_intercomm) return MPI_Barrier_intercomm(comm);
11
12    if(comm.is_ep)
13    {
14      int ep_rank_loc = comm.ep_comm_ptr->size_rank_info[1].first;
15
16      MPI_Barrier_local(comm);
17
18      if(ep_rank_loc == 0)
19      {
20        ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.mpi_comm);
21
22        ::MPI_Barrier(mpi_comm);
23      }
24
25      MPI_Barrier_local(comm);
26
27      return 0;
28    }
29    else if(comm.mpi_comm != static_cast< ::MPI_Comm>(MPI_COMM_NULL.mpi_comm))
30    {
31      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.mpi_comm);
32      ::MPI_Barrier(mpi_comm);
33      return 0;
34    }
35
36    else return 0;
37  }
38
39
40  int MPI_Barrier_intercomm(MPI_Comm comm)
41  {
42
43    int ep_rank_loc = comm.ep_comm_ptr->size_rank_info[1].first;
44
45    MPI_Barrier_local(comm);
46
47    if(ep_rank_loc == 0)
48    {
49      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.ep_comm_ptr->intercomm->mpi_inter_comm);
50      ::MPI_Barrier(mpi_comm);
51    }
52
53    MPI_Barrier_local(comm);
54
55    return 0;
56
57  }
58
59
60  int MPI_Barrier_local(MPI_Comm comm)
61  {
62    //Message_Check(comm);
63    comm.ep_barrier->wait();
64  }
65
66
67}
68
69
Note: See TracBrowser for help on using the repository browser.