5#ifndef IPPL_MPI_COMMUNICATOR_H
6#define IPPL_MPI_COMMUNICATOR_H
43 operator const MPI_Comm&()
const noexcept {
return *
comm_m; }
51 void abort(
int errorcode = -1) { MPI_Abort(*
comm_m, errorcode); }
59 void send(
const T& buffer,
int count,
int dest,
int tag);
62 void send(
const T* buffer,
int count,
int dest,
int tag);
65 void recv(
T& output,
int count,
int source,
int tag,
Status& status);
68 void recv(
T* output,
int count,
int source,
int tag,
Status& status);
99 void gather(
const T* input,
T* output,
int count,
int root = 0);
104 template <
typename T>
105 void scatter(
const T* input,
T* output,
int count,
int root = 0);
111 template <
typename T,
class Op>
112 void reduce(
const T* input,
T* output,
int count, Op op,
int root = 0);
114 template <
typename T,
class Op>
115 void reduce(
const T& input,
T& output,
int count, Op op,
int root = 0);
117 template <
typename T,
class Op>
118 void allreduce(
const T* input,
T* output,
int count, Op op);
120 template <
typename T,
class Op>
121 void allreduce(
const T& input,
T& output,
int count, Op op);
123 template <
typename T,
class Op>
126 template <
typename T,
class Op>
130 template <
typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
133 template <
typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
137 template <
typename MemorySpace>
148 template <
typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space,
155 template <
typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
160 template <
class Buffer,
typename Archive>
166 if (msize > INT_MAX) {
167 std::cerr <<
"Message size exceeds range of int" << std::endl;
171 MPI_Recv(ar.getBuffer(), msize, MPI_BYTE, src,
tag, *
comm_m, &status);
173 buffer.deserialize(ar, nrecvs);
176 template <
class Buffer,
typename Archive>
177 void isend(
int dest,
int tag, Buffer& buffer, Archive& ar, MPI_Request& request,
179 if (ar.getSize() > INT_MAX) {
180 std::cerr <<
"Message size exceeds range of int" << std::endl;
183 buffer.serialize(ar, nsends);
184 MPI_Isend(ar.getBuffer(), ar.getSize(), MPI_BYTE, dest,
tag, *
comm_m, &request);
187 template <
typename Archive>
189 if (msize > INT_MAX) {
190 std::cerr <<
"Message size exceeds range of int" << std::endl;
193 MPI_Irecv(ar.getBuffer(), msize, MPI_BYTE, src,
tag, *
comm_m, &request);
196 void printLogs(
const std::string& filename);
202 void writeLogsToFile(
const std::vector<LogEntry>& allLogs,
const std::string& filename);
ippl::detail::size_type size_type
void writeLogsToFile(const std::vector< LogEntry > &allLogs, const std::string &filename)
void scatter(const T *input, T *output, int count, int root=0)
void send(const T &buffer, int count, int dest, int tag)
const MPI_Comm & getCommunicator() const noexcept
void isend(int dest, int tag, Buffer &buffer, Archive &ar, MPI_Request &request, size_type nsends)
typename detail::ContainerForAllSpaces< buffer_container_type >::type buffer_handler_type
void irecv(T &buffer, int count, int source, int tag, Request &request)
void abort(int errorcode=-1)
Communicator & operator=(MPI_Comm comm)
void printLogs(const std::string &filename)
void freeBuffer(buffer_type< MemorySpace > buffer)
void setDefaultOverallocation(double factor)
Communicator split(int color, int key) const
int rank() const noexcept
void reduce(const T *input, T *output, int count, Op op, int root=0)
void recv(T &output, int count, int source, int tag, Status &status)
std::shared_ptr< MPI_Comm > comm_m
std::shared_ptr< archive_type< MemorySpace > > buffer_type
int size() const noexcept
buffer_type< MemorySpace > getBuffer(size_type size, double overallocation=1.0)
double defaultOveralloc_m
detail::size_type size_type
bool iprobe(int source, int tag, Status &status)
std::vector< LogEntry > gatherLocalLogs()
buffer_handler_type buffer_handlers_m
void isend(const T &buffer, int count, int dest, int tag, Request &request)
void allreduce(const T *input, T *output, int count, Op op)
std::vector< LogEntry > gatherLogsFromAllRanks(const std::vector< LogEntry > &localLogs)
void probe(int source, int tag, Status &status)
LoggingBufferHandler< MemorySpace > buffer_container_type
void gather(const T *input, T *output, int count, int root=0)
double getDefaultOverallocation() const
void recv(int src, int tag, Buffer &buffer, Archive &ar, size_type msize, size_type nrecvs)
void sendLogsToRank0(const std::vector< LogEntry > &localLogs)
void irecv(int src, int tag, Archive &ar, MPI_Request &request, size_type msize)
detail::Archive< MemorySpace > archive_type
Decorator class for buffer management that adds logging capabilities to buffer operations.
typename TypeForAllSpaces< container_type >::memory_spaces_type type