tensorflow/core/common_runtime/collective_param_resolver_local.cc
// The first time a CollGroupParams is established for a group we compute a good
// rank order for all the devices in the group, that is appropriate for a ring
// algorithm.
The first time a CollGroupParams is established for a group we compute a good
rank order for all the devices in the group, that is appropriate for a ring
algorithm.
The first time a CollGroupParams is established for a group we compute a good rank order for all the devices in the group that is appropriate for a ring algorithm .
GlobalDeviceMap EstablishGlobalRank(const CollGroupParams& gp,
                                    const string& gpu_ring_order) {
  VLOG(1) << "EstablishGlobalRank";
  GlobalDeviceMap gdm = BuildDevRecs(gp);
  for (auto& iter : gdm) {
    TaskDeviceMap& tdm = iter.second;
    OrderTaskDeviceMap(gpu_ring_order, &tdm);
  }
  std::set<string> tasks;
  for (const CollGroupMember& member : gp.members) {
    tasks.insert(member.task);
  }
  int next_rank = 0;
  for (const string& task : tasks) {
    TaskDeviceMap* tdm = &gdm[task];
    for (auto& it : *tdm) {
      it.second.global_rank = it.second.local_rank + next_rank;
    }
    next_rank += tdm->size();
  }
  return gdm;
}
GlobalDeviceMap EstablishGlobalRank ( const CollGroupParams & gp , const string & gpu_ring_order ) { VLOG ( 1 ) << " " ; GlobalDeviceMap gdm = BuildDevRecs ( gp ) ; for ( auto & iter : gdm ) { TaskDeviceMap & tdm = iter . second ; OrderTaskDeviceMap ( gpu_ring_order , & tdm ) ; } std :: set < string > tasks ; for ( const CollGroupMember & member : gp . members ) { tasks . insert ( member . task ) ; } int next_rank = 0 ; for ( const string & task : tasks ) { TaskDeviceMap * tdm = & gdm [ task ] ; for ( auto & it : * tdm ) { it . second . global_rank = it . second . local_rank + next_rank ; } next_rank += tdm -> size ( ) ; } return gdm ; }
The first time a CollGroupParams is established for a group we compute a good
rank order for all the devices in the group, that is appropriate for a ring
algorithm.
The first time a CollGroupParams is established for a group we compute a good rank order for all the devices in the group that is appropriate for a ring algorithm .
// Connect the global rank order by the lexicographical order of the tasks.