21#ifndef dealii_base_mpi_large_count_h
22#define dealii_base_mpi_large_count_h
26#ifdef DEAL_II_WITH_MPI
39#ifdef DEAL_II_WITH_MPI
56 std::numeric_limits<int>::max();
66 MPI_Datatype *newtype)
69 return MPI_Type_contiguous_c(count, oldtype, newtype);
72 return MPI_Type_contiguous(count, oldtype, newtype);
79 ierr = MPI_Type_size_x(oldtype, &size_old);
81 MPI_Count n_chunks = count / max_signed_int;
82 MPI_Count n_remaining_elements = count % max_signed_int;
85 ierr = MPI_Type_vector(
86 n_chunks, max_signed_int, max_signed_int, oldtype, &chunks);
87 if (ierr != MPI_SUCCESS)
90 MPI_Datatype remainder;
92 MPI_Type_contiguous(n_remaining_elements, oldtype, &remainder);
93 if (ierr != MPI_SUCCESS)
96 int blocklengths[2] = {1, 1};
97 MPI_Aint displacements[2] = {0,
98 static_cast<MPI_Aint
>(n_chunks) *
99 size_old * max_signed_int};
100 MPI_Datatype
types[2] = {chunks, remainder};
101 ierr = MPI_Type_create_struct(
102 2, blocklengths, displacements,
types, newtype);
103 if (ierr != MPI_SUCCESS)
106 ierr = MPI_Type_commit(newtype);
107 if (ierr != MPI_SUCCESS)
110 ierr = MPI_Type_free(&chunks);
111 if (ierr != MPI_SUCCESS)
114 ierr = MPI_Type_free(&remainder);
115 if (ierr != MPI_SUCCESS)
118# ifndef MPI_COMPAT_SKIP_SIZE_CHECK
120 ierr = MPI_Type_size_x(*newtype, &size_new);
121 if (ierr != MPI_SUCCESS)
124 if (size_old * count != size_new)
135 return MPI_ERR_INTERN;
153 MPI_Datatype datatype,
159 return MPI_Send_c(buf, count, datatype, dest, tag,
comm);
162 return MPI_Send(buf, count, datatype, dest, tag,
comm);
164 MPI_Datatype bigtype;
167 if (ierr != MPI_SUCCESS)
169 ierr = MPI_Type_commit(&bigtype);
170 if (ierr != MPI_SUCCESS)
173 ierr = MPI_Send(buf, 1, bigtype, dest, tag,
comm);
174 if (ierr != MPI_SUCCESS)
177 ierr = MPI_Type_free(&bigtype);
178 if (ierr != MPI_SUCCESS)
192 MPI_Datatype datatype,
199 return MPI_Recv_c(buf, count, datatype, source, tag,
comm, status);
202 return MPI_Recv(buf, count, datatype, source, tag,
comm, status);
204 MPI_Datatype bigtype;
207 if (ierr != MPI_SUCCESS)
210 ierr = MPI_Type_commit(&bigtype);
211 if (ierr != MPI_SUCCESS)
214 ierr = MPI_Recv(buf, 1, bigtype, source, tag,
comm, status);
215 if (ierr != MPI_SUCCESS)
218 ierr = MPI_Type_free(&bigtype);
219 if (ierr != MPI_SUCCESS)
234 MPI_Datatype datatype,
238 return MPI_Get_count_c(status, datatype, count);
243 return MPI_Get_elements_x(status, datatype, count);
256 MPI_Datatype datatype,
257 unsigned int root_mpi_rank,
261 return MPI_Bcast_c(buf, count, datatype, root_mpi_rank,
comm);
264 return MPI_Bcast(buf, count, datatype, root_mpi_rank,
comm);
266 MPI_Datatype bigtype;
269 if (ierr != MPI_SUCCESS)
271 ierr = MPI_Type_commit(&bigtype);
272 if (ierr != MPI_SUCCESS)
275 ierr = MPI_Bcast(buf, 1, bigtype, root_mpi_rank,
comm);
276 if (ierr != MPI_SUCCESS)
279 ierr = MPI_Type_free(&bigtype);
280 if (ierr != MPI_SUCCESS)
296 MPI_Datatype datatype,
300 return MPI_File_write_at(fh, offset, buf, count, datatype, status);
302 MPI_Datatype bigtype;
305 if (ierr != MPI_SUCCESS)
307 ierr = MPI_Type_commit(&bigtype);
308 if (ierr != MPI_SUCCESS)
311 ierr = MPI_File_write_at(fh, offset, buf, 1, bigtype, status);
312 if (ierr != MPI_SUCCESS)
315 ierr = MPI_Type_free(&bigtype);
316 if (ierr != MPI_SUCCESS)
332 MPI_Datatype datatype,
336 return MPI_File_write_at_all(
337 fh, offset, buf, count, datatype, status);
339 MPI_Datatype bigtype;
342 if (ierr != MPI_SUCCESS)
344 ierr = MPI_Type_commit(&bigtype);
345 if (ierr != MPI_SUCCESS)
348 ierr = MPI_File_write_at_all(fh, offset, buf, 1, bigtype, status);
349 if (ierr != MPI_SUCCESS)
352 ierr = MPI_Type_free(&bigtype);
353 if (ierr != MPI_SUCCESS)
367 MPI_Datatype datatype,
371 return MPI_File_write_ordered(fh, buf, count, datatype, status);
373 MPI_Datatype bigtype;
376 if (ierr != MPI_SUCCESS)
378 ierr = MPI_Type_commit(&bigtype);
379 if (ierr != MPI_SUCCESS)
382 ierr = MPI_File_write_ordered(fh, buf, 1, bigtype, status);
383 if (ierr != MPI_SUCCESS)
386 ierr = MPI_Type_free(&bigtype);
387 if (ierr != MPI_SUCCESS)
403 MPI_Datatype datatype,
407 return MPI_File_read_at(fh, offset, buf, count, datatype, status);
409 MPI_Datatype bigtype;
412 if (ierr != MPI_SUCCESS)
414 ierr = MPI_Type_commit(&bigtype);
415 if (ierr != MPI_SUCCESS)
418 ierr = MPI_File_read_at(fh, offset, buf, 1, bigtype, status);
419 if (ierr != MPI_SUCCESS)
422 ierr = MPI_Type_free(&bigtype);
423 if (ierr != MPI_SUCCESS)
439 MPI_Datatype datatype,
443 return MPI_File_read_at_all(fh, offset, buf, count, datatype, status);
445 MPI_Datatype bigtype;
448 if (ierr != MPI_SUCCESS)
450 ierr = MPI_Type_commit(&bigtype);
451 if (ierr != MPI_SUCCESS)
454 ierr = MPI_File_read_at_all(fh, offset, buf, 1, bigtype, status);
455 if (ierr != MPI_SUCCESS)
458 ierr = MPI_Type_free(&bigtype);
459 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 Get_count_c(const MPI_Status *status, MPI_Datatype datatype, MPI_Count *count)
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