#include "ep_lib.hpp" #include #include "ep_declaration.hpp" #include "ep_mpi.hpp" namespace ep_lib { int MPI_Comm_free(MPI_Comm *comm) { if(! (*comm)->is_ep) return MPI_Comm_free_mpi(comm); else return MPI_Comm_free_endpoint(comm); } int MPI_Comm_free_mpi(MPI_Comm *comm) { Debug("MPI_Comm_free with MPI\n"); return ::MPI_Comm_free(to_mpi_comm_ptr((*comm)->mpi_comm)); } int MPI_Comm_free_endpoint(MPI_Comm *comm) { Debug("MPI_Comm_free with EP_intracomm\n"); int ep_rank_loc, num_ep; ep_rank_loc = (*comm)->ep_comm_ptr->size_rank_info[1].first; num_ep = (*comm)->ep_comm_ptr->size_rank_info[1].second; MPI_Barrier_local(*comm); if(ep_rank_loc == 0) { if((*comm)->is_intercomm) { for(int i=0; iep_comm_ptr->comm_list[i]->inter_rank_map->clear(); #ifdef _showinfo 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); #endif delete (*comm)->ep_comm_ptr->comm_list[i]->inter_rank_map; } } #ifdef _showinfo printf("delete (*comm)->my_buffer = %p\n", (*comm)->my_buffer); #endif delete (*comm)->my_buffer; #ifdef _showinfo printf("delete (*comm)->ep_barrier = %p\n", (*comm)->ep_barrier); #endif delete (*comm)->ep_barrier; (*comm)->ep_rank_map->clear(); #ifdef _showinfo printf("delete (*comm)->ep_rank_map = %p\n", (*comm)->ep_rank_map); #endif delete (*comm)->ep_rank_map; for(int i=0; iep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue->clear(); #ifdef _showinfo 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); #endif delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue; #ifdef _showinfo 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); #endif delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr; #ifdef _showinfo printf("delete (*comm)->ep_comm_ptr->comm_list[%d] = %p\n", i, (*comm)->ep_comm_ptr->comm_list[i]); #endif delete (*comm)->ep_comm_ptr->comm_list[i]; } #ifdef _showinfo printf("delete (*comm)->mpi_comm = %p\n", (*comm)->mpi_comm); #endif ::MPI_Comm_free(to_mpi_comm_ptr((*comm)->mpi_comm)); #ifdef _showinfo printf("delete (*comm)->ep_comm_ptr->comm_list = %p\n", (*comm)->ep_comm_ptr->comm_list); #endif delete[] (*comm)->ep_comm_ptr->comm_list; } } }