tensorflow/core/common_runtime/collective_param_resolver_local.cc
// NOTE(ayushd): The DeviceLocality objects in attributes will have LocalLinks
// to all devices that they are physically connected to and visible to the
// TensorFlow runtime.  This set of devices may be a superset of the devices
// participating in this instance of collectives.
The DeviceLocality objects in attributes will have LocalLinks
to all devices that they are physically connected to and visible to the
TensorFlow runtime.  This set of devices may be a superset of the devices
participating in this instance of collectives.
The DeviceLocality objects in attributes will have LocalLinks to all devices that they are physically connected to and visible to the TensorFlow runtime . This set of devices may be a superset of the devices participating in this instance of collectives .
void CollectiveParamResolverLocal::CompleteDefaultRanking(CollGroupParams* gp) {
  std::sort(gp->members.begin(), gp->members.end(),
            [](const CollGroupMember& lhs, const CollGroupMember& rhs) {
              return lhs.device.name() < rhs.device.name();
            });
  GlobalDeviceMap gdm = EstablishGlobalRank(*gp, gpu_ring_order_);
  std::vector<CollGroupMember> new_members(gp->group_size);
  for (const auto& git : gdm) {
    const TaskDeviceMap& tdm = git.second;
    for (const auto& tit : tdm) {
      const DevRec& dr = tit.second;
      new_members[dr.global_rank] = std::move(gp->members[dr.original_rank]);
    }
  }
  if (VLOG_IS_ON(2)) {
    string buf;
    for (const auto& m : new_members)
      strings::StrAppend(&buf, "\n", m.device.name());
    VLOG(2) << "Optimized device order for group " << gp->group_key << ": "
            << buf;
  }
  gp->members = std::move(new_members);
}
void CollectiveParamResolverLocal :: CompleteDefaultRanking ( CollGroupParams * gp ) { std :: sort ( gp -> members . begin ( ) , gp -> members . end ( ) , [ ] ( const CollGroupMember & lhs , const CollGroupMember & rhs ) { return lhs . device . name ( ) < rhs . device . name ( ) ; } ) ; GlobalDeviceMap gdm = EstablishGlobalRank ( * gp , gpu_ring_order_ ) ; std :: vector < CollGroupMember > new_members ( gp -> group_size ) ; for ( const auto & git : gdm ) { const TaskDeviceMap & tdm = git . second ; for ( const auto & tit : tdm ) { const DevRec & dr = tit . second ; new_members [ dr . global_rank ] = std :: move ( gp -> members [ dr . original_rank ] ) ; } } if ( VLOG_IS_ON ( 2 ) ) { string buf ; for ( const auto & m : new_members ) strings :: StrAppend ( & buf , " \n " , m . device . name ( ) ) ; VLOG ( 2 ) << " " << gp -> group_key << " " << buf ; } gp -> members = std :: move ( new_members ) ; }
NOTE(ayushd): The DeviceLocality objects in attributes will have LocalLinks
to all devices that they are physically connected to and visible to the
TensorFlow runtime.
NOTE ( ayushd ) : The DeviceLocality objects in attributes will have LocalLinks to all devices that they are physically connected to and visible to the TensorFlow runtime .
// Sort gp->member to avoid indeterminism. // Establish an instance-specific default rank order for devices // based on localities.  This rank order should be a good ring // order, if possible. // Reflect the new global ranking on shared