Ignore:
Timestamp:
05/29/18 13:12:21 (6 years ago)
Author:
yushan
Message:

mpi_comm_split respect the norme of MPI: ranking according to the key argument. Key can be the same. In such case, the original ranking is used.

Location:
XIOS/dev/branch_openmp/extern/ep_dev
Files:
2 edited

Legend:

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

    r1504 r1506  
    131131    MPI_Allgather(&key, 1, MPI_INT, all_key.data(),1, MPI_INT, comm); 
    132132    MPI_Allgather_local(&key, 1, MPI_INT, all_key_loc.data(), comm); 
     133     
     134    vector<int> all_ep_rank(ep_size); 
     135    vector<int> all_ep_rank_loc(num_ep); 
     136     
     137    vector<int> colored_ep_rank[num_color]; 
     138    vector<int> colored_ep_rank_loc[num_color]; 
     139     
     140    MPI_Allgather(&ep_rank, 1, MPI_INT, all_ep_rank.data(),1, MPI_INT, comm); 
     141    MPI_Allgather_local(&ep_rank, 1, MPI_INT, all_ep_rank_loc.data(), comm); 
    133142 
    134143    for(int i=0; i<num_ep; i++) 
     
    139148        { 
    140149          colored_key_loc[j].push_back(all_key_loc[i]); 
     150          colored_ep_rank_loc[j].push_back(all_ep_rank_loc[i]); 
    141151        } 
    142152      } 
     
    150160        { 
    151161          colored_key[j].push_back(all_key[i]); 
    152         } 
    153       } 
    154     } 
     162          colored_ep_rank[j].push_back(all_ep_rank[i]); 
     163        } 
     164      } 
     165    } 
     166     
     167    int my_offset=0; 
     168    for(int i=0; i<colored_key[number_of_color].size(); i++) 
     169    { 
     170      if(key == colored_key[number_of_color][i]) 
     171      { 
     172        if(ep_rank != colored_ep_rank[number_of_color][i]) 
     173        { 
     174          my_offset++; 
     175        } 
     176        else 
     177          break; 
     178      } 
     179    } 
     180     
     181    int my_offset_loc=0; 
     182    for(int i=0; i<colored_key_loc[number_of_color].size(); i++) 
     183    { 
     184      if(key == colored_key_loc[number_of_color][i]) 
     185      { 
     186        if(ep_rank != colored_ep_rank_loc[number_of_color][i]) 
     187        { 
     188          my_offset_loc++; 
     189        } 
     190        else 
     191          break; 
     192      } 
     193    } 
     194     
     195     
    155196     
    156197    for(int i=0; i<num_color; i++) 
     
    166207      if(key == colored_key[number_of_color][i]) 
    167208      { 
    168         new_ep_rank = i; 
     209        new_ep_rank = i+my_offset; 
    169210        break; 
    170211      } 
     
    177218      if(key == colored_key_loc[number_of_color][i]) 
    178219      { 
    179         new_ep_rank_loc = i; 
     220        new_ep_rank_loc = i+my_offset_loc; 
    180221        break; 
    181222      } 
     
    272313      } 
    273314    } 
    274      
    275     /*for(int i=0; i<ep_size; i++) 
     315 
     316#ifdef _Memory_check    
     317    for(int i=0; i<ep_size; i++) 
    276318    { 
    277319      MPI_Barrier(comm); 
     
    288330      MPI_Barrier(comm); 
    289331      MPI_Barrier(comm); 
    290     }*/    
     332    }    
     333#endif 
    291334     
    292335    return 0; 
  • XIOS/dev/branch_openmp/extern/ep_dev/main.cpp

    r1504 r1506  
    686686    MPI_Comm_size(comm, &size); 
    687687 
    688     //int color = rank%2; 
    689     int tab_color[16]={2,2,2,3,0,1,1,3,2,1,3,0,0,2,0,0}; 
    690     int tab_key[16]={3,11,10,5,6,8,15,7,2,1,9,13,4,14,12,0}; 
     688    //int tab_color[16]={2,2,2,3,0,1,1,3,2,1,3,0,0,2,0,0};     // OK 
     689    //int tab_key[16]={3,11,10,5,6,8,15,7,2,1,9,13,4,14,12,0}; // OK  
     690     
     691 
     692    int tab_color[16]={2,2,1,1,1,1,0,1,1,1,0,1,1,1,2,0}; 
     693    //int tab_key[16]={3,11,12,4,6,15,10,5,2,8,14,7,13,9,1,0}; 
     694    int tab_key[16]={3,11,7,7,6,15,10,5,2,8,14,7,13,9,1,0}; 
     695     
    691696    int color = tab_color[rank]; 
    692697    int key = tab_key[rank]; 
     
    700705    MPI_Comm_rank(split_comm, &split_rank); 
    701706     
    702     printf("rank = %d, color = %d, key = %d, split_rank = %d\n", rank, color, key, split_rank); 
     707    printf("rank = %d, color = %d, key = %d, split_rank = %d, local_rank=%d\n", rank, color, key, split_rank, split_comm->ep_comm_ptr->size_rank_info[1].first); 
    703708 
    704709 
Note: See TracChangeset for help on using the changeset viewer.