| 60 | }; |
| 61 | |
| 62 | class DevicePair { |
| 63 | public: |
| 64 | DevicePair(int parent, int device) |
| 65 | : parent_(parent), |
| 66 | device_(device) { |
| 67 | } |
| 68 | inline int parent() { |
| 69 | return parent_; |
| 70 | } |
| 71 | inline int device() { |
| 72 | return device_; |
| 73 | } |
| 74 | |
| 75 | // Group GPUs in pairs, by proximity depending on machine's topology |
| 76 | static void compute(const vector<int> devices, vector<DevicePair>* pairs); |
| 77 | |
| 78 | protected: |
| 79 | int parent_; |
| 80 | int device_; |
| 81 | }; |
| 82 | |
| 83 | // Synchronous data parallelism using map-reduce between local GPUs. |
| 84 | template<typename Dtype> |