source: XIOS/dev/branch_openmp/extern/ep_dev/ep_barrier.cpp @ 1525

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

save dev : intercomm_create via intracomm. To do : modif related intercomm communication routines, barrier, free, rank, size...

File size: 1.4 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_Barrier2(MPI_Comm comm)
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 = to_mpi_comm(comm->mpi_comm);
50
51      ::MPI_Barrier(mpi_comm);
52    }
53
54    MPI_Barrier_local(comm);
55
56    return 0;
57  }
58
59  int MPI_Barrier_intercomm(MPI_Comm comm)
60  {
61    MPI_Barrier_local(comm);
62
63    if(comm->ep_comm_ptr->intercomm->size_rank_info[1].first == 0)
64      ::MPI_Barrier(to_mpi_comm(comm->ep_comm_ptr->intercomm->mpi_inter_comm));
65
66    MPI_Barrier_local(comm);
67  }
68
69  int MPI_Barrier_mpi(MPI_Comm comm)
70  {
71    return ::MPI_Barrier(to_mpi_comm(comm->mpi_comm));
72  }
73
74
75  int MPI_Barrier_local(MPI_Comm comm)
76  {
77    comm->ep_barrier->wait();
78  }
79
80
81}
82
83
Note: See TracBrowser for help on using the repository browser.