23#ifndef BIG_MPI_COMPAT_H
24#define BIG_MPI_COMPAT_H
28#ifdef DEAL_II_WITH_MPI
35# error "Your MPI implementation does not define MPI_VERSION!"
39# error "BigMPICompat requires at least MPI 3.0"
64 std::numeric_limits<int>::max();
74 MPI_Datatype *newtype)
77 return MPI_Type_contiguous_c(count, oldtype, newtype);
80 return MPI_Type_contiguous(count, oldtype, newtype);
87 ierr = MPI_Type_size_x(oldtype, &size_old);
89 MPI_Count n_chunks = count / max_signed_int;
90 MPI_Count n_remaining_elements = count % max_signed_int;
93 ierr = MPI_Type_vector(
94 n_chunks, max_signed_int, max_signed_int, oldtype, &chunks);
95 if (ierr != MPI_SUCCESS)
98 MPI_Datatype remainder;
100 MPI_Type_contiguous(n_remaining_elements, oldtype, &remainder);
101 if (ierr != MPI_SUCCESS)
104 int blocklengths[2] = {1, 1};
105 MPI_Aint displacements[2] = {0,
106 static_cast<MPI_Aint
>(n_chunks) *
107 size_old * max_signed_int};
108 MPI_Datatype
types[2] = {chunks, remainder};
109 ierr = MPI_Type_create_struct(
110 2, blocklengths, displacements,
types, newtype);
111 if (ierr != MPI_SUCCESS)
114 ierr = MPI_Type_commit(newtype);
115 if (ierr != MPI_SUCCESS)
118 ierr = MPI_Type_free(&chunks);
119 if (ierr != MPI_SUCCESS)
122 ierr = MPI_Type_free(&remainder);
123 if (ierr != MPI_SUCCESS)
126# ifndef MPI_COMPAT_SKIP_SIZE_CHECK
128 ierr = MPI_Type_size_x(*newtype, &size_new);
129 if (ierr != MPI_SUCCESS)
132 if (size_old * count != size_new)
143 return MPI_ERR_INTERN;
161 MPI_Datatype datatype,
167 return MPI_Send_c(buf, count, datatype, dest, tag,
comm);
170 return MPI_Send(buf, count, datatype, dest, tag,
comm);
172 MPI_Datatype bigtype;
175 if (ierr != MPI_SUCCESS)
177 ierr = MPI_Type_commit(&bigtype);
178 if (ierr != MPI_SUCCESS)
181 ierr = MPI_Send(buf, 1, bigtype, dest, tag,
comm);
182 if (ierr != MPI_SUCCESS)
185 ierr = MPI_Type_free(&bigtype);
186 if (ierr != MPI_SUCCESS)
200 MPI_Datatype datatype,
207 return MPI_Recv_c(buf, count, datatype, source, tag,
comm, status);
210 return MPI_Recv(buf, count, datatype, source, tag,
comm, status);
212 MPI_Datatype bigtype;
215 if (ierr != MPI_SUCCESS)
218 ierr = MPI_Type_commit(&bigtype);
219 if (ierr != MPI_SUCCESS)
222 ierr = MPI_Recv(buf, 1, bigtype, source, tag,
comm, status);
223 if (ierr != MPI_SUCCESS)
226 ierr = MPI_Type_free(&bigtype);
227 if (ierr != MPI_SUCCESS)
242 MPI_Datatype datatype,
243 unsigned int root_mpi_rank,
247 return MPI_Bcast_c(buf, count, datatype, root_mpi_rank,
comm);
250 return MPI_Bcast(buf, count, datatype, root_mpi_rank,
comm);
252 MPI_Datatype bigtype;
255 if (ierr != MPI_SUCCESS)
257 ierr = MPI_Type_commit(&bigtype);
258 if (ierr != MPI_SUCCESS)
261 ierr = MPI_Bcast(buf, 1, bigtype, root_mpi_rank,
comm);
262 if (ierr != MPI_SUCCESS)
265 ierr = MPI_Type_free(&bigtype);
266 if (ierr != MPI_SUCCESS)
282 MPI_Datatype datatype,
286 return MPI_File_write_at(fh, offset, buf, count, datatype, status);
288 MPI_Datatype bigtype;
291 if (ierr != MPI_SUCCESS)
293 ierr = MPI_Type_commit(&bigtype);
294 if (ierr != MPI_SUCCESS)
297 ierr = MPI_File_write_at(fh, offset, buf, 1, bigtype, status);
298 if (ierr != MPI_SUCCESS)
301 ierr = MPI_Type_free(&bigtype);
302 if (ierr != MPI_SUCCESS)
318 MPI_Datatype datatype,
322 return MPI_File_write_at_all(
323 fh, offset, buf, count, datatype, status);
325 MPI_Datatype bigtype;
328 if (ierr != MPI_SUCCESS)
330 ierr = MPI_Type_commit(&bigtype);
331 if (ierr != MPI_SUCCESS)
334 ierr = MPI_File_write_at_all(fh, offset, buf, 1, bigtype, status);
335 if (ierr != MPI_SUCCESS)
338 ierr = MPI_Type_free(&bigtype);
339 if (ierr != MPI_SUCCESS)
353 MPI_Datatype datatype,
357 return MPI_File_write_ordered(fh, buf, count, datatype, status);
359 MPI_Datatype bigtype;
362 if (ierr != MPI_SUCCESS)
364 ierr = MPI_Type_commit(&bigtype);
365 if (ierr != MPI_SUCCESS)
368 ierr = MPI_File_write_ordered(fh, buf, 1, bigtype, status);
369 if (ierr != MPI_SUCCESS)
372 ierr = MPI_Type_free(&bigtype);
373 if (ierr != MPI_SUCCESS)
389 MPI_Datatype datatype,
393 return MPI_File_read_at(fh, offset, buf, count, datatype, status);
395 MPI_Datatype bigtype;
398 if (ierr != MPI_SUCCESS)
400 ierr = MPI_Type_commit(&bigtype);
401 if (ierr != MPI_SUCCESS)
404 ierr = MPI_File_read_at(fh, offset, buf, 1, bigtype, status);
405 if (ierr != MPI_SUCCESS)
408 ierr = MPI_Type_free(&bigtype);
409 if (ierr != MPI_SUCCESS)
425 MPI_Datatype datatype,
429 return MPI_File_read_at_all(fh, offset, buf, count, datatype, status);
431 MPI_Datatype bigtype;
434 if (ierr != MPI_SUCCESS)
436 ierr = MPI_Type_commit(&bigtype);
437 if (ierr != MPI_SUCCESS)
440 ierr = MPI_File_read_at_all(fh, offset, buf, 1, bigtype, status);
441 if (ierr != MPI_SUCCESS)
444 ierr = MPI_Type_free(&bigtype);
445 if (ierr != MPI_SUCCESS)
57 namespace LargeCount {
…}
#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