Skip to content

Commit

Permalink
Remove allreduce namespace from bcube implementation
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebookincubator#141

Reviewed By: teng-li

Differential Revision: D10362257

Pulled By: pietern

fbshipit-source-id: 6a8cdb6e0c29f847d253d3180300e4274025245c
  • Loading branch information
pietern authored and facebook-github-bot committed Oct 13, 2018
1 parent 612f0f2 commit a94e6bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
12 changes: 5 additions & 7 deletions gloo/allreduce_bcube.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
*/
namespace gloo {

namespace allreduce {
namespace bcube {

/**
Expand Down Expand Up @@ -241,7 +240,6 @@ class Group {
};

} // namespace bcube
} // namespace allreduce

/**
* This is another implemenation of allreduce algorithm where-in we divide
Expand Down Expand Up @@ -508,7 +506,7 @@ class AllreduceBcube : public Algorithm {
/**
* List of all the nodes
*/
std::vector<allreduce::bcube::Node> allNodes_;
std::vector<bcube::Node> allNodes_;
/**
* Compute number of steps required in reduce-scatter and all-gather (each)
* @param nodes The total number of nodes
Expand Down Expand Up @@ -633,7 +631,7 @@ class AllreduceBcube : public Algorithm {
* @param step The step for which we are updating the values
* @param groups The group object with all peer, count and offset data
*/
void updateGroupNodes(int step, const allreduce::bcube::Group& group) {
void updateGroupNodes(int step, const bcube::Group& group) {
const std::vector<int>& peers = group.getNodeRanks();
const int peersSz = peers.size();
int ptrOffset = group.getPtrOffset();
Expand All @@ -643,7 +641,7 @@ class AllreduceBcube : public Algorithm {
count = 1;
}
for (int i = 0; i < peersSz; ++i) {
allreduce::bcube::Node& node = allNodes_[peers[i]];
bcube::Node& node = allNodes_[peers[i]];
if (peersSz - 1 != i) { // if not the last node in group
node.setPerStepAttributes(step, peers, count, ptrOffset);
ptrOffset += count;
Expand Down Expand Up @@ -672,10 +670,10 @@ class AllreduceBcube : public Algorithm {
// Now we actually try to set up the nodes
int peerDistance = 1;
for (int step = 0; step < steps_; ++step) {
std::vector<allreduce::bcube::Group> groups;
std::vector<bcube::Group> groups;
// Iterate over all the nodes to identify the first node of each group
for (int rank = 0; rank < nodes_; ++rank) {
const allreduce::bcube::Node& firstNode = allNodes_[rank];
const bcube::Node& firstNode = allNodes_[rank];
// Only the ones with no peers would be first node
if (0 == firstNode.getPeersPerStep(step).size()) {
// Create a new group
Expand Down
10 changes: 4 additions & 6 deletions gloo/cuda_allreduce_bcube.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void CudaAllreduceBcube<T, W>::createNodes() {
template <typename T, typename W>
void CudaAllreduceBcube<T, W>::updateGroupNodes(
int step,
const cuda::allreduce::bcube::Group& group) {
const cuda::bcube::Group& group) {
const std::vector<int>& peers = group.getNodeRanks();
const int peersSz = peers.size();
int ptrOffset = group.getPtrOffset();
Expand All @@ -311,7 +311,7 @@ void CudaAllreduceBcube<T, W>::updateGroupNodes(
count = 1;
}
for (int i = 0; i < peersSz; ++i) {
cuda::allreduce::bcube::Node& node = allNodes_[peers[i]];
cuda::bcube::Node& node = allNodes_[peers[i]];
if (peersSz - 1 != i) { // if not the last node in group
node.setPerStepAttributes(step, peers, count, ptrOffset);
ptrOffset += count;
Expand All @@ -335,10 +335,10 @@ void CudaAllreduceBcube<T, W>::setupNodes() {
// Now we actually try to set up the nodes
int peerDistance = 1;
for (int step = 0; step < steps_; ++step) {
std::vector<cuda::allreduce::bcube::Group> groups;
std::vector<cuda::bcube::Group> groups;
// Iterate over all the nodes to identify the first node of each group
for (int rank = 0; rank < nodes_; ++rank) {
const cuda::allreduce::bcube::Node& firstNode = allNodes_[rank];
const cuda::bcube::Node& firstNode = allNodes_[rank];
// Only the ones with no peers would be first node
if (0 == firstNode.getPeersPerStep(step).size()) {
// Create a new group
Expand Down Expand Up @@ -409,7 +409,6 @@ void CudaAllreduceBcube<T, W>::init(
}

namespace cuda {
namespace allreduce {
namespace bcube {

Node::Node(int rank, int steps) : rank_(rank) {
Expand Down Expand Up @@ -499,7 +498,6 @@ std::vector<int> Group::getNodeRanks(
}

} // namespace bcube
} // namespace allreduce
} // namespace cuda

#define INSTANTIATE_TEMPLATE(T) \
Expand Down
8 changes: 2 additions & 6 deletions gloo/cuda_allreduce_bcube.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
namespace gloo {

namespace cuda {
namespace allreduce {
namespace bcube {

class Node;
class Group;

} // namespace bcube
} // namespace allreduce
} // namespace cuda

/**
Expand Down Expand Up @@ -161,7 +159,7 @@ class CudaAllreduceBcube : public Algorithm {
/**
* List of all the nodes
*/
std::vector<cuda::allreduce::bcube::Node> allNodes_;
std::vector<cuda::bcube::Node> allNodes_;

/**
* Compute number of steps required in reduce-scatter and all-gather (each)
Expand Down Expand Up @@ -240,7 +238,7 @@ class CudaAllreduceBcube : public Algorithm {
* @param step The step for which we are updating the values
* @param groups The group object with all peer, count and offset data
*/
void updateGroupNodes(int step, const cuda::allreduce::bcube::Group& group);
void updateGroupNodes(int step, const cuda::bcube::Group& group);
/**
* Setup all the nodes
* Here are the things we do in this function
Expand All @@ -264,7 +262,6 @@ class CudaAllreduceBcube : public Algorithm {
};

namespace cuda {
namespace allreduce {
namespace bcube {

/**
Expand Down Expand Up @@ -406,7 +403,6 @@ class Group {
};

} // namespace bcube
} // namespace allreduce
} // namespace cuda

} // namespace gloo

0 comments on commit a94e6bf

Please sign in to comment.