source: XIOS/dev/branch_openmp/extern/ep_dev/ep_size.cpp @ 1499

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

debugging for memory leaks

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