|
1 | 1 | #include <torch/csrc/distributed/c10d/GlooDeviceFactory.hpp>
|
2 | 2 |
|
| 3 | +#include <torch/csrc/distributed/c10d/Utils.hpp> |
| 4 | + |
3 | 5 | #ifdef USE_C10D_GLOO
|
4 | 6 |
|
5 | 7 | #include <cstdlib>
|
|
19 | 21 | #include <gloo/transport/uv/device.h>
|
20 | 22 | #endif
|
21 | 23 |
|
| 24 | +#if GLOO_HAVE_TRANSPORT_IBVERBS |
| 25 | +#include <gloo/transport/ibverbs/device.h> |
| 26 | +#endif |
| 27 | + |
22 | 28 | // On Linux, check that the tcp transport is available.
|
23 | 29 | #ifdef __linux__
|
24 | 30 | #if !GLOO_HAVE_TRANSPORT_TCP
|
@@ -140,6 +146,45 @@ C10_REGISTER_CREATOR(GlooDeviceRegistry, WIN32, makeUVDevice)
|
140 | 146 | C10_REGISTER_CREATOR(GlooDeviceRegistry, UV, makeUVDevice)
|
141 | 147 | #endif
|
142 | 148 |
|
| 149 | +#if GLOO_HAVE_TRANSPORT_IBVERBS |
| 150 | +static std::shared_ptr<::gloo::transport::Device> makeIBVerbsDevice( |
| 151 | + const std::string& interface, |
| 152 | + const std::string& hostname, |
| 153 | + bool lazyInit) { |
| 154 | + TORCH_CHECK(hostname.empty(), "ibverbs transport does not support hostname"); |
| 155 | + |
| 156 | + TORCH_CHECK(!lazyInit, "transport does not support lazy init"); |
| 157 | + |
| 158 | + ::gloo::transport::ibverbs::attr attr; |
| 159 | + attr.name = getCvarString( |
| 160 | + { |
| 161 | + "TORCH_GLOO_IBV_NAME", |
| 162 | + }, |
| 163 | + ""); |
| 164 | + attr.port = getCvarInt( |
| 165 | + { |
| 166 | + "TORCH_GLOO_IBV_PORT", |
| 167 | + }, |
| 168 | + 1); |
| 169 | + attr.index = getCvarInt( |
| 170 | + { |
| 171 | + "TORCH_GLOO_IBV_INDEX", |
| 172 | + }, |
| 173 | + 0); |
| 174 | + |
| 175 | + if (!interface.empty()) { |
| 176 | + attr.name = interface; |
| 177 | + } |
| 178 | + |
| 179 | + // use global port |
| 180 | + attr.port = 1; |
| 181 | + |
| 182 | + return ::gloo::transport::ibverbs::CreateDevice(attr); |
| 183 | +} |
| 184 | + |
| 185 | +C10_REGISTER_CREATOR(GlooDeviceRegistry, IBVERBS, makeIBVerbsDevice) |
| 186 | +#endif |
| 187 | + |
143 | 188 | namespace {
|
144 | 189 | std::shared_ptr<::gloo::transport::Device> makeGlooDevice(
|
145 | 190 | const std::string& interfaceName,
|
|
0 commit comments