23#ifndef BIG_MPI_COMPAT_H
24#define BIG_MPI_COMPAT_H
28#ifdef DEAL_II_WITH_MPI
55 std::numeric_limits<int>::max();
65 MPI_Datatype *newtype)
68 return MPI_Type_contiguous_c(count, oldtype, newtype);
71 return MPI_Type_contiguous(count, oldtype, newtype);
78 ierr = MPI_Type_size_x(oldtype, &size_old);
80 MPI_Count n_chunks = count / max_signed_int;
81 MPI_Count n_remaining_elements = count % max_signed_int;
84 ierr = MPI_Type_vector(
85 n_chunks, max_signed_int, max_signed_int, oldtype, &chunks);
86 if (ierr != MPI_SUCCESS)
89 MPI_Datatype remainder;
91 MPI_Type_contiguous(n_remaining_elements, oldtype, &remainder);
92 if (ierr != MPI_SUCCESS)
95 int blocklengths[2] = {1, 1};
96 MPI_Aint displacements[2] = {0,
97 static_cast<MPI_Aint
>(n_chunks) *
98 size_old * max_signed_int};
99 MPI_Datatype
types[2] = {chunks, remainder};
100 ierr = MPI_Type_create_struct(
101 2, blocklengths, displacements,
types, newtype);
102 if (ierr != MPI_SUCCESS)
105 ierr = MPI_Type_commit(newtype);
106 if (ierr != MPI_SUCCESS)
109 ierr = MPI_Type_free(&chunks);
110 if (ierr != MPI_SUCCESS)
113 ierr = MPI_Type_free(&remainder);
114 if (ierr != MPI_SUCCESS)
117# ifndef MPI_COMPAT_SKIP_SIZE_CHECK
119 ierr = MPI_Type_size_x(*newtype, &size_new);
120 if (ierr != MPI_SUCCESS)
123 if (size_old * count != size_new)
134 return MPI_ERR_INTERN;
152 MPI_Datatype datatype,
158 return MPI_Send_c(buf, count, datatype, dest, tag,
comm);
161 return MPI_Send(buf, count, datatype, dest, tag,
comm);
163 MPI_Datatype bigtype;
166 if (ierr != MPI_SUCCESS)
168 ierr = MPI_Type_commit(&bigtype);
169 if (ierr != MPI_SUCCESS)
172 ierr = MPI_Send(buf, 1, bigtype, dest, tag,
comm);
173 if (ierr != MPI_SUCCESS)
176 ierr = MPI_Type_free(&bigtype);
177 if (ierr != MPI_SUCCESS)
191 MPI_Datatype datatype,
198 return MPI_Recv_c(buf, count, datatype, source, tag,
comm, status);
201 return MPI_Recv(buf, count, datatype, source, tag,
comm, status);
203 MPI_Datatype bigtype;
206 if (ierr != MPI_SUCCESS)
209 ierr = MPI_Type_commit(&bigtype);
210 if (ierr != MPI_SUCCESS)
213 ierr = MPI_Recv(buf, 1, bigtype, source, tag,
comm, status);
214 if (ierr != MPI_SUCCESS)
217 ierr = MPI_Type_free(&bigtype);
218 if (ierr != MPI_SUCCESS)
233 MPI_Datatype datatype,
234 unsigned int root_mpi_rank,
238 return MPI_Bcast_c(buf, count, datatype, root_mpi_rank,
comm);
241 return MPI_Bcast(buf, count, datatype, root_mpi_rank,
comm);
243 MPI_Datatype bigtype;
246 if (ierr != MPI_SUCCESS)
248 ierr = MPI_Type_commit(&bigtype);
249 if (ierr != MPI_SUCCESS)
252 ierr = MPI_Bcast(buf, 1, bigtype, root_mpi_rank,
comm);
253 if (ierr != MPI_SUCCESS)
256 ierr = MPI_Type_free(&bigtype);
257 if (ierr != MPI_SUCCESS)
273 MPI_Datatype datatype,
277 return MPI_File_write_at(fh, offset, buf, count, datatype, status);
279 MPI_Datatype bigtype;
282 if (ierr != MPI_SUCCESS)
284 ierr = MPI_Type_commit(&bigtype);
285 if (ierr != MPI_SUCCESS)
288 ierr = MPI_File_write_at(fh, offset, buf, 1, bigtype, status);
289 if (ierr != MPI_SUCCESS)
292 ierr = MPI_Type_free(&bigtype);
293 if (ierr != MPI_SUCCESS)
309 MPI_Datatype datatype,
313 return MPI_File_write_at_all(
314 fh, offset, buf, count, datatype, status);
316 MPI_Datatype bigtype;
319 if (ierr != MPI_SUCCESS)
321 ierr = MPI_Type_commit(&bigtype);
322 if (ierr != MPI_SUCCESS)
325 ierr = MPI_File_write_at_all(fh, offset, buf, 1, bigtype, status);
326 if (ierr != MPI_SUCCESS)
329 ierr = MPI_Type_free(&bigtype);
330 if (ierr != MPI_SUCCESS)
344 MPI_Datatype datatype,
348 return MPI_File_write_ordered(fh, buf, count, datatype, status);
350 MPI_Datatype bigtype;
353 if (ierr != MPI_SUCCESS)
355 ierr = MPI_Type_commit(&bigtype);
356 if (ierr != MPI_SUCCESS)
359 ierr = MPI_File_write_ordered(fh, buf, 1, bigtype, status);
360 if (ierr != MPI_SUCCESS)
363 ierr = MPI_Type_free(&bigtype);
364 if (ierr != MPI_SUCCESS)
380 MPI_Datatype datatype,
384 return MPI_File_read_at(fh, offset, buf, count, datatype, status);
386 MPI_Datatype bigtype;
389 if (ierr != MPI_SUCCESS)
391 ierr = MPI_Type_commit(&bigtype);
392 if (ierr != MPI_SUCCESS)
395 ierr = MPI_File_read_at(fh, offset, buf, 1, bigtype, status);
396 if (ierr != MPI_SUCCESS)
399 ierr = MPI_Type_free(&bigtype);
400 if (ierr != MPI_SUCCESS)
416 MPI_Datatype datatype,
420 return MPI_File_read_at_all(fh, offset, buf, count, datatype, status);
422 MPI_Datatype bigtype;
425 if (ierr != MPI_SUCCESS)
427 ierr = MPI_Type_commit(&bigtype);
428 if (ierr != MPI_SUCCESS)
431 ierr = MPI_File_read_at_all(fh, offset, buf, 1, bigtype, status);
432 if (ierr != MPI_SUCCESS)
435 ierr = MPI_Type_free(&bigtype);
436 if (ierr != MPI_SUCCESS)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
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)
constexpr MPI_Count mpi_max_int_count
*braid_SplitCommworld & comm