Ignore:
Timestamp:
05/28/18 09:54:32 (6 years ago)
Author:
yushan
Message:

save dev

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/ep_dev/ep_free.cpp

    r1499 r1500  
    99  int MPI_Comm_free(MPI_Comm *comm) 
    1010  { 
    11     if(! comm->is_ep) 
     11    if(! (*comm)->is_ep) 
    1212    { 
    13       if(comm->mpi_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm)) 
     13      if((*comm)->mpi_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL->mpi_comm)) 
    1414      { 
    15         ::MPI_Comm mpi_comm = to_mpi_comm(comm->mpi_comm); 
     15        ::MPI_Comm mpi_comm = to_mpi_comm((*comm)->mpi_comm); 
    1616 
    1717        ::MPI_Comm_free(&mpi_comm); 
     
    2121    } 
    2222 
    23     else if(comm->is_intercomm) 
     23    else if((*comm)->is_intercomm) 
    2424    { 
    2525      return MPI_Comm_free_intercomm(comm); 
     
    3030      int ep_rank_loc, num_ep; 
    3131 
    32       ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 
    33       num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 
     32      ep_rank_loc = (*comm)->ep_comm_ptr->size_rank_info[1].first; 
     33      num_ep = (*comm)->ep_comm_ptr->size_rank_info[1].second; 
    3434 
    3535      MPI_Barrier(*comm); 
     
    3939        Debug("comm is EP, mpi_comm_ptr != NULL\n"); 
    4040 
    41         delete comm->my_buffer; 
     41        delete (*comm)->my_buffer; 
    4242 
    4343 
    44         if(comm->ep_barrier != NULL) 
     44        if((*comm)->ep_barrier != NULL) 
    4545        { 
    46           comm->ep_barrier->~OMPbarrier(); 
     46          (*comm)->ep_barrier->~ep_barrier(); 
    4747          Debug("ep_barrier freed\n"); 
    4848        } 
    4949 
    5050 
    51         if( ! comm->rank_map->empty() ) 
     51        if( ! (*comm)->rank_map->empty() ) 
    5252        { 
    53           comm->rank_map->clear(); 
    54           delete comm->rank_map; 
     53          (*comm)->rank_map->clear(); 
     54          delete (*comm)->rank_map; 
    5555          Debug("rank_map emptied\n"); 
    5656        } 
     
    5858        for(int i=0; i<num_ep; i++) 
    5959        { 
    60           comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 
    61           delete comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue; 
     60          (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue->clear(); 
     61          delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue; 
    6262          Debug("message queue freed\n"); 
    6363           
    6464 
    65           if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) 
     65          if((*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr != NULL) 
    6666          { 
    67             delete comm->ep_comm_ptr->comm_list[i].ep_comm_ptr; 
     67            delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr; 
    6868            Debug("ep_comm_ptr freed\n"); 
    6969          } 
    7070        } 
    7171 
    72         if( to_mpi_comm(comm->mpi_comm) != *static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm)  
    73           && to_mpi_comm(comm->mpi_comm) != *static_cast< ::MPI_Comm*>(MPI_COMM_WORLD.mpi_comm)) 
     72        if( to_mpi_comm((*comm)->mpi_comm) != *static_cast< ::MPI_Comm*>(MPI_COMM_NULL->mpi_comm)  
     73          && to_mpi_comm((*comm)->mpi_comm) != *static_cast< ::MPI_Comm*>(MPI_COMM_WORLD->mpi_comm)) 
    7474        { 
    75           ::MPI_Comm mpi_comm = to_mpi_comm(comm->mpi_comm); 
     75          ::MPI_Comm mpi_comm = to_mpi_comm((*comm)->mpi_comm); 
    7676          ::MPI_Comm_free(&mpi_comm); 
    7777          Debug("mpi_comm freed\n"); 
    7878        } 
    7979 
    80        if(comm != NULL) {delete[] comm->ep_comm_ptr->comm_list; Debug("comm freed\n");} 
     80       //if(comm != NULL) {delete[] comm->ep_comm_ptr->comm_list; Debug("comm freed\n");} 
    8181 
    8282      } 
     
    9393    int ep_rank_loc, num_ep; 
    9494 
    95     ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 
    96     num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 
     95    ep_rank_loc = (*comm)->ep_comm_ptr->size_rank_info[1].first; 
     96    num_ep = (*comm)->ep_comm_ptr->size_rank_info[1].second; 
    9797 
    9898    //MPI_Barrier(*comm); 
     
    103103 
    104104 
    105       if(comm->ep_barrier != NULL) 
     105      if((*comm)->ep_barrier != NULL) 
    106106      { 
    107         comm->ep_barrier->~OMPbarrier(); 
     107        (*comm)->ep_barrier->~ep_barrier(); 
    108108        Debug("ep_barrier freed\n"); 
    109109      } 
    110110 
    111111 
    112       if( ! comm->rank_map->empty() ) 
     112      if( ! (*comm)->rank_map->empty() ) 
    113113      { 
    114         comm->rank_map->clear(); 
     114        (*comm)->rank_map->clear(); 
    115115        Debug("rank_map emptied\n"); 
    116116      } 
     
    118118      for(int i=0; i<num_ep; i++) 
    119119      { 
    120         comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->message_queue->clear(); 
     120        (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue->clear(); 
    121121        Debug("message queue freed\n"); 
    122122 
    123123        #pragma omp critical (memory_free) 
    124         if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm != NULL) 
     124        if((*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->intercomm != NULL) 
    125125        { 
    126           comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->local_rank_map->clear(); 
    127           comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->remote_rank_map->clear(); 
    128           comm->ep_comm_ptr->comm_list[i].ep_comm_ptr->intercomm->intercomm_rank_map->clear(); 
     126          (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->intercomm->local_rank_map->clear(); 
     127          (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->intercomm->remote_rank_map->clear(); 
     128          (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->intercomm->intercomm_rank_map->clear(); 
    129129          Debug("intercomm local/remote/intercomm_rank_map emptied\n"); 
    130130        }   
    131131 
    132         if(comm->ep_comm_ptr->comm_list[i].ep_comm_ptr != NULL) 
     132        if((*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr != NULL) 
    133133        { 
    134           delete comm->ep_comm_ptr->comm_list[i].ep_comm_ptr; 
     134          delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr; 
    135135          Debug("ep_comm_ptr freed\n"); 
    136136        } 
    137137      } 
    138138 
    139       if(comm->mpi_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm)) 
     139      if((*comm)->mpi_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL->mpi_comm)) 
    140140      { 
    141         ::MPI_Comm mpi_comm = to_mpi_comm(comm->mpi_comm); 
     141        ::MPI_Comm mpi_comm = to_mpi_comm((*comm)->mpi_comm); 
    142142        ::MPI_Comm_free(&mpi_comm); 
    143143        Debug("mpi_comm freed\n"); 
    144144      } 
    145145 
    146       if(comm->ep_comm_ptr->intercomm->mpi_inter_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL.mpi_comm)) 
     146      if((*comm)->ep_comm_ptr->intercomm->mpi_inter_comm != static_cast< ::MPI_Comm*>(MPI_COMM_NULL->mpi_comm)) 
    147147      { 
    148         ::MPI_Comm mpi_comm = to_mpi_comm(comm->ep_comm_ptr->comm_list->ep_comm_ptr->intercomm->mpi_inter_comm); 
     148        ::MPI_Comm mpi_comm = to_mpi_comm((*comm)->ep_comm_ptr->comm_list[0]->ep_comm_ptr->intercomm->mpi_inter_comm); 
    149149        ::MPI_Comm_free(&mpi_comm); 
    150150        Debug("mpi_intercomm freed\n"); 
    151151      } 
    152152 
    153      if(comm != NULL) {delete[] comm->ep_comm_ptr->comm_list; Debug("comm freed\n");} 
     153     if(comm != NULL) {delete[] (*comm)->ep_comm_ptr->comm_list; Debug("comm freed\n");} 
    154154 
    155155    } 
Note: See TracChangeset for help on using the changeset viewer.