Ignore:
Timestamp:
02/27/17 14:19:19 (7 years ago)
Author:
yushan
Message:

server mode OK for both multiple and one file mode. Tested with test_client

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_free.cpp

    r1053 r1063  
    1010  int MPI_Comm_free(MPI_Comm *comm) 
    1111  { 
    12     //if(comm == NULL) return 0; 
    13  
    14     MPI_Barrier(*comm); 
    15  
    1612 
    1713    if(! comm->is_ep) 
     
    2723    } 
    2824 
     25    else if(comm->is_intercomm) 
     26    { 
     27      return MPI_Comm_free_intercomm(comm); 
     28    } 
     29 
    2930    else 
    3031    { 
    31       if(comm->mpi_comm == MPI_COMM_NULL_STD ) return 0; 
     32      int ep_rank_loc, num_ep; 
    3233 
    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; 
    3734      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; 
    4035      num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 
    41       mpi_size = comm->ep_comm_ptr->size_rank_info[2].second; 
    4236 
    4337      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  
    5538 
    5639      if(ep_rank_loc == 0) 
     
    5841        Debug("comm is EP, mpi_comm_ptr != NULL\n"); 
    5942 
    60  
    61 /* 
    6243        if(comm->my_buffer != NULL) 
    6344        { 
     
    6950          if(comm->my_buffer->buf_char != NULL) delete[] comm->my_buffer->buf_char; Debug("buf_char freed\n"); 
    7051        } 
    71 */ 
     52 
    7253        if(comm->ep_barrier != NULL) 
    7354        { 
     
    7758 
    7859 
    79         if(comm->rank_map != NULL) 
     60        if( ! comm->rank_map->empty() ) 
    8061        { 
    8162          comm->rank_map->clear(); 
     
    8364        } 
    8465 
    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  
    9766        for(int i=0; i<num_ep; i++) 
    9867        { 
    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           
    10471 
    10572          if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) 
     
    11481          ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(comm->mpi_comm); 
    11582          ::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"); 
    11884        } 
    11985 
     
    12894  } 
    12995 
     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  } 
    130173 
    131174 
Note: See TracChangeset for help on using the changeset viewer.