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.

File:
1 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; 
Note: See TracChangeset for help on using the changeset viewer.