Changeset 1063 for XIOS/dev/branch_yushan/extern/src_ep_dev/ep_free.cpp
- Timestamp:
- 02/27/17 14:19:19 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_yushan/extern/src_ep_dev/ep_free.cpp
r1053 r1063 10 10 int MPI_Comm_free(MPI_Comm *comm) 11 11 { 12 //if(comm == NULL) return 0;13 14 MPI_Barrier(*comm);15 16 12 17 13 if(! comm->is_ep) … … 27 23 } 28 24 25 else if(comm->is_intercomm) 26 { 27 return MPI_Comm_free_intercomm(comm); 28 } 29 29 30 else 30 31 { 31 i f(comm->mpi_comm == MPI_COMM_NULL_STD ) return 0;32 int ep_rank_loc, num_ep; 32 33 33 int ep_rank, ep_rank_loc, mpi_rank;34 int ep_size, num_ep, mpi_size;35 36 ep_rank = comm->ep_comm_ptr->size_rank_info[0].first;37 34 ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 38 mpi_rank = comm->ep_comm_ptr->size_rank_info[2].first;39 ep_size = comm->ep_comm_ptr->size_rank_info[0].second;40 35 num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 41 mpi_size = comm->ep_comm_ptr->size_rank_info[2].second;42 36 43 37 MPI_Barrier(*comm); 44 45 46 #pragma omp critical (memory_free)47 if(comm->is_intercomm && comm->ep_comm_ptr->intercomm != NULL)48 {49 if(comm->ep_comm_ptr->intercomm->local_rank_map) comm->ep_comm_ptr->intercomm->local_rank_map->clear();50 if(comm->ep_comm_ptr->intercomm->remote_rank_map) comm->ep_comm_ptr->intercomm->remote_rank_map->clear();51 if(comm->ep_comm_ptr->intercomm->intercomm_rank_map) comm->ep_comm_ptr->intercomm->intercomm_rank_map->clear();52 Debug("intercomm local/remote/intercomm_rank_map emptied\n");53 }54 55 38 56 39 if(ep_rank_loc == 0) … … 58 41 Debug("comm is EP, mpi_comm_ptr != NULL\n"); 59 42 60 61 /*62 43 if(comm->my_buffer != NULL) 63 44 { … … 69 50 if(comm->my_buffer->buf_char != NULL) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n"); 70 51 } 71 */ 52 72 53 if(comm->ep_barrier != NULL) 73 54 { … … 77 58 78 59 79 if( comm->rank_map != NULL)60 if( ! comm->rank_map->empty() ) 80 61 { 81 62 comm->rank_map->clear(); … … 83 64 } 84 65 85 86 if(comm->is_intercomm && comm->ep_comm_ptr->intercomm->mpi_inter_comm != MPI_COMM_NULL_STD)87 {88 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->ep_comm_ptr->intercomm->mpi_inter_comm);89 90 ::MPI_Comm_free(&mpi_comm);91 //comm->ep_comm_ptr->intercomm->mpi_inter_comm = NULL;92 Debug("mpi_intercomm freed\n");93 }94 95 96 97 66 for(int i=0; i<num_ep; i++) 98 67 { 99 if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue != NULL) 100 { 101 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 102 Debug("message queue freed\n"); 103 } 68 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 69 Debug("message queue freed\n"); 70 104 71 105 72 if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) … … 114 81 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm); 115 82 ::MPI_Comm_free(&mpi_comm); 116 //comm->mpi_comm = NULL; 117 // printf("label = %d, mpi_comm freed\n", comm->ep_comm_ptr->comm_label); 83 Debug("mpi_comm freed\n"); 118 84 } 119 85 … … 128 94 } 129 95 96 int MPI_Comm_free_intercomm(MPI_Comm *comm) 97 { 98 int ep_rank_loc, num_ep; 99 100 ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 101 num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 102 103 //MPI_Barrier(*comm); 104 105 if(ep_rank_loc == 0) 106 { 107 Debug("comm is EP, mpi_comm_ptr != NULL\n"); 108 109 if(comm->my_buffer != NULL) 110 { 111 if(comm->my_buffer->buf_int != NULL) delete[] comm->my_buffer->buf_int; Debug("buf_int freed\n"); 112 if(comm->my_buffer->buf_float != NULL) delete[] comm->my_buffer->buf_float; Debug("buf_float freed\n"); 113 if(comm->my_buffer->buf_double != NULL) delete[] comm->my_buffer->buf_double; Debug("buf_double freed\n"); 114 if(comm->my_buffer->buf_long != NULL) delete[] comm->my_buffer->buf_long; Debug("buf_long freed\n"); 115 if(comm->my_buffer->buf_ulong != NULL) delete[] comm->my_buffer->buf_ulong; Debug("buf_ulong freed\n"); 116 if(comm->my_buffer->buf_char != NULL) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n"); 117 } 118 119 if(comm->ep_barrier != NULL) 120 { 121 comm->ep_barrier->~OMPbarrier(); 122 Debug("ep_barrier freed\n"); 123 } 124 125 126 if( ! comm->rank_map->empty() ) 127 { 128 comm->rank_map->clear(); 129 Debug("rank_map emptied\n"); 130 } 131 132 for(int i=0; i<num_ep; i++) 133 { 134 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 135 Debug("message queue freed\n"); 136 137 #pragma omp critical (memory_free) 138 if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm != NULL) 139 { 140 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map->clear(); 141 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map->clear(); 142 comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map->clear(); 143 Debug("intercomm local/remote/intercomm_rank_map emptied\n"); 144 } 145 146 if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) 147 { 148 delete comm->ep_comm_ptr->comm_list[i].ep_comm_ptr; 149 Debug("ep_comm_ptr freed\n"); 150 } 151 } 152 153 if(comm->mpi_comm != MPI_COMM_NULL_STD) 154 { 155 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm); 156 ::MPI_Comm_free(&mpi_comm); 157 Debug("mpi_comm freed\n"); 158 } 159 160 // if(comm->ep_comm_ptr->intercomm->mpi_inter_comm != MPI_COMM_NULL_STD) 161 // { 162 // ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->ep_comm_ptr->comm_list->ep_comm_ptr->intercomm->mpi_inter_comm); 163 // ::MPI_Comm_free(&mpi_comm); 164 // Debug("mpi_intercomm freed\n"); 165 // } 166 167 if(comm != NULL) {delete[] comm->ep_comm_ptr->comm_list; Debug("comm freed\n");} 168 169 } 170 171 return 0; 172 } 130 173 131 174
Note: See TracChangeset
for help on using the changeset viewer.