1 #include<libgeodecomp/config.h> 2 #ifdef LIBGEODECOMP_WITH_MPI 3 #ifndef LIBGEODECOMP_TYPEMAPS_H 4 #define LIBGEODECOMP_TYPEMAPS_H 5 6 #include <mpi.h> 7 #include <complex> 8 #include <libgeodecomp/geometry/coord.h> 9 #include <libgeodecomp/geometry/coord.h> 10 #include <libgeodecomp/geometry/coord.h> 11 #include <libgeodecomp/geometry/coordbox.h> 12 #include <libgeodecomp/geometry/coordbox.h> 13 #include <libgeodecomp/geometry/coordbox.h> 14 #include <libgeodecomp/geometry/coordbox.h> 15 #include <libgeodecomp/storage/fixedarray.h> 16 #include <libgeodecomp/geometry/floatcoord.h> 17 #include <libgeodecomp/geometry/floatcoord.h> 18 #include <libgeodecomp/geometry/floatcoord.h> 19 #include <libgeodecomp/geometry/floatcoord.h> 20 #include <libgeodecomp/geometry/streak.h> 21 #include <libgeodecomp/geometry/streak.h> 22 #include <libgeodecomp/geometry/streak.h> 23 #include <libgeodecomp/geometry/streak.h> 24 #include <libgeodecomp/misc/testcell.h> 25 #include <libgeodecomp/misc/testcell.h> 26 #include <libgeodecomp/misc/testcell.h> 27 #include <libgeodecomp/misc/testcell.h> 28 #include <libgeodecomp/misc/chronometer.h> 29 30 extern MPI_Datatype MPI_LIBGEODECOMP_COORD_1_; 31 extern MPI_Datatype MPI_LIBGEODECOMP_COORD_2_; 32 extern MPI_Datatype MPI_LIBGEODECOMP_COORD_3_; 33 extern MPI_Datatype MPI_LIBGEODECOMP_COORDBOX_1_; 34 extern MPI_Datatype MPI_LIBGEODECOMP_COORDBOX_2_; 35 extern MPI_Datatype MPI_LIBGEODECOMP_COORDBOX_3_; 36 extern MPI_Datatype MPI_LIBGEODECOMP_COORDBOXMPIDATATYPEHELPER; 37 extern MPI_Datatype MPI_LIBGEODECOMP_FIXEDARRAY_DOUBLE_CHRONOMETER_NUM_INTERVALS_; 38 extern MPI_Datatype MPI_LIBGEODECOMP_FLOATCOORD_1_; 39 extern MPI_Datatype MPI_LIBGEODECOMP_FLOATCOORD_2_; 40 extern MPI_Datatype MPI_LIBGEODECOMP_FLOATCOORD_3_; 41 extern MPI_Datatype MPI_LIBGEODECOMP_FLOATCOORDMPIDATATYPEHELPER; 42 extern MPI_Datatype MPI_LIBGEODECOMP_STREAK_1_; 43 extern MPI_Datatype MPI_LIBGEODECOMP_STREAK_2_; 44 extern MPI_Datatype MPI_LIBGEODECOMP_STREAK_3_; 45 extern MPI_Datatype MPI_LIBGEODECOMP_STREAKMPIDATATYPEHELPER; 46 extern MPI_Datatype MPI_LIBGEODECOMP_TESTCELL_1_; 47 extern MPI_Datatype MPI_LIBGEODECOMP_TESTCELL_2_; 48 extern MPI_Datatype MPI_LIBGEODECOMP_TESTCELL_3_; 49 extern MPI_Datatype MPI_LIBGEODECOMP_TESTCELLMPIDATATYPEHELPER; 50 extern MPI_Datatype MPI_LIBGEODECOMP_CHRONOMETER; 51 52 namespace LibGeoDecomp { 53 class Typemaps 54 { 55 public: 56 static void initializeMaps(); 57 58 template<typename T> lookup()59 static inline MPI_Datatype lookup() 60 { 61 return lookup((T*)0); 62 } 63 64 private: 65 template<typename T> getAddress(T * address)66 static MPI_Aint getAddress(T *address) 67 { 68 MPI_Aint ret; 69 MPI_Get_address(address, &ret); 70 return ret; 71 } 72 73 static MPI_Datatype generateMapLibGeoDecomp_Coord_1_(); 74 static MPI_Datatype generateMapLibGeoDecomp_Coord_2_(); 75 static MPI_Datatype generateMapLibGeoDecomp_Coord_3_(); 76 static MPI_Datatype generateMapLibGeoDecomp_CoordBox_1_(); 77 static MPI_Datatype generateMapLibGeoDecomp_CoordBox_2_(); 78 static MPI_Datatype generateMapLibGeoDecomp_CoordBox_3_(); 79 static MPI_Datatype generateMapLibGeoDecomp_CoordBoxMPIDatatypeHelper(); 80 static MPI_Datatype generateMapLibGeoDecomp_FixedArray_double_Chronometer_NUM_INTERVALS_(); 81 static MPI_Datatype generateMapLibGeoDecomp_FloatCoord_1_(); 82 static MPI_Datatype generateMapLibGeoDecomp_FloatCoord_2_(); 83 static MPI_Datatype generateMapLibGeoDecomp_FloatCoord_3_(); 84 static MPI_Datatype generateMapLibGeoDecomp_FloatCoordMPIDatatypeHelper(); 85 static MPI_Datatype generateMapLibGeoDecomp_Streak_1_(); 86 static MPI_Datatype generateMapLibGeoDecomp_Streak_2_(); 87 static MPI_Datatype generateMapLibGeoDecomp_Streak_3_(); 88 static MPI_Datatype generateMapLibGeoDecomp_StreakMPIDatatypeHelper(); 89 static MPI_Datatype generateMapLibGeoDecomp_TestCell_1_(); 90 static MPI_Datatype generateMapLibGeoDecomp_TestCell_2_(); 91 static MPI_Datatype generateMapLibGeoDecomp_TestCell_3_(); 92 static MPI_Datatype generateMapLibGeoDecomp_TestCellMPIDatatypeHelper(); 93 static MPI_Datatype generateMapLibGeoDecomp_Chronometer(); 94 95 public: lookup(bool *)96 static inline MPI_Datatype lookup(bool*) 97 { 98 return MPI_CHAR; 99 } 100 lookup(char *)101 static inline MPI_Datatype lookup(char*) 102 { 103 return MPI_CHAR; 104 } 105 lookup(double *)106 static inline MPI_Datatype lookup(double*) 107 { 108 return MPI_DOUBLE; 109 } 110 lookup(float *)111 static inline MPI_Datatype lookup(float*) 112 { 113 return MPI_FLOAT; 114 } 115 lookup(int *)116 static inline MPI_Datatype lookup(int*) 117 { 118 return MPI_INT; 119 } 120 lookup(long *)121 static inline MPI_Datatype lookup(long*) 122 { 123 return MPI_LONG; 124 } 125 lookup(long double *)126 static inline MPI_Datatype lookup(long double*) 127 { 128 return MPI_LONG_DOUBLE; 129 } 130 lookup(long long *)131 static inline MPI_Datatype lookup(long long*) 132 { 133 return MPI_LONG_LONG; 134 } 135 lookup(short *)136 static inline MPI_Datatype lookup(short*) 137 { 138 return MPI_SHORT; 139 } 140 lookup(signed char *)141 static inline MPI_Datatype lookup(signed char*) 142 { 143 return MPI_SIGNED_CHAR; 144 } 145 lookup(std::complex<double> *)146 static inline MPI_Datatype lookup(std::complex<double>*) 147 { 148 return MPI_DOUBLE_COMPLEX; 149 } 150 lookup(std::complex<float> *)151 static inline MPI_Datatype lookup(std::complex<float>*) 152 { 153 return MPI_COMPLEX; 154 } 155 lookup(unsigned *)156 static inline MPI_Datatype lookup(unsigned*) 157 { 158 return MPI_UNSIGNED; 159 } 160 lookup(unsigned char *)161 static inline MPI_Datatype lookup(unsigned char*) 162 { 163 return MPI_UNSIGNED_CHAR; 164 } 165 lookup(unsigned long *)166 static inline MPI_Datatype lookup(unsigned long*) 167 { 168 return MPI_UNSIGNED_LONG; 169 } 170 lookup(unsigned long long *)171 static inline MPI_Datatype lookup(unsigned long long*) 172 { 173 return MPI_UNSIGNED_LONG_LONG; 174 } 175 lookup(unsigned short *)176 static inline MPI_Datatype lookup(unsigned short*) 177 { 178 return MPI_UNSIGNED_SHORT; 179 } 180 lookup(wchar_t *)181 static inline MPI_Datatype lookup(wchar_t*) 182 { 183 return MPI_WCHAR; 184 } 185 lookup(LibGeoDecomp::Coord<1> *)186 static inline MPI_Datatype lookup(LibGeoDecomp::Coord<1 >*) 187 { 188 return MPI_LIBGEODECOMP_COORD_1_; 189 } 190 lookup(LibGeoDecomp::Coord<2> *)191 static inline MPI_Datatype lookup(LibGeoDecomp::Coord<2 >*) 192 { 193 return MPI_LIBGEODECOMP_COORD_2_; 194 } 195 lookup(LibGeoDecomp::Coord<3> *)196 static inline MPI_Datatype lookup(LibGeoDecomp::Coord<3 >*) 197 { 198 return MPI_LIBGEODECOMP_COORD_3_; 199 } 200 lookup(LibGeoDecomp::CoordBox<1> *)201 static inline MPI_Datatype lookup(LibGeoDecomp::CoordBox<1 >*) 202 { 203 return MPI_LIBGEODECOMP_COORDBOX_1_; 204 } 205 lookup(LibGeoDecomp::CoordBox<2> *)206 static inline MPI_Datatype lookup(LibGeoDecomp::CoordBox<2 >*) 207 { 208 return MPI_LIBGEODECOMP_COORDBOX_2_; 209 } 210 lookup(LibGeoDecomp::CoordBox<3> *)211 static inline MPI_Datatype lookup(LibGeoDecomp::CoordBox<3 >*) 212 { 213 return MPI_LIBGEODECOMP_COORDBOX_3_; 214 } 215 lookup(LibGeoDecomp::CoordBoxMPIDatatypeHelper *)216 static inline MPI_Datatype lookup(LibGeoDecomp::CoordBoxMPIDatatypeHelper*) 217 { 218 return MPI_LIBGEODECOMP_COORDBOXMPIDATATYPEHELPER; 219 } 220 lookup(LibGeoDecomp::FixedArray<double,Chronometer::NUM_INTERVALS> *)221 static inline MPI_Datatype lookup(LibGeoDecomp::FixedArray<double,Chronometer::NUM_INTERVALS >*) 222 { 223 return MPI_LIBGEODECOMP_FIXEDARRAY_DOUBLE_CHRONOMETER_NUM_INTERVALS_; 224 } 225 lookup(LibGeoDecomp::FloatCoord<1> *)226 static inline MPI_Datatype lookup(LibGeoDecomp::FloatCoord<1 >*) 227 { 228 return MPI_LIBGEODECOMP_FLOATCOORD_1_; 229 } 230 lookup(LibGeoDecomp::FloatCoord<2> *)231 static inline MPI_Datatype lookup(LibGeoDecomp::FloatCoord<2 >*) 232 { 233 return MPI_LIBGEODECOMP_FLOATCOORD_2_; 234 } 235 lookup(LibGeoDecomp::FloatCoord<3> *)236 static inline MPI_Datatype lookup(LibGeoDecomp::FloatCoord<3 >*) 237 { 238 return MPI_LIBGEODECOMP_FLOATCOORD_3_; 239 } 240 lookup(LibGeoDecomp::FloatCoordMPIDatatypeHelper *)241 static inline MPI_Datatype lookup(LibGeoDecomp::FloatCoordMPIDatatypeHelper*) 242 { 243 return MPI_LIBGEODECOMP_FLOATCOORDMPIDATATYPEHELPER; 244 } 245 lookup(LibGeoDecomp::Streak<1> *)246 static inline MPI_Datatype lookup(LibGeoDecomp::Streak<1 >*) 247 { 248 return MPI_LIBGEODECOMP_STREAK_1_; 249 } 250 lookup(LibGeoDecomp::Streak<2> *)251 static inline MPI_Datatype lookup(LibGeoDecomp::Streak<2 >*) 252 { 253 return MPI_LIBGEODECOMP_STREAK_2_; 254 } 255 lookup(LibGeoDecomp::Streak<3> *)256 static inline MPI_Datatype lookup(LibGeoDecomp::Streak<3 >*) 257 { 258 return MPI_LIBGEODECOMP_STREAK_3_; 259 } 260 lookup(LibGeoDecomp::StreakMPIDatatypeHelper *)261 static inline MPI_Datatype lookup(LibGeoDecomp::StreakMPIDatatypeHelper*) 262 { 263 return MPI_LIBGEODECOMP_STREAKMPIDATATYPEHELPER; 264 } 265 lookup(LibGeoDecomp::TestCell<1> *)266 static inline MPI_Datatype lookup(LibGeoDecomp::TestCell<1 >*) 267 { 268 return MPI_LIBGEODECOMP_TESTCELL_1_; 269 } 270 lookup(LibGeoDecomp::TestCell<2> *)271 static inline MPI_Datatype lookup(LibGeoDecomp::TestCell<2 >*) 272 { 273 return MPI_LIBGEODECOMP_TESTCELL_2_; 274 } 275 lookup(LibGeoDecomp::TestCell<3> *)276 static inline MPI_Datatype lookup(LibGeoDecomp::TestCell<3 >*) 277 { 278 return MPI_LIBGEODECOMP_TESTCELL_3_; 279 } 280 lookup(LibGeoDecomp::TestCellMPIDatatypeHelper *)281 static inline MPI_Datatype lookup(LibGeoDecomp::TestCellMPIDatatypeHelper*) 282 { 283 return MPI_LIBGEODECOMP_TESTCELLMPIDATATYPEHELPER; 284 } 285 lookup(LibGeoDecomp::Chronometer *)286 static inline MPI_Datatype lookup(LibGeoDecomp::Chronometer*) 287 { 288 return MPI_LIBGEODECOMP_CHRONOMETER; 289 } 290 291 }; 292 } 293 294 #endif 295 296 #endif 297