source: XIOS/dev/dev_trunk_omp/extern/src_ep_dev2/ep_free.cpp @ 2129

Last change on this file since 2129 was 1651, checked in by yushan, 5 years ago

dev on EP for tracing with itac. Tested on ADA with test_omp

File size: 2.7 KB
Line 
1#ifdef _usingEP
2#include "ep_lib.hpp"
3#include <mpi.h>
4#include "ep_declaration.hpp"
5#include "ep_mpi.hpp"
6
7namespace ep_lib
8{
9
10  int MPI_Comm_free(MPI_Comm *comm)
11  {
12    if(! (*comm)->is_ep) return MPI_Comm_free_mpi(comm);
13    else return MPI_Comm_free_endpoint(comm);
14  }
15
16
17
18  int MPI_Comm_free_mpi(MPI_Comm *comm)
19  {
20    Debug("MPI_Comm_free with MPI\n");
21    return ::MPI_Comm_free(to_mpi_comm_ptr((*comm)->mpi_comm));
22  }
23
24  int MPI_Comm_free_endpoint(MPI_Comm *comm)
25  {
26    Debug("MPI_Comm_free with EP_intracomm\n");
27
28    int ep_rank_loc, num_ep;
29
30    ep_rank_loc = (*comm)->ep_comm_ptr->size_rank_info[1].first;
31    num_ep = (*comm)->ep_comm_ptr->size_rank_info[1].second;
32
33    MPI_Barrier_local(*comm);
34
35    if(ep_rank_loc == 0)
36    {
37
38      if((*comm)->is_intercomm)
39      {
40        for(int i=0; i<num_ep; i++)
41        {
42          (*comm)->ep_comm_ptr->comm_list[i]->inter_rank_map->clear();
43#ifdef _showinfo
44          printf("delete (*comm)->ep_comm_ptr->comm_list[%d]->inter_rank_map = %p\n", i, (*comm)->ep_comm_ptr->comm_list[i]->inter_rank_map);
45#endif
46          delete (*comm)->ep_comm_ptr->comm_list[i]->inter_rank_map;
47        }
48      }
49
50
51
52#ifdef _showinfo
53      printf("delete (*comm)->my_buffer = %p\n", (*comm)->my_buffer);
54#endif
55      delete (*comm)->my_buffer;
56
57
58     
59#ifdef _showinfo       
60      printf("delete (*comm)->ep_barrier = %p\n", (*comm)->ep_barrier);
61#endif
62      delete (*comm)->ep_barrier;
63     
64
65
66      (*comm)->ep_rank_map->clear();
67#ifdef _showinfo
68      printf("delete (*comm)->ep_rank_map = %p\n", (*comm)->ep_rank_map);
69#endif
70      delete (*comm)->ep_rank_map;
71     
72
73      for(int i=0; i<num_ep; i++)
74      {
75        (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue->clear();
76#ifdef _showinfo
77        printf("delete (*comm)->ep_comm_ptr->comm_list[%d]->ep_comm_ptr->message_queue = %p\n", i, (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue);
78#endif
79        delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue;
80         
81
82#ifdef _showinfo
83        printf("delete (*comm)->ep_comm_ptr->comm_list[%d]->ep_comm_ptr = %p\n", i, (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr);
84#endif
85        delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr;
86
87
88#ifdef _showinfo
89        printf("delete (*comm)->ep_comm_ptr->comm_list[%d] = %p\n", i, (*comm)->ep_comm_ptr->comm_list[i]);
90#endif
91        delete (*comm)->ep_comm_ptr->comm_list[i];
92      }
93
94#ifdef _showinfo
95      printf("delete (*comm)->mpi_comm = %p\n", (*comm)->mpi_comm);
96#endif
97      ::MPI_Comm_free(to_mpi_comm_ptr((*comm)->mpi_comm));
98     
99#ifdef _showinfo
100      printf("delete (*comm)->ep_comm_ptr->comm_list = %p\n", (*comm)->ep_comm_ptr->comm_list);
101#endif
102      delete[] (*comm)->ep_comm_ptr->comm_list;
103    }
104  }
105
106
107
108}
109
110
111#endif
Note: See TracBrowser for help on using the repository browser.