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,
235 unsigned int root_mpi_rank,
239 return MPI_Bcast_c(buf, count, datatype, root_mpi_rank,
comm);
242 return MPI_Bcast(buf, count, datatype, root_mpi_rank,
comm);
244 MPI_Datatype bigtype;
247 if (ierr != MPI_SUCCESS)
249 ierr = MPI_Type_commit(&bigtype);
250 if (ierr != MPI_SUCCESS)
253 ierr = MPI_Bcast(buf, 1, bigtype, root_mpi_rank,
comm);
254 if (ierr != MPI_SUCCESS)
257 ierr = MPI_Type_free(&bigtype);
258 if (ierr != MPI_SUCCESS)
274 MPI_Datatype datatype,
278 return MPI_File_write_at(fh, offset, buf, count, datatype, status);
280 MPI_Datatype bigtype;
283 if (ierr != MPI_SUCCESS)
285 ierr = MPI_Type_commit(&bigtype);
286 if (ierr != MPI_SUCCESS)
289 ierr = MPI_File_write_at(fh, offset, buf, 1, bigtype, status);
290 if (ierr != MPI_SUCCESS)
293 ierr = MPI_Type_free(&bigtype);
294 if (ierr != MPI_SUCCESS)
310 MPI_Datatype datatype,
314 return MPI_File_write_at_all(
315 fh, offset, buf, count, datatype, status);
317 MPI_Datatype bigtype;
320 if (ierr != MPI_SUCCESS)
322 ierr = MPI_Type_commit(&bigtype);
323 if (ierr != MPI_SUCCESS)
326 ierr = MPI_File_write_at_all(fh, offset, buf, 1, bigtype, status);
327 if (ierr != MPI_SUCCESS)
330 ierr = MPI_Type_free(&bigtype);
331 if (ierr != MPI_SUCCESS)
345 MPI_Datatype datatype,
349 return MPI_File_write_ordered(fh, buf, count, datatype, status);
351 MPI_Datatype bigtype;
354 if (ierr != MPI_SUCCESS)
356 ierr = MPI_Type_commit(&bigtype);
357 if (ierr != MPI_SUCCESS)
360 ierr = MPI_File_write_ordered(fh, buf, 1, bigtype, status);
361 if (ierr != MPI_SUCCESS)
364 ierr = MPI_Type_free(&bigtype);
365 if (ierr != MPI_SUCCESS)
381 MPI_Datatype datatype,
385 return MPI_File_read_at(fh, offset, buf, count, datatype, status);
387 MPI_Datatype bigtype;
390 if (ierr != MPI_SUCCESS)
392 ierr = MPI_Type_commit(&bigtype);
393 if (ierr != MPI_SUCCESS)
396 ierr = MPI_File_read_at(fh, offset, buf, 1, bigtype, status);
397 if (ierr != MPI_SUCCESS)
400 ierr = MPI_Type_free(&bigtype);
401 if (ierr != MPI_SUCCESS)
417 MPI_Datatype datatype,
421 return MPI_File_read_at_all(fh, offset, buf, count, datatype, status);
423 MPI_Datatype bigtype;
426 if (ierr != MPI_SUCCESS)
428 ierr = MPI_Type_commit(&bigtype);
429 if (ierr != MPI_SUCCESS)
432 ierr = MPI_File_read_at_all(fh, offset, buf, 1, bigtype, status);
433 if (ierr != MPI_SUCCESS)
436 ierr = MPI_Type_free(&bigtype);
437 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