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

Last change on this file since 1520 was 1520, checked in by yushan, 6 years ago

save dev. TO DO : test with xios

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