11 #define GHOST_ALLREDUCE -1
22 #define MPI_COMM_NULL 0
23 #define MPI_COMM_SELF 1
25 #define MPI_DATATYPE_NULL 0
26 #define MPI_COMM_WORLD 0
34 #include <sys/types.h>
40 #define SELECT_TMPL_2DATATYPES(dt1,dt2,complexclass,ret,func,...)\
41 if (dt1 & GHOST_DT_COMPLEX) {\
42 if (dt1 & GHOST_DT_DOUBLE) {\
43 if (dt2 & GHOST_DT_COMPLEX) {\
44 if (dt2 & GHOST_DT_DOUBLE) {\
45 ret = func<complexclass<double>,complexclass<double> >(__VA_ARGS__);\
47 ret = func<complexclass<double>,complexclass<float> >(__VA_ARGS__);\
50 if (dt2 & GHOST_DT_DOUBLE) {\
51 ret = func<complexclass<double>,double>(__VA_ARGS__);\
53 GHOST_WARNING_LOG("Incompatible data types!");\
57 if (dt2 & GHOST_DT_COMPLEX) {\
58 if (dt2 & GHOST_DT_DOUBLE) {\
59 ret = func<complexclass<float>,complexclass<double> >(__VA_ARGS__);\
61 ret = func<complexclass<float>,complexclass<float> >(__VA_ARGS__);\
64 if (dt2 & GHOST_DT_DOUBLE) {\
65 GHOST_WARNING_LOG("Incompatible data types!");\
67 ret = func<complexclass<float>,float>(__VA_ARGS__);\
72 if (dt1 & GHOST_DT_DOUBLE) {\
73 if (dt2 & GHOST_DT_COMPLEX) {\
74 if (dt2 & GHOST_DT_DOUBLE) {\
75 ret = func<double,complexclass<double> >(__VA_ARGS__);\
77 GHOST_WARNING_LOG("Incompatible data types!");\
80 if (dt2 & GHOST_DT_DOUBLE) {\
81 ret = func<double,double>(__VA_ARGS__);\
83 ret = func<double,float>(__VA_ARGS__);\
87 if (dt2 & GHOST_DT_COMPLEX) {\
88 if (dt2 & GHOST_DT_DOUBLE) {\
89 GHOST_WARNING_LOG("Incompatible data types!");\
91 ret = func<float,complexclass<float> >(__VA_ARGS__);\
94 if (dt2 & GHOST_DT_DOUBLE) {\
95 ret = func<float,double>(__VA_ARGS__);\
97 ret = func<float,float>(__VA_ARGS__);\
107 #define SELECT_TMPL_2DATATYPES_base_derived(dt1,dt2,complexclass,ret,func,...)\
108 if (dt1 & GHOST_DT_COMPLEX) {\
109 if (dt1 & GHOST_DT_DOUBLE) {\
110 if (dt2 & GHOST_DT_COMPLEX) {\
111 if (dt2 & GHOST_DT_DOUBLE) {\
112 ret = func<complexclass<double>,complexclass<double> >(__VA_ARGS__);\
117 ret = GHOST_ERR_DATATYPE; \
120 if (dt2 & GHOST_DT_COMPLEX) {\
121 if (dt2 & GHOST_DT_DOUBLE) {\
124 ret = func<complexclass<float>,complexclass<float> >(__VA_ARGS__);\
127 ret = GHOST_ERR_DATATYPE; \
131 if (dt1 & GHOST_DT_DOUBLE) {\
132 if (dt2 & GHOST_DT_COMPLEX) {\
133 if (dt2 & GHOST_DT_DOUBLE) {\
134 ret = func<double,complexclass<double> >(__VA_ARGS__);\
139 if (dt2 & GHOST_DT_DOUBLE) {\
140 ret = func<double,double>(__VA_ARGS__);\
146 if (dt2 & GHOST_DT_COMPLEX) {\
147 if (dt2 & GHOST_DT_DOUBLE) {\
150 ret = func<float,complexclass<float> >(__VA_ARGS__);\
153 if (dt2 & GHOST_DT_DOUBLE) {\
156 ret = func<float,float>(__VA_ARGS__);\
165 #define SELECT_TMPL_4DATATYPES(dt1,dt2,complexclass,ret,func,...)\
166 if (dt1 & GHOST_DT_COMPLEX) {\
167 if (dt1 & GHOST_DT_DOUBLE) {\
168 if (dt2 & GHOST_DT_COMPLEX) {\
169 if (dt2 & GHOST_DT_DOUBLE) {\
170 ret = func<cuDoubleComplex,complexclass<double>,cuDoubleComplex,double>(__VA_ARGS__);\
172 ret = func<cuDoubleComplex,complexclass<float>,cuFloatComplex,float>(__VA_ARGS__);\
175 if (dt2 & GHOST_DT_DOUBLE) {\
176 ret = func<cuDoubleComplex,double,double,double>(__VA_ARGS__);\
178 ret = func<cuDoubleComplex,float,float,float>(__VA_ARGS__);\
182 if (dt2 & GHOST_DT_COMPLEX) {\
183 if (dt2 & GHOST_DT_DOUBLE) {\
184 ret = func<cuFloatComplex,complexclass<double>,cuDoubleComplex,double>(__VA_ARGS__);\
186 ret = func<cuFloatComplex,complexclass<float>,cuFloatComplex,float>(__VA_ARGS__);\
189 if (dt2 & GHOST_DT_DOUBLE) {\
190 ret = func<cuFloatComplex,double,double,double>(__VA_ARGS__);\
192 ret = func<cuFloatComplex,float,float,float>(__VA_ARGS__);\
197 if (dt1 & GHOST_DT_DOUBLE) {\
198 if (dt2 & GHOST_DT_COMPLEX) {\
199 if (dt2 & GHOST_DT_DOUBLE) {\
200 ret = func<double,complexclass<double>,cuDoubleComplex,double>(__VA_ARGS__);\
202 ret = func<double,complexclass<float>,cuFloatComplex,float>(__VA_ARGS__);\
205 if (dt2 & GHOST_DT_DOUBLE) {\
206 ret = func<double,double,double,double>(__VA_ARGS__);\
208 ret = func<double,float,float,float>(__VA_ARGS__);\
212 if (dt2 & GHOST_DT_COMPLEX) {\
213 if (dt2 & GHOST_DT_DOUBLE) {\
214 ret = func<float,complexclass<double>,cuDoubleComplex,double>(__VA_ARGS__);\
216 ret = func<float,complexclass<float>,cuFloatComplex,float>(__VA_ARGS__);\
219 if (dt2 & GHOST_DT_DOUBLE) {\
220 ret = func<float,double,double,double>(__VA_ARGS__);\
222 ret = func<float,float,float,float>(__VA_ARGS__);\
228 #define SELECT_TMPL_1DATATYPE(dt,complexclass,ret,func,...)\
229 if (dt & GHOST_DT_COMPLEX) {\
230 if (dt & GHOST_DT_DOUBLE) {\
231 ret = func<complexclass<double> >(__VA_ARGS__);\
233 ret = func<complexclass<float> >(__VA_ARGS__);\
236 if (dt & GHOST_DT_DOUBLE) {\
237 ret = func<double>(__VA_ARGS__);\
239 ret = func<float>(__VA_ARGS__);\
267 #define GHOST_DT_ANY (ghost_datatype)-1
268 #define GHOST_DT_NONE (ghost_datatype)0
287 #define GHOST_HOST_IDX 0
288 #define GHOST_DEVICE_IDX 1
293 return static_cast<ghost_location>(
static_cast<int>(a) & static_cast<int>(b));
296 return static_cast<ghost_location>(
static_cast<int>(a) | static_cast<int>(b));
299 a =
static_cast<ghost_location>(
static_cast<int>(a) & static_cast<int>(b));
303 a =
static_cast<ghost_location>(
static_cast<int>(a) | static_cast<int>(b));
360 #define GHOST_DT_MAX_SIZE 16
371 #define GHOST_REGISTER_DT_D(name) \
372 typedef double name ## _t; \
373 ghost_datatype name = (ghost_datatype)(GHOST_DT_DOUBLE|GHOST_DT_REAL); \
378 #define GHOST_REGISTER_DT_S(name) \
379 typedef float name ## _t; \
380 ghost_datatype name = (ghost_datatype)(GHOST_DT_FLOAT|GHOST_DT_REAL); \
386 #define GHOST_REGISTER_DT_C(name) \
387 typedef std::complex<float> name ## _t; \
388 ghost_datatype name = (ghost_datatype)(GHOST_DT_FLOAT|GHOST_DT_COMPLEX);
393 #define GHOST_REGISTER_DT_C(name) \
394 typedef complex float name ## _t; \
395 ghost_datatype name = (ghost_datatype)(GHOST_DT_FLOAT|GHOST_DT_COMPLEX);
402 #define GHOST_REGISTER_DT_Z(name) \
403 typedef std::complex<double> name ## _t; \
404 ghost_datatype name = (ghost_datatype)(GHOST_DT_DOUBLE|GHOST_DT_COMPLEX);
409 #define GHOST_REGISTER_DT_Z(name) \
410 typedef complex double name ## _t; \
411 ghost_datatype name = (ghost_datatype)(GHOST_DT_DOUBLE|GHOST_DT_COMPLEX);
414 #ifdef GHOST_IDX64_GLOBAL
424 #define ghost_mpi_dt_gidx MPI_INT64_T
426 #ifdef GHOST_HAVE_MPI
427 #warning "Assuming that MPI_LONG_LONG_INT is 64 bits long"
429 #define ghost_mpi_dt_gidx MPI_LONG_LONG_INT
434 #define PRGIDX PRId64
436 #define GHOST_GIDX_MAX INT64_MAX
448 #define ghost_mpi_dt_gidx MPI_INT32_T
450 #ifdef GHOST_HAVE_MPI
451 #warning "Assuming that MPI_INT is 32 bits long"
453 #define ghost_mpi_dt_gidx MPI_INT
458 #define PRGIDX PRId32
460 #define GHOST_GIDX_MAX INT32_MAX
464 #ifdef GHOST_IDX64_LOCAL
474 #define ghost_mpi_dt_lidx MPI_INT64_T
476 #ifdef GHOST_HAVE_MPI
477 #warning "Assuming that MPI_LONG_LONG_INT is 64 bits long"
479 #define ghost_mpi_dt_gidx MPI_LONG_LONG_INT
484 #define PRLIDX PRId64
486 #ifdef GHOST_HAVE_MKL
491 #define PRBLASIDX PRId64
494 #define PRBLASIDX PRId32
497 #define PRLIDX PRId64
499 #define GHOST_LIDX_MAX INT64_MAX
505 #define ghost_mpi_dt_lidx MPI_INT32_T
507 #ifdef GHOST_HAVE_MPI
508 #warning "Assuming that MPI_INT is 32 bits long"
510 #define ghost_mpi_dt_lidx MPI_INT
513 #define PRBLASIDX PRId32
515 #define PRLIDX PRId32
517 #define GHOST_LIDX_MAX INT32_MAX
521 #if defined(GHOST_IDX64_LOCAL) && defined(GHOST_IDX64_GLOBAL)
522 #define GHOST_IDX_UNIFORM
525 #if !defined(GHOST_IDX64_LOCAL) && !defined(GHOST_IDX64_GLOBAL)
526 #define GHOST_IDX_UNIFORM
531 #define ghost_mpi_dt_idx ghost_mpi_dt_gidx
ghost_implementation
Possible implementations of a CPU function.
Definition: types.h:323
const char * ghost_location_string(ghost_location location)
Definition: types.c:197
ghost_error ghost_datatype_idx_get(ghost_datatype_idx *idx, ghost_datatype datatype)
Definition: types.c:145
Data is located on host.
Definition: types.h:278
ghost_error ghost_mpi_datatype_get(ghost_mpi_datatype *dt, ghost_datatype datatype)
Definition: types.c:8
int32_t ghost_gidx
Type for global indices.
Definition: types.h:443
int32_t ghost_lidx
Definition: types.h:503
int ghost_blas_idx
Definition: types.h:512
Types, functions and macros for error handling.
int ghost_mpi_comm
Definition: types.h:19
Complex numbers.
Definition: types.h:264
Single precision.
Definition: types.h:252
Double precision.
Definition: types.h:256
ghost_error
Error return type.
Definition: error.h:23
ghost_error ghost_datatype_size(size_t *size, ghost_datatype datatype)
Definition: types.c:67
ghost_alignment
Possible alignments of data access.
Definition: types.h:315
Real numbers.
Definition: types.h:260
Real double.
Definition: types.h:346
Default location. This is only a placeholder and the actual location has to be specified by GHOST...
Definition: types.h:274
bool ghost_datatype_valid(ghost_datatype datatype)
Check whether a given data type is valid.
Definition: types.c:91
ghost_datatype
Available primitive data types.
Definition: types.h:248
float x
Definition: types.h:544
int ghost_mpi_datatype
Definition: types.h:21
ghost_error ghost_mpi_datatypes_create()
Definition: types.c:37
Data is located on device (accelerator, GPU).
Definition: types.h:282
int ghost_mpi_op
Definition: types.h:20
double x
Definition: types.h:553
double y
Definition: types.h:554
ghost_error ghost_mpi_datatypes_destroy()
Definition: types.c:55
A float complex number (used for MPI).
Definition: types.h:542
ghost_datatype_idx
Contiguous indices for data types.
Definition: types.h:338
const char * ghost_datatype_string(ghost_datatype datatype)
Stringify a ghost_datatype.
Definition: types.c:118
const char * ghost_implementation_string(ghost_implementation implementation)
Definition: types.c:215
float y
Definition: types.h:545
Real float.
Definition: types.h:342
ghost_location
Definition: types.h:270
Complex float.
Definition: types.h:350
A double complex number (used for MPI).
Definition: types.h:551
ghost_error ghost_idx2datatype(ghost_datatype *datatype, ghost_datatype_idx idx)
Definition: types.c:171
Complex double.
Definition: types.h:354
int ghost_idx_of_location(ghost_location l)
Definition: types.c:238