Ignore:
Timestamp:
06/05/18 19:14:40 (3 years ago)
Author:
yushan
Message:

Test_client 6*8 clients 2 servers OK. TO DO : intercomm->intracomm, comm_free_intercomm

File:
1 edited

Legend:

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

    r1518 r1522  
    77 
    88 
    9 namespace ep_lib { 
     9namespace ep_lib  
     10{ 
    1011 
    1112  int MPI_Intercomm_merge_unique_leader(MPI_Comm inter_comm, bool high, MPI_Comm *newintracomm) 
     
    198199     
    199200    delete my_triple_list; 
    200   
    201  
    202     return 0; 
    203  
    204  
    205  
    206     Debug("intercomm_merge kernel\n"); 
    207  
    208     //int ep_rank_loc; 
    209     //int num_ep; 
    210  
    211     ep_rank_loc = inter_comm->ep_comm_ptr->size_rank_info[1].first; 
    212     num_ep = inter_comm->ep_comm_ptr->size_rank_info[1].second; 
    213  
    214  
    215  
    216     //int remote_ep_size = inter_comm->ep_comm_ptr->intercomm->remote_rank_map->size(); 
    217  
    218  
    219     MPI_Barrier(inter_comm); 
    220  
    221  
    222     ::MPI_Comm *mpi_intracomm = new ::MPI_Comm; 
    223     MPI_Comm *ep_intracomm; 
    224  
    225     if(ep_rank_loc == 0) 
    226     { 
    227  
    228       ::MPI_Comm mpi_comm = to_mpi_comm(inter_comm->ep_comm_ptr->intercomm->mpi_inter_comm); 
    229  
    230       ::MPI_Intercomm_merge(mpi_comm, high, mpi_intracomm); 
    231       MPI_Info info; 
    232       MPI_Comm_create_endpoints(mpi_intracomm, num_ep, info, ep_intracomm); 
    233  
    234       inter_comm->ep_comm_ptr->comm_list[0]->mem_bridge = ep_intracomm; 
    235  
    236     } 
    237  
    238     MPI_Barrier_local(inter_comm); 
    239  
    240     int inter_rank; 
    241     MPI_Comm_rank(inter_comm, &inter_rank); 
    242      
    243     int my_ep_rank = high? inter_rank+remote_ep_size : inter_rank; 
    244     int my_ep_rank_loc;// = inter_comm->ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].first; 
    245     int my_num_ep_loc;// = inter_comm->ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].second; 
    246     int my_num_ep_total = inter_comm->ep_comm_ptr->comm_list[0]->mem_bridge[0]->ep_comm_ptr->size_rank_info[1].second; 
    247     int my_ep_size = inter_comm->ep_comm_ptr->comm_list[0]->mem_bridge[0]->ep_comm_ptr->size_rank_info[0].second; 
    248  
    249     int tmp_intra_ep_rank_loc = high?my_ep_rank_loc+my_num_ep_total-my_num_ep_loc: my_ep_rank_loc; 
    250  
    251  
    252     *newintracomm = inter_comm->ep_comm_ptr->comm_list[0]->mem_bridge[tmp_intra_ep_rank_loc]; 
    253  
    254     int newintracomm_ep_rank = (*newintracomm)->ep_comm_ptr->size_rank_info[0].first; 
    255     int newintracomm_ep_rank_loc = (*newintracomm)->ep_comm_ptr->size_rank_info[1].first; 
    256     int newintracomm_mpi_rank = (*newintracomm)->ep_comm_ptr->size_rank_info[2].first; 
    257     int newintracomm_ep_size = (*newintracomm)->ep_comm_ptr->size_rank_info[0].second; 
    258     int newintracomm_num_ep = (*newintracomm)->ep_comm_ptr->size_rank_info[1].second; 
    259     int newintracomm_mpi_size = (*newintracomm)->ep_comm_ptr->size_rank_info[2].second; 
    260  
    261  
    262     int buf[3]; 
    263     buf[0] = my_ep_rank; 
    264     buf[1] = tmp_intra_ep_rank_loc; 
    265     buf[2] = (*newintracomm)->ep_comm_ptr->size_rank_info[2].first; 
    266  
    267     // printf("my_ep_rank = %d, tmp_intra_ep_rank_loc = %d, mpi_rank = %d\n", my_ep_rank, tmp_intra_ep_rank_loc, newintracomm->ep_comm_ptr->size_rank_info[2].first); 
    268  
    269     int *rankmap_buf; 
    270     rankmap_buf = new int [3*my_ep_size]; 
    271  
    272     MPI_Allgather(buf, 3, MPI_INT, rankmap_buf, 3, MPI_INT, *newintracomm); 
    273  
    274      
    275     // printf(" ID = %d : rankmap_buf = (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d)\n", newintracomm_ep_rank, 
    276     //                     rankmap_buf[0], rankmap_buf[1], rankmap_buf[2], rankmap_buf[3], rankmap_buf[4], rankmap_buf[5], rankmap_buf[6], rankmap_buf[7], rankmap_buf[8], rankmap_buf[9], 
    277     //                     rankmap_buf[10], rankmap_buf[11], rankmap_buf[12], rankmap_buf[13], rankmap_buf[14], rankmap_buf[15], rankmap_buf[16], rankmap_buf[17], rankmap_buf[18], rankmap_buf[19],  
    278     //                     rankmap_buf[20], rankmap_buf[21], rankmap_buf[22], rankmap_buf[23], rankmap_buf[24], rankmap_buf[25], rankmap_buf[26], rankmap_buf[27], rankmap_buf[28], rankmap_buf[29], 
    279     //                     rankmap_buf[30], rankmap_buf[31], rankmap_buf[32], rankmap_buf[33], rankmap_buf[34], rankmap_buf[35], rankmap_buf[36], rankmap_buf[37], rankmap_buf[38], rankmap_buf[39], 
    280     //                     rankmap_buf[40], rankmap_buf[41], rankmap_buf[42], rankmap_buf[43], rankmap_buf[44], rankmap_buf[45], rankmap_buf[46], rankmap_buf[47]); 
    281  
    282  
    283     for(int i=0; i<newintracomm_ep_size; i++) 
    284     { 
    285       (*newintracomm)->ep_rank_map->at(rankmap_buf[3*i]).first  = rankmap_buf[3*i+1]; 
    286       (*newintracomm)->ep_rank_map->at(rankmap_buf[3*i]).second = rankmap_buf[3*i+2]; 
    287     } 
    288  
    289  
    290     (*newintracomm)->ep_comm_ptr->size_rank_info[0].first = my_ep_rank; 
    291     (*newintracomm)->ep_comm_ptr->size_rank_info[1].first = tmp_intra_ep_rank_loc; 
    292      
    293  
    294     delete[] rankmap_buf; 
    295  
    296      
    297     return MPI_SUCCESS; 
    298  
    299201  } 
    300  
    301  
     202   
    302203} 
Note: See TracChangeset for help on using the changeset viewer.