23#ifndef BIG_MPI_COMPAT_H
24#define BIG_MPI_COMPAT_H
28#ifdef DEAL_II_WITH_MPI
33# error "Your MPI implementation does not define MPI_VERSION!"
37# error "BigMPICompat requires at least MPI 3.0"
58 std::numeric_limits<int>::max();
68 MPI_Datatype *newtype)
71 return MPI_Type_contiguous_c(count, oldtype, newtype);
74 return MPI_Type_contiguous(count, oldtype, newtype);
81 ierr = MPI_Type_size_x(oldtype, &size_old);
83 MPI_Count n_chunks = count / max_signed_int;
84 MPI_Count n_remaining_elements = count % max_signed_int;
87 ierr = MPI_Type_vector(
88 n_chunks, max_signed_int, max_signed_int, oldtype, &chunks);
89 if (ierr != MPI_SUCCESS)
92 MPI_Datatype remainder;
94 MPI_Type_contiguous(n_remaining_elements, oldtype, &remainder);
95 if (ierr != MPI_SUCCESS)
98 int blocklengths[2] = {1, 1};
99 MPI_Aint displacements[2] = {0,
100 static_cast<MPI_Aint
>(n_chunks) *
101 size_old * max_signed_int};
102 MPI_Datatype
types[2] = {chunks, remainder};
103 ierr = MPI_Type_create_struct(
104 2, blocklengths, displacements,
types, newtype);
105 if (ierr != MPI_SUCCESS)
108 ierr = MPI_Type_commit(newtype);
109 if (ierr != MPI_SUCCESS)
112 ierr = MPI_Type_free(&chunks);
113 if (ierr != MPI_SUCCESS)
116 ierr = MPI_Type_free(&remainder);
117 if (ierr != MPI_SUCCESS)
120# ifndef MPI_COMPAT_SKIP_SIZE_CHECK
122 ierr = MPI_Type_size_x(*newtype, &size_new);
123 if (ierr != MPI_SUCCESS)
126 if (size_old * count != size_new)
137 return MPI_ERR_INTERN;
155 MPI_Datatype datatype,
161 return MPI_Send_c(buf, count, datatype, dest, tag,
comm);
164 return MPI_Send(buf, count, datatype, dest, tag,
comm);
166 MPI_Datatype bigtype;
169 if (ierr != MPI_SUCCESS)
171 ierr = MPI_Type_commit(&bigtype);
172 if (ierr != MPI_SUCCESS)
175 ierr = MPI_Send(buf, 1, bigtype, dest, tag,
comm);
176 if (ierr != MPI_SUCCESS)
179 ierr = MPI_Type_free(&bigtype);
180 if (ierr != MPI_SUCCESS)
194 MPI_Datatype datatype,
201 return MPI_Recv_c(buf, count, datatype, source, tag,
comm, status);
204 return MPI_Recv(buf, count, datatype, source, tag,
comm, status);
206 MPI_Datatype bigtype;
209 if (ierr != MPI_SUCCESS)
212 ierr = MPI_Type_commit(&bigtype);
213 if (ierr != MPI_SUCCESS)
216 ierr = MPI_Recv(buf, 1, bigtype, source, tag,
comm, status);
217 if (ierr != MPI_SUCCESS)
220 ierr = MPI_Type_free(&bigtype);
221 if (ierr != MPI_SUCCESS)
236 MPI_Datatype datatype,
237 unsigned int root_mpi_rank,
241 return MPI_Bcast_c(buf, count, datatype, root_mpi_rank,
comm);
244 return MPI_Bcast(buf, count, datatype, root_mpi_rank,
comm);
246 MPI_Datatype bigtype;
249 if (ierr != MPI_SUCCESS)
251 ierr = MPI_Type_commit(&bigtype);
252 if (ierr != MPI_SUCCESS)
255 ierr = MPI_Bcast(buf, 1, bigtype, root_mpi_rank,
comm);
256 if (ierr != MPI_SUCCESS)
259 ierr = MPI_Type_free(&bigtype);
260 if (ierr != MPI_SUCCESS)
276 MPI_Datatype datatype,
280 return MPI_File_write_at(fh, offset, buf, count, datatype, status);
282 MPI_Datatype bigtype;
285 if (ierr != MPI_SUCCESS)
287 ierr = MPI_Type_commit(&bigtype);
288 if (ierr != MPI_SUCCESS)
291 ierr = MPI_File_write_at(fh, offset, buf, 1, bigtype, status);
292 if (ierr != MPI_SUCCESS)
295 ierr = MPI_Type_free(&bigtype);
296 if (ierr != MPI_SUCCESS)
312 MPI_Datatype datatype,
316 return MPI_File_write_at_all(
317 fh, offset, buf, count, datatype, status);
319 MPI_Datatype bigtype;
322 if (ierr != MPI_SUCCESS)
324 ierr = MPI_Type_commit(&bigtype);
325 if (ierr != MPI_SUCCESS)
328 ierr = MPI_File_write_at_all(fh, offset, buf, 1, bigtype, status);
329 if (ierr != MPI_SUCCESS)
332 ierr = MPI_Type_free(&bigtype);
333 if (ierr != MPI_SUCCESS)
347 MPI_Datatype datatype,
351 return MPI_File_write_ordered(fh, buf, count, datatype, status);
353 MPI_Datatype bigtype;
356 if (ierr != MPI_SUCCESS)
358 ierr = MPI_Type_commit(&bigtype);
359 if (ierr != MPI_SUCCESS)
362 ierr = MPI_File_write_ordered(fh, buf, 1, bigtype, status);
363 if (ierr != MPI_SUCCESS)
366 ierr = MPI_Type_free(&bigtype);
367 if (ierr != MPI_SUCCESS)
383 MPI_Datatype datatype,
387 return MPI_File_read_at(fh, offset, buf, count, datatype, status);
389 MPI_Datatype bigtype;
392 if (ierr != MPI_SUCCESS)
394 ierr = MPI_Type_commit(&bigtype);
395 if (ierr != MPI_SUCCESS)
398 ierr = MPI_File_read_at(fh, offset, buf, 1, bigtype, status);
399 if (ierr != MPI_SUCCESS)
402 ierr = MPI_Type_free(&bigtype);
403 if (ierr != MPI_SUCCESS)
419 MPI_Datatype datatype,
423 return MPI_File_read_at_all(fh, offset, buf, count, datatype, status);
425 MPI_Datatype bigtype;
428 if (ierr != MPI_SUCCESS)
430 ierr = MPI_Type_commit(&bigtype);
431 if (ierr != MPI_SUCCESS)
434 ierr = MPI_File_read_at_all(fh, offset, buf, 1, bigtype, status);
435 if (ierr != MPI_SUCCESS)
438 ierr = MPI_Type_free(&bigtype);
439 if (ierr != MPI_SUCCESS)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
int File_write_at_c(MPI_File fh, MPI_Offset offset, const void *buf, MPI_Count count, MPI_Datatype datatype, MPI_Status *status)
int File_write_ordered_c(MPI_File fh, const void *buf, MPI_Count count, MPI_Datatype datatype, MPI_Status *status)
int File_write_at_all_c(MPI_File fh, MPI_Offset offset, const void *buf, MPI_Count count, MPI_Datatype datatype, MPI_Status *status)
int Recv_c(void *buf, MPI_Count count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
int File_read_at_c(MPI_File fh, MPI_Offset offset, void *buf, MPI_Count count, MPI_Datatype datatype, MPI_Status *status)
int Type_contiguous_c(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype *newtype)
int Bcast_c(void *buf, MPI_Count count, MPI_Datatype datatype, unsigned int root_mpi_rank, MPI_Comm comm)
int Send_c(const void *buf, MPI_Count count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
int File_read_at_all_c(MPI_File fh, MPI_Offset offset, void *buf, MPI_Count count, MPI_Datatype datatype, MPI_Status *status)
static constexpr MPI_Count mpi_max_int_count
*braid_SplitCommworld & comm