LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
detect_El_mpi.hpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2023, Lawrence Livermore National Security, LLC.
3 // Produced at the Lawrence Livermore National Laboratory.
4 // Written by the LBANN Research Team (B. Van Essen, et al.) listed in
5 // the CONTRIBUTORS file. <lbann-dev@llnl.gov>
6 //
7 // LLNL-CODE-697807.
8 // All rights reserved.
9 //
10 // This file is part of LBANN: Livermore Big Artificial Neural Network
11 // Toolkit. For details, see http://software.llnl.gov/LBANN or
12 // https://github.com/LLNL/LBANN.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "Licensee"); you
15 // may not use this file except in compliance with the License. You may
16 // obtain a copy of the License at:
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
23 // implied. See the License for the specific language governing
24 // permissions and limitations under the license.
25 //
26 // detect_El_mpi .hpp .cpp - detect the existence of the instantiations
27 // of the overloaded El::mpi wrappers for a data type
29 
30 #ifndef LBANN_DETECT_EL_MPI_HPP_INCLUDED
31 #define LBANN_DETECT_EL_MPI_HPP_INCLUDED
32 
33 #include "base.hpp"
34 #include <type_traits>
35 
36 namespace lbann {
37 
38 template <typename... Ts>
39 struct make_void
40 {
41  using type = void;
42 };
43 
45 template <typename... Ts>
46 using void_t = typename make_void<Ts...>::type;
47 
49 template <typename T, typename = void>
50 struct is_instantiated_El_mpi_type : std::false_type
51 {
52 };
53 
58 template <typename T>
60  T,
61  void_t<typename std::enable_if<
62  std::is_same<T, El::byte>::value || std::is_same<T, short>::value ||
63  std::is_same<T, int>::value || std::is_same<T, unsigned>::value ||
64  std::is_same<T, long int>::value || std::is_same<T, unsigned long>::value ||
65 #ifdef EL_HAVE_MPI_LONG_LONG
66  std::is_same<T, long long int>::value ||
67  std::is_same<T, unsigned long long>::value ||
68 #endif
69  std::is_same<T, float>::value || std::is_same<T, double>::value ||
70  std::is_same<T, El::Complex<float>>::value ||
71  std::is_same<T, El::Complex<double>>::value>::type>> : std::true_type
72 {
73 };
74 
81 template <bool B, class T = void>
83 {
84  using type = El::byte;
85 };
86 
88 template <class T>
90 {
91  using type = T;
92 };
93 
95 template <>
96 struct interpret_as_byte_if_needed<true, void>
97 {
98  using type = El::byte;
99 };
100 
101 } // namespace lbann
102 
103 #endif // LBANN_DETECT_EL_MPI_HPP_INCLUDED
typename make_void< Ts... >::type void_t
Alternative to c++17 std::void_t for older compilers.
By default, assume no instantiation for the type T in El::mpi.