Ignore:
Timestamp:
06/08/18 15:59:53 (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

    r1525 r1527  
    99  int MPI_Comm_free(MPI_Comm *comm) 
    1010  { 
    11     if(! (*comm)->is_ep) 
    12     { 
    13       return MPI_Comm_free_mpi(comm); 
    14     } 
    15  
    16     else  
    17     { 
    18       if((*comm)->is_intercomm) 
    19         return MPI_Comm_free_intercomm(comm); 
    20       else 
    21         return MPI_Comm_free_intracomm(comm); 
    22     } 
     11    if(! (*comm)->is_ep) return MPI_Comm_free_mpi(comm); 
     12    else return MPI_Comm_free_endpoint(comm); 
    2313  } 
    2414 
     
    3323  } 
    3424 
    35   int MPI_Comm_free_intracomm(MPI_Comm *comm) 
     25  int MPI_Comm_free_endpoint(MPI_Comm *comm) 
    3626  { 
    3727    Debug("MPI_Comm_free with EP_intracomm\n"); 
     
    4030 
    4131    ep_rank_loc = (*comm)->ep_comm_ptr->size_rank_info[1].first; 
     32    int ep_rank = (*comm)->ep_comm_ptr->size_rank_info[0].first; 
    4233    num_ep = (*comm)->ep_comm_ptr->size_rank_info[1].second; 
    4334 
     
    4637    if(ep_rank_loc == 0) 
    4738    { 
     39 
     40      if((*comm)->is_intercomm) 
     41      { 
     42        for(int i=0; i<num_ep; i++) 
     43        { 
     44          (*comm)->ep_comm_ptr->comm_list[i]->inter_rank_map->clear(); 
     45#ifdef _showinfo 
     46          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); 
     47#endif 
     48          delete (*comm)->ep_comm_ptr->comm_list[i]->inter_rank_map; 
     49        } 
     50      } 
     51 
     52 
    4853 
    4954#ifdef _showinfo 
     
    103108 
    104109 
    105   int MPI_Comm_free2(MPI_Comm *comm) 
    106   { 
    107     Debug("MPI_Comm_free with EP_intracomm\n"); 
    108  
    109     int ep_rank_loc, num_ep; 
    110  
    111     ep_rank_loc = (*comm)->ep_comm_ptr->size_rank_info[1].first; 
    112     num_ep = (*comm)->ep_comm_ptr->size_rank_info[1].second; 
    113  
    114     MPI_Barrier2(*comm); 
    115  
    116     if(ep_rank_loc == 0) 
    117     { 
    118  
    119 #ifdef _showinfo 
    120       printf("delete (*comm)->my_buffer = %p\n", (*comm)->my_buffer); 
    121 #endif 
    122       delete (*comm)->my_buffer; 
    123  
    124  
    125        
    126 #ifdef _showinfo         
    127       printf("delete (*comm)->ep_barrier = %p\n", (*comm)->ep_barrier); 
    128 #endif 
    129       delete (*comm)->ep_barrier; 
    130        
    131  
    132  
    133       (*comm)->ep_rank_map->clear(); 
    134 #ifdef _showinfo 
    135       printf("delete (*comm)->ep_rank_map = %p\n", (*comm)->ep_rank_map); 
    136 #endif 
    137       delete (*comm)->ep_rank_map; 
    138        
    139  
    140       for(int i=0; i<num_ep; i++) 
    141       { 
    142         if((*comm)->is_intercomm) 
    143         { 
    144           (*comm)->ep_comm_ptr->comm_list[i]->inter_rank_map->clear(); 
    145 #ifdef _showinfo 
    146           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); 
    147 #endif 
    148           delete (*comm)->ep_comm_ptr->comm_list[i]->inter_rank_map; 
    149         } 
    150  
    151         (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue->clear(); 
    152 #ifdef _showinfo 
    153         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); 
    154 #endif 
    155         delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue; 
    156            
    157  
    158 #ifdef _showinfo 
    159         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); 
    160 #endif 
    161         delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr; 
    162  
    163  
    164 #ifdef _showinfo 
    165         printf("delete (*comm)->ep_comm_ptr->comm_list[%d] = %p\n", i, (*comm)->ep_comm_ptr->comm_list[i]); 
    166 #endif 
    167         delete (*comm)->ep_comm_ptr->comm_list[i]; 
    168       } 
    169  
    170 #ifdef _showinfo 
    171       printf("delete (*comm)->mpi_comm = %p\n", (*comm)->mpi_comm); 
    172 #endif 
    173       ::MPI_Comm_free(to_mpi_comm_ptr((*comm)->mpi_comm)); 
    174        
    175 #ifdef _showinfo 
    176       printf("delete (*comm)->ep_comm_ptr->comm_list = %p\n", (*comm)->ep_comm_ptr->comm_list); 
    177 #endif 
    178       delete[] (*comm)->ep_comm_ptr->comm_list; 
    179     } 
    180   } 
    181  
    182  
    183  
    184   int MPI_Comm_free_intercomm(MPI_Comm *comm) 
    185   { 
    186     int ep_rank; 
    187     MPI_Comm_rank(*comm, &ep_rank); 
    188     int ep_rank_loc = (*comm)->ep_comm_ptr->size_rank_info[1].first; 
    189     int num_ep =      (*comm)->ep_comm_ptr->size_rank_info[1].second; 
    190      
    191     int newcomm_ep_rank =(*comm)->ep_comm_ptr->intercomm->size_rank_info[0].first;  
    192     int newcomm_ep_rank_loc = (*comm)->ep_comm_ptr->intercomm->size_rank_info[1].first; 
    193     int newcomm_num_ep = (*comm)->ep_comm_ptr->intercomm->size_rank_info[1].second; 
    194  
    195     MPI_Barrier(*comm); 
    196  
    197     if(ep_rank_loc == 0) 
    198     { 
    199       (*comm)->ep_comm_ptr->intercomm->intercomm_rank_map->clear(); 
    200 #ifdef _showinfo 
    201       printf("delete (*comm)->ep_comm_ptr->intercomm->intercomm_rank_map = %p\n", (*comm)->ep_comm_ptr->intercomm->intercomm_rank_map); 
    202 #endif 
    203       delete (*comm)->ep_comm_ptr->intercomm->intercomm_rank_map; 
    204  
    205       (*comm)->ep_comm_ptr->intercomm->local_rank_map->clear(); 
    206 #ifdef _showinfo 
    207       printf("delete (*comm)->ep_comm_ptr->intercomm->local_rank_map = %p\n", (*comm)->ep_comm_ptr->intercomm->local_rank_map); 
    208 #endif 
    209       delete (*comm)->ep_comm_ptr->intercomm->local_rank_map; 
    210     } 
    211  
    212     if(newcomm_ep_rank_loc == 0) 
    213     { 
    214  
    215 #ifdef _showinfo 
    216       printf("delete (*comm)->my_buffer = %p\n", (*comm)->my_buffer); 
    217 #endif 
    218       delete (*comm)->my_buffer; 
    219  
    220  
    221        
    222 #ifdef _showinfo         
    223       printf("delete (*comm)->ep_barrier = %p\n", (*comm)->ep_barrier); 
    224 #endif 
    225       delete (*comm)->ep_barrier; 
    226        
    227  
    228       (*comm)->ep_rank_map->clear(); 
    229 #ifdef _showinfo 
    230       printf("delete (*comm)->ep_rank_map = %p\n", (*comm)->ep_rank_map); 
    231 #endif 
    232       delete (*comm)->ep_rank_map; 
    233        
    234 #ifdef _showinfo 
    235       printf("delete (*comm)->ep_comm_ptr->intercomm->mpi_inter_comm = %p\n", (*comm)->ep_comm_ptr->intercomm->mpi_inter_comm); 
    236 #endif 
    237       ::MPI_Comm_free(to_mpi_comm_ptr((*comm)->ep_comm_ptr->intercomm->mpi_inter_comm)); 
    238  
    239       for(int i=0; i<newcomm_num_ep; i++) 
    240       { 
    241         (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue->clear(); 
    242 #ifdef _showinfo 
    243         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); 
    244 #endif 
    245         delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->message_queue; 
    246  
    247 #ifdef _showinfo 
    248         printf("delete (*comm)->ep_comm_ptr->comm_list[%d]->ep_comm_ptr->intercomm = %p\n", i, (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->intercomm); 
    249 #endif 
    250         delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr->intercomm;         
    251            
    252  
    253 #ifdef _showinfo 
    254         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); 
    255 #endif 
    256         delete (*comm)->ep_comm_ptr->comm_list[i]->ep_comm_ptr; 
    257  
    258  
    259 #ifdef _showinfo 
    260         printf("delete (*comm)->ep_comm_ptr->comm_list[%d] = %p\n", i, (*comm)->ep_comm_ptr->comm_list[i]); 
    261 #endif 
    262         delete (*comm)->ep_comm_ptr->comm_list[i]; 
    263  
    264       } 
    265  
    266 #ifdef _showinfo 
    267       printf("delete (*comm)->mpi_comm = %p\n", (*comm)->mpi_comm); 
    268 #endif 
    269       ::MPI_Comm_free(to_mpi_comm_ptr((*comm)->mpi_comm)); 
    270        
    271 #ifdef _showinfo 
    272       printf("delete (*comm)->ep_comm_ptr->comm_list = %p\n", (*comm)->ep_comm_ptr->comm_list); 
    273 #endif 
    274       delete[] (*comm)->ep_comm_ptr->comm_list; 
    275     } 
    276   } 
    277  
    278  
    279110} 
    280111 
Note: See TracChangeset for help on using the changeset viewer.