27 #ifndef LBANN_UTILS_DISTCONV_HPP 28 #define LBANN_UTILS_DISTCONV_HPP 30 #include "lbann_config.hpp" 32 #ifdef LBANN_HAS_DISTCONV 39 #define DISTCONV_DEBUG 42 #include "distconv/distconv.hpp" 43 #include "distconv/dnn_backend/backend.hpp" 44 #include "distconv/tensor/algorithms.hpp" 45 #include "distconv/tensor/shuffle_mpi.hpp" 46 #include "distconv/tensor/shuffle_mpi_cuda.hpp" 47 #include "distconv/tensor/shuffle_mpi_cuda_al.hpp" 48 #include "distconv/tensor/tensor_mpi_cuda.hpp" 49 #include "distconv/util/util.hpp" 50 #ifdef DISTCONV_HAS_P2P 51 #include "distconv/tensor/shuffle_mpi_cuda_hybrid.hpp" 52 #include "distconv/tensor/shuffle_mpi_cuda_p2p.hpp" 53 #include "p2p/p2p.hpp" 54 #endif // DISTCONV_HAS_P2P 58 inline auto default_hydrogen_stream()
61 return hydrogen::cuda::GetDefaultStream();
63 return hydrogen::rocm::GetDefaultStream();
73 namespace tensor = ::distconv::tensor;
74 namespace util = ::distconv::util;
79 using IntVector = ::distconv::IntVector;
80 using IndexVector = ::distconv::IndexVector;
83 using Dist = ::distconv::tensor::Distribution;
87 using AbsTensor = ::distconv::tensor::AbstractTensor;
89 template <
typename TensorDataType>
90 using TensorHost = ::distconv::tensor::
91 Tensor<TensorDataType, LocaleMPI, ::distconv::tensor::BaseAllocator>;
93 template <
typename TensorDataType>
95 Tensor<TensorDataType, LocaleMPI, ::distconv::tensor::CUDAAllocator>;
97 template <
typename TensorDataType>
98 using TensorHostShuffler =
99 ::distconv::tensor::TensorMPIShuffler<TensorDataType,
100 ::distconv::tensor::BaseAllocator>;
102 template <
typename TensorDataType>
104 ::distconv::tensor::TensorMPICUDAShuffler<TensorDataType>;
105 template <
typename TensorDataType>
106 using TensorShufflerAL =
107 ::distconv::tensor::TensorMPICUDAShufflerAL<TensorDataType>;
108 #ifdef DISTCONV_HAS_P2P 109 template <
typename TensorDataType>
110 using TensorShufflerP2P =
111 ::distconv::tensor::TensorMPICUDAShufflerP2P<TensorDataType>;
112 template <
typename TensorDataType>
113 using TensorShufflerHybrid =
114 ::distconv::tensor::TensorMPICUDAShufflerHybrid<TensorDataType>;
115 #endif // DISTCONV_HAS_P2P 118 using MPIPrintStreamDebug = ::distconv::util::MPIPrintStreamDebug;
119 using MPIPrintStreamError = ::distconv::util::MPIPrintStreamError;
120 using MPIPrintStreamInfo = ::distconv::util::MPIPrintStreamInfo;
121 using MPIPrintStreamWarning = ::distconv::util::MPIPrintStreamWarning;
122 using MPIRootPrintStreamDebug = ::distconv::util::MPIRootPrintStreamDebug;
123 using MPIRootPrintStreamError = ::distconv::util::MPIRootPrintStreamError;
124 using MPIRootPrintStreamInfo = ::distconv::util::MPIRootPrintStreamInfo;
125 using MPIRootPrintStreamWaning = ::distconv::util::MPIRootPrintStreamWarning;
128 using Backend = ::distconv::BackendDNNLib;
129 using AlCommType =
typename decltype(std::declval<Backend>()
130 .get_al_mpi_cuda_comm())::element_type;
132 using ::distconv::get_channel_dim;
133 using ::distconv::get_sample_dim;
135 int get_strided_mpi_rank(MPI_Comm comm);
136 MPI_Comm get_strided_mpi_comm(MPI_Comm comm);
151 MPI_Comm get_mpi_comm();
159 int get_mpi_num_ranks();
167 int get_rank_stride();
171 bool evaluate_performance();
175 std::string get_convolution_fwd_algorithm();
179 std::string get_convolution_bwd_data_algorithm();
183 std::string get_convolution_bwd_filter_algorithm();
187 std::string get_synthetic_data_reader_randgen();
191 int get_number_of_pre_generated_synthetic_data();
195 bool is_deterministic();
199 int get_number_of_io_partitions();
203 bool is_cosmoflow_parallel_io_enabled();
205 #ifdef DISTCONV_HAS_P2P 209 #endif // DISTCONV_HAS_P2P 213 AlCommType& get_hosttransfer();
217 Backend& get_backend();
221 ::distconv::HaloExchangeMethod get_halo_exchange_method();
223 template <
typename TensorDataType>
224 TensorShuffler<TensorDataType>*
225 get_tensor_shuffler(
const TensorDev<TensorDataType>& src,
226 const TensorDev<TensorDataType>& dst);
228 MPI_Comm get_input_comm(
const lbann_comm& comm);
232 int get_input_rank(
const lbann_comm& comm);
236 Dist get_hydrogen_data_parallel_distribution(
int num_dims);
238 template <
typename Tensor>
239 void dump_tensor(
const Tensor& t,
const std::string& path)
241 dc::MPIPrintStreamDebug() <<
"Dumping tensor to " << path;
243 distconv::dump_tensor(t, path,
true);
246 size_t get_workspace_capacity();
248 int get_num_dims(
const Layer& layer);
249 int get_num_spatial_dims(
const Layer& layer);
251 #ifndef LBANN_UTILS_DISTCONV_INSTANTIATE 253 extern template TensorShuffler<T>* get_tensor_shuffler<T>( \ 254 const TensorDev<T>&, \ 255 const TensorDev<T>&); 257 #define LBANN_INSTANTIATE_CPU_HALF 258 #define LBANN_INSTANTIATE_GPU_HALF 261 #undef LBANN_INSTANTIATE_CPU_HALF 262 #undef LBANN_INSTANTIATE_GPU_HALF 263 #endif // LBANN_UTILS_DISTCONV_INSTANTIATE 268 #endif // LBANN_HAS_DISTCONV 269 #endif // LBANN_UTILS_DISTCONV_HPP ::distconv::tensor::LocaleMPI LocaleMPI
::distconv::tensor::Tensor< TensorDataType, LocaleMPI, ::distconv::tensor::CUDAAllocator > TensorDev
::distconv::tensor::TensorMPICUDAShuffler< TensorDataType > TensorShuffler
::distconv::tensor::Shape Shape
world_comm_ptr initialize(int &argc, char **&argv)
void finalize(lbann_comm *comm=nullptr)
::distconv::tensor::AbstractTensor AbsTensor
::distconv::tensor::Distribution Dist