source: XIOS/dev/branch_yushan_merged/extern/src_ep_dev/ep_size.cpp @ 1134

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

branch merged with trunk r1130

File size: 1.4 KB
Line 
1#include "ep_lib.hpp"
2#include <mpi.h>
3#include "ep_declaration.hpp"
4
5namespace ep_lib
6{
7
8
9
10
11  int MPI_Comm_size(MPI_Comm comm, int* size)
12  {
13   
14    if(comm.is_ep)
15    {
16      if(!comm.is_intercomm)
17      {
18        *size = comm.ep_comm_ptr->size_rank_info[0].second;
19
20        return 0;
21      }
22      else
23      {
24        *size = comm.ep_comm_ptr->intercomm->size_rank_info[0].second;
25
26        return 0;
27      }
28
29    }
30
31    Debug("Calling EP_Comm_size\n");
32
33    if(comm.mpi_comm != MPI_COMM_NULL_STD)
34    {
35      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.mpi_comm); 
36      int mpi_size;
37
38      ::MPI_Comm_size(mpi_comm, &mpi_size);
39      printf("============ ep comm size called for non ep comm, %d\n", mpi_size);
40      *size = mpi_size;
41      return 0;
42    }
43
44    else
45    {
46      *size = MPI_UNDEFINED;
47      printf("============ ep comm size called for non ep comm not defined\n");
48      return 0;
49    }
50  }
51
52  int MPI_Comm_remote_size(MPI_Comm comm, int *size)
53  {
54    if(!comm.is_ep)
55    {
56      if(comm.mpi_comm != MPI_COMM_NULL_STD)
57      {
58        ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm > (comm.mpi_comm); 
59        ::MPI_Comm_remote_size(mpi_comm, size);
60        return 0;
61      }
62
63      else
64      {
65        *size = MPI_UNDEFINED;
66        return 0;
67      }
68    }
69   
70    if(comm.is_intercomm)
71    {
72      *size = comm.ep_comm_ptr->intercomm->remote_rank_map->size();
73      return 0;
74    }
75    *size = MPI_UNDEFINED;
76    return 0; 
77  }
78}
79
80
Note: See TracBrowser for help on using the repository browser.