AutoPas  3.0.0
Loading...
Searching...
No Matches
WrapMPI.h
Go to the documentation of this file.
1
7#pragma once
8
15#include <limits.h>
16#include <stdint.h>
17
18#if defined(AUTOPAS_INCLUDE_MPI)
19#include <mpi.h>
20#else
21#include <cstdio>
22#include <cstring>
23#include <map>
24#include <set>
25#endif
26
27namespace autopas {
28
29#if defined(AUTOPAS_INCLUDE_MPI)
30
31// MPI_Comm
33#define AUTOPAS_MPI_COMM_NULL MPI_COMM_NULL
35#define AUTOPAS_MPI_COMM_WORLD MPI_COMM_WORLD
36
37// MPI_Datatype
39#define AUTOPAS_MPI_BYTE MPI_BYTE
41#define AUTOPAS_MPI_CXX_BOOL MPI_CXX_BOOL
43#define AUTOPAS_MPI_CHAR MPI_CHAR
45#define AUTOPAS_MPI_INT MPI_INT
47#define AUTOPAS_MPI_LONG_INT MPI_LONG_INT
49#define AUTOPAS_MPI_UNSIGNED_INT MPI_UNSIGNED
51#define AUTOPAS_MPI_LONG MPI_LONG
53#define AUTOPAS_MPI_UNSIGNED_LONG MPI_UNSIGNED_LONG
55#define AUTOPAS_MPI_DOUBLE MPI_DOUBLE
56
57// MPI_Op
59#define AUTOPAS_MPI_MAX MPI_MAX
61#define AUTOPAS_MPI_MIN MPI_MIN
63#define AUTOPAS_MPI_SUM MPI_SUM
65#define AUTOPAS_MPI_PROD MPI_PROD
67#define AUTOPAS_MPI_LAND MPI_LAND
69#define AUTOPAS_MPI_BAND MPI_BAND
71#define AUTOPAS_MPI_LOR MPI_LOR
73#define AUTOPAS_MPI_BOR MPI_BOR
75#define AUTOPAS_MPI_LXOR MPI_LXOR
77#define AUTOPAS_MPI_BXOR MPI_BXOR
79#define AUTOPAS_MPI_MINLOC MPI_MINLOC
81#define AUTOPAS_MPI_MAXLOC MPI_MAXLOC
83#define AUTOPAS_MPI_REPLACE MPI_REPLACE
85#define AUTOPAS_MPI_NO_OP MPI_NO_OP
86
87// MPI Constants
89#define AUTOPAS_MPI_IN_PLACE MPI_IN_PLACE
90
91// MPI_Status
93#define AUTOPAS_MPI_STATUS_IGNORE MPI_STATUS_IGNORE
94
95// MPI_Request
97#define AUTOPAS_MPI_REQUEST_NULL MPI_REQUEST_NULL
98
100#define AUTOPAS_MPI_MAX_ERROR_STRING MPI_MAX_ERROR_STRING
101
102using AutoPas_MPI_Comm = MPI_Comm;
103using AutoPas_MPI_Datatype = MPI_Datatype;
104using AutoPas_MPI_Op = MPI_Op;
105using AutoPas_MPI_Status = MPI_Status;
106using AutoPas_MPI_Request = MPI_Request;
107
108#else
109
114 COMM_NULL = 0,
115 COMM_WORLD,
116};
118#define AUTOPAS_MPI_COMM_NULL autopas::AutoPas_MPI_Comm::COMM_NULL
120#define AUTOPAS_MPI_COMM_WORLD autopas::AutoPas_MPI_Comm::COMM_WORLD
121
127 BYTE = 1,
128 CXX_BOOL = sizeof(bool),
129 CHAR = sizeof(char),
130 UNSIGNED_CHAR = sizeof(unsigned char),
131 UNSIGNED_SHORT = sizeof(unsigned short),
132 INT = sizeof(int),
133 UNSIGNED_INT = sizeof(unsigned int),
134 UNSIGNED_LONG = sizeof(unsigned long),
135 UNSIGNED_LONG_LONG = sizeof(unsigned long long),
136 LONG = sizeof(double),
137 DOUBLE = sizeof(double),
138 LONG_INT = sizeof(long) + sizeof(int),
139};
140// MPI_Datatype
142#define AUTOPAS_MPI_BYTE autopas::AutoPas_MPI_Datatype::BYTE
144#define AUTOPAS_MPI_CXX_BOOL autopas::AutoPas_MPI_Datatype::CXX_BOOL
146#define AUTOPAS_MPI_CHAR autopas::AutoPas_MPI_Datatype::CHAR
148#define AUTOPAS_MPI_INT autopas::AutoPas_MPI_Datatype::INT
150#define AUTOPAS_MPI_LONG_INT autopas::AutoPas_MPI_Datatype::LONG_INT
152#define AUTOPAS_MPI_UNSIGNED_INT autopas::AutoPas_MPI_Datatype::UNSIGNED_INT
154#define AUTOPAS_MPI_LONG autopas::AutoPas_MPI_Datatype::LONG
156#define AUTOPAS_MPI_UNSIGNED_LONG autopas::AutoPas_MPI_Datatype::UNSIGNED_LONG
158#define AUTOPAS_MPI_DOUBLE autopas::AutoPas_MPI_Datatype::DOUBLE
159
163enum AutoPas_MPI_Op { MAX, MIN, SUM, PROD, LAND, BAND, LOR, BOR, LXOR, BXOR, MINLOC, MAXLOC, REPLACE, NO_OP };
164// MPI_Op
166#define AUTOPAS_MPI_MAX autopas::AutoPas_MPI_Op::MAX
168#define AUTOPAS_MPI_MIN autopas::AutoPas_MPI_Op::MIN
170#define AUTOPAS_MPI_SUM autopas::AutoPas_MPI_Op::SUM
172#define AUTOPAS_MPI_PROD autopas::AutoPas_MPI_Op::PROD
174#define AUTOPAS_MPI_LAND autopas::AutoPas_MPI_Op::LAND
176#define AUTOPAS_MPI_BAND autopas::AutoPas_MPI_Op::BAND
178#define AUTOPAS_MPI_LOR autopas::AutoPas_MPI_Op::LOR
180#define AUTOPAS_MPI_BOR autopas::AutoPas_MPI_Op::BOR
182#define AUTOPAS_MPI_LXOR autopas::AutoPas_MPI_Op::LXOR
184#define AUTOPAS_MPI_BXOR autopas::AutoPas_MPI_Op::BXOR
186#define AUTOPAS_MPI_MINLOC autopas::AutoPas_MPI_Op::MINLOC
188#define AUTOPAS_MPI_MAXLOC autopas::AutoPas_MPI_Op::MAXLOC
190#define AUTOPAS_MPI_REPLACE autopas::AutoPas_MPI_Op::REPLACE
192#define AUTOPAS_MPI_NO_OP autopas::AutoPas_MPI_Op::NO_OP
193
210};
212#define AUTOPAS_MPI_STATUS_IGNORE nullptr
213
218 REQUEST_NULL,
219 COMPLETED_REQUEST,
220 INCOMPLETE_REQUEST,
221};
223#define AUTOPAS_MPI_REQUEST_NULL autopas::AutoPas_MPI_Request::REQUEST_NULL
224
229 AUTOPAS_MPI_SUCCESS = 0,
230 AUTOPAS_MPI_ERR_BUFFER,
231 AUTOPAS_MPI_ERR_COUNT,
232 AUTOPAS_MPI_ERR_TYPE,
233 AUTOPAS_MPI_ERR_TAG,
234 AUTOPAS_MPI_ERR_COMM,
235 AUTOPAS_MPI_ERR_RANK,
236 AUTOPAS_MPI_ERR_ROOT,
237 AUTOPAS_MPI_ERR_GROUP,
238 AUTOPAS_MPI_ERR_OP,
239 AUTOPAS_MPI_ERR_TOPOLOGY,
240 AUTOPAS_MPI_ERR_DIMS,
241 AUTOPAS_MPI_ERR_ARG,
242 AUTOPAS_MPI_ERR_UNKNOWN,
243 AUTOPAS_MPI_ERR_TRUNCATE,
244 AUTOPAS_MPI_ERR_OTHER,
245 AUTOPAS_MPI_ERR_INTERN,
246 AUTOPAS_MPI_ERR_IN_STATUS,
247 AUTOPAS_MPI_ERR_PENDING,
248 AUTOPAS_MPI_ERR_REQUEST,
249 AUTOPAS_MPI_ERR_LASTCODE,
250};
252#define AUTOPAS_MPI_MAX_ERROR_STRING 256
254#define AUTOPAS_MPI_IN_PLACE ((void *)1)
255
256#endif
257
265inline int AutoPas_MPI_Init(int *argc, char ***argv);
266
272inline int AutoPas_MPI_Finalize();
273
279inline int AutoPas_MPI_Finalized(int *flag);
280
288inline int AutoPas_MPI_Error_string(int errorcode, char *string, int *resultlen);
289
296inline int AutoPas_MPI_Comm_size(AutoPas_MPI_Comm comm, int *size);
297
304inline int AutoPas_MPI_Comm_rank(AutoPas_MPI_Comm comm, int *rank);
305
313
320
331inline int AutoPas_MPI_Send(const void *buf, int count, AutoPas_MPI_Datatype datatype, int dest, int tag,
332 AutoPas_MPI_Comm comm);
333
345inline int AutoPas_MPI_Recv(void *buf, int count, AutoPas_MPI_Datatype datatype, int source, int tag,
346 AutoPas_MPI_Comm comm, AutoPas_MPI_Status *status);
347
357inline int AutoPas_MPI_Bcast(void *buffer, int count, AutoPas_MPI_Datatype datatype, int root, AutoPas_MPI_Comm comm);
358
369inline int AutoPas_MPI_Ibcast(void *buffer, int count, AutoPas_MPI_Datatype datatype, int root, AutoPas_MPI_Comm comm,
370 AutoPas_MPI_Request *request);
382inline int AutoPas_MPI_Reduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
383 AutoPas_MPI_Op op, int root, AutoPas_MPI_Comm comm);
384
395inline int AutoPas_MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
397
409inline int AutoPas_MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
411
418
426
434inline int AutoPas_MPI_Test(AutoPas_MPI_Request *request, int *flag, AutoPas_MPI_Status *status);
435
442inline int AutoPas_MPI_Wait(AutoPas_MPI_Request *request, AutoPas_MPI_Status *status);
443
450
461inline int AutoPas_MPI_Cart_create(AutoPas_MPI_Comm comm, int nDims, const int *dims, const int *periods, int reorder,
462 AutoPas_MPI_Comm *comm_cart);
463
473inline int AutoPas_MPI_Cart_get(AutoPas_MPI_Comm comm, int maxdims, int dims[], int periods[], int coords[]);
474
484inline int AutoPas_MPI_Cart_coords(AutoPas_MPI_Comm comm, int rank, int maxdims, int coords[]);
485
495inline int AutoPas_MPI_Cart_rank(AutoPas_MPI_Comm comm, const int coords[], int *rank);
496
505inline int AutoPas_MPI_Dims_create(int nnodes, int ndims, int dims[]);
506
518inline int AutoPas_MPI_Isend(const void *buf, int count, AutoPas_MPI_Datatype datatype, int dest, int tag,
520
533inline int AutoPas_MPI_Irecv(void *buf, int count, AutoPas_MPI_Datatype datatype, int source, int tag,
543inline int AutoPas_MPI_Probe(int source, int tag, AutoPas_MPI_Comm comm, AutoPas_MPI_Status *status);
544
552inline int AutoPas_MPI_Get_count(const AutoPas_MPI_Status *status, AutoPas_MPI_Datatype datatype, int *count);
553
561inline int AutoPas_MPI_Waitall(int count, AutoPas_MPI_Request array_of_requests[],
562 AutoPas_MPI_Status *array_of_statuses);
563
576inline int AutoPas_MPI_Gather(const void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
577 void *buffer_recv, int count_recv, AutoPas_MPI_Datatype datatype_recv, int root,
578 AutoPas_MPI_Comm comm);
579
593inline int AutoPas_MPI_Gatherv(const void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
594 void *buffer_recv, const int *count_recv, const int *displs,
595 AutoPas_MPI_Datatype datatype_recv, int root, AutoPas_MPI_Comm comm);
607inline int AutoPas_MPI_Allgather(void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
608 void *buffer_recv, int count_recv, AutoPas_MPI_Datatype datatype_recv,
609 AutoPas_MPI_Comm comm);
610
619inline int AutoPas_MPI_Comm_split(AutoPas_MPI_Comm old_communicator, int color, int key,
620 AutoPas_MPI_Comm *new_communicator);
621
622#if defined(AUTOPAS_INCLUDE_MPI)
623
624inline int AutoPas_MPI_Init(int *argc, char ***argv) { return MPI_Init(argc, argv); }
625
626inline int AutoPas_MPI_Finalize() { return MPI_Finalize(); }
627
628inline int AutoPas_MPI_Finalized(int *flag) { return MPI_Finalized(flag); }
629
630inline int AutoPas_MPI_Error_string(int errorcode, char *string, int *resultlen) {
631 return MPI_Error_string(errorcode, string, resultlen);
632}
633
634inline int AutoPas_MPI_Comm_size(AutoPas_MPI_Comm comm, int *size) { return MPI_Comm_size(comm, size); }
635
636inline int AutoPas_MPI_Comm_rank(AutoPas_MPI_Comm comm, int *rank) { return MPI_Comm_rank(comm, rank); }
637
638inline int AutoPas_MPI_Comm_dup(AutoPas_MPI_Comm comm, AutoPas_MPI_Comm *newComm) {
639 return MPI_Comm_dup(comm, newComm);
640}
641
642inline int AutoPas_MPI_Comm_free(AutoPas_MPI_Comm *comm) { return MPI_Comm_free(comm); }
643
644inline int AutoPas_MPI_Comm_split(AutoPas_MPI_Comm comm, int color, int key, AutoPas_MPI_Comm *newcomm) {
645 return MPI_Comm_split(comm, color, key, newcomm);
646}
647
648inline int AutoPas_MPI_Send(const void *buf, int count, AutoPas_MPI_Datatype datatype, int dest, int tag,
649 AutoPas_MPI_Comm comm) {
650 return MPI_Send(buf, count, datatype, dest, tag, comm);
651}
652
653inline int AutoPas_MPI_Recv(void *buf, int count, AutoPas_MPI_Datatype datatype, int source, int tag,
654 AutoPas_MPI_Comm comm, AutoPas_MPI_Status *status) {
655 return MPI_Recv(buf, count, datatype, source, tag, comm, status);
656}
657
658inline int AutoPas_MPI_Bcast(void *buffer, int count, AutoPas_MPI_Datatype datatype, int root, AutoPas_MPI_Comm comm) {
659 return MPI_Bcast(buffer, count, datatype, root, comm);
660}
661
662inline int AutoPas_MPI_Ibcast(void *buffer, int count, AutoPas_MPI_Datatype datatype, int root, AutoPas_MPI_Comm comm,
663 AutoPas_MPI_Request *request) {
664 return MPI_Ibcast(buffer, count, datatype, root, comm, request);
665}
666
667inline int AutoPas_MPI_Reduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
668 AutoPas_MPI_Op op, int root, AutoPas_MPI_Comm comm) {
669 return MPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
670}
671
672inline int AutoPas_MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
674 return MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm);
675}
676
677inline int AutoPas_MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
679 return MPI_Iallreduce(sendbuf, recvbuf, count, datatype, op, comm, request);
680}
681
682inline int AutoPas_MPI_Barrier(AutoPas_MPI_Comm comm) { return MPI_Barrier(comm); }
683
685 return MPI_Ibarrier(comm, request);
686}
687
688inline int AutoPas_MPI_Test(AutoPas_MPI_Request *request, int *flag, AutoPas_MPI_Status *status) {
689 return MPI_Test(request, flag, status);
690}
691
692inline int AutoPas_MPI_Wait(AutoPas_MPI_Request *request, AutoPas_MPI_Status *status) {
693 return MPI_Wait(request, status);
694}
695
696inline int AutoPas_MPI_Request_free(AutoPas_MPI_Request *request) { return MPI_Request_free(request); }
697
698inline int AutoPas_MPI_Cart_create(AutoPas_MPI_Comm comm, int nDims, const int *dims, const int *periods, int reorder,
699 AutoPas_MPI_Comm *comm_cart) {
700 return MPI_Cart_create(comm, nDims, dims, periods, reorder, comm_cart);
701}
702
703inline int AutoPas_MPI_Cart_get(AutoPas_MPI_Comm comm, int maxdims, int dims[], int periods[], int coords[]) {
704 return MPI_Cart_get(comm, maxdims, dims, periods, coords);
705}
706
707inline int AutoPas_MPI_Cart_coords(AutoPas_MPI_Comm comm, int rank, int maxdims, int coords[]) {
708 return MPI_Cart_coords(comm, rank, maxdims, coords);
709}
710
711inline int AutoPas_MPI_Cart_rank(AutoPas_MPI_Comm comm, const int coords[], int *rank) {
712 return MPI_Cart_rank(comm, coords, rank);
713}
714
715inline int AutoPas_MPI_Dims_create(int nnodes, int ndims, int dims[]) { return MPI_Dims_create(nnodes, ndims, dims); }
716
717inline int AutoPas_MPI_Isend(const void *buf, int count, AutoPas_MPI_Datatype datatype, int dest, int tag,
718 AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request) {
719 return MPI_Isend(buf, count, datatype, dest, tag, comm, request);
720}
721
722inline int AutoPas_MPI_Irecv(void *buf, int count, AutoPas_MPI_Datatype datatype, int source, int tag,
723 AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request) {
724 return MPI_Irecv(buf, count, datatype, source, tag, comm, request);
725}
726
727inline int AutoPas_MPI_Probe(int source, int tag, AutoPas_MPI_Comm comm, AutoPas_MPI_Status *status) {
728 return MPI_Probe(source, tag, comm, status);
729}
730
731inline int AutoPas_MPI_Get_count(const AutoPas_MPI_Status *status, AutoPas_MPI_Datatype datatype, int *count) {
732 return MPI_Get_count(status, datatype, count);
733}
734
735inline int AutoPas_MPI_Waitall(int count, AutoPas_MPI_Request array_of_requests[],
736 AutoPas_MPI_Status *array_of_statuses) {
737 return MPI_Waitall(count, array_of_requests, array_of_statuses);
738}
739
740inline int AutoPas_MPI_Gather(const void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
741 void *buffer_recv, int count_recv, AutoPas_MPI_Datatype datatype_recv, int root,
742 AutoPas_MPI_Comm comm) {
743 return MPI_Gather(buffer_send, count_send, datatype_send, buffer_recv, count_recv, datatype_recv, root, comm);
744}
745
746inline int AutoPas_MPI_Gatherv(const void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
747 void *buffer_recv, const int *count_recv, const int *displs,
748 AutoPas_MPI_Datatype datatype_recv, int root, AutoPas_MPI_Comm comm) {
749 return MPI_Gatherv(buffer_send, count_send, datatype_send, buffer_recv, count_recv, displs, datatype_recv, root,
750 comm);
751}
752
753inline int AutoPas_MPI_Allgather(void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
754 void *buffer_recv, int count_recv, AutoPas_MPI_Datatype datatype_recv,
755 AutoPas_MPI_Comm comm) {
756 return MPI_Allgather(buffer_send, count_send, datatype_send, buffer_recv, count_recv, datatype_recv, comm);
757}
758
759#else
760
761inline int AutoPas_MPI_Init(int *argc, char ***argv) { return AUTOPAS_MPI_SUCCESS; }
762
763inline int AutoPas_MPI_Finalize() { return AUTOPAS_MPI_SUCCESS; }
764
765inline int AutoPas_MPI_Finalized(int *flag) {
766 *flag = 1;
767 return AUTOPAS_MPI_SUCCESS;
768}
769
770int AutoPas_MPI_Error_string(int errorcode, char *string, int *resultlen) {
771 static const std::map<int, const char *> errorStrings = {
772 {AUTOPAS_MPI_SUCCESS, "MPI_SUCCESS: Successful return code"},
773 {AUTOPAS_MPI_ERR_BUFFER, "MPI_ERR_BUFFER: Invalid buffer pointer"},
774 {AUTOPAS_MPI_ERR_COUNT, "MPI_ERR_COUNT: Invalid count argument"},
775 {AUTOPAS_MPI_ERR_TYPE, "MPI_ERR_TYPE: Invalid datatype argument"},
776 {AUTOPAS_MPI_ERR_TAG, "MPI_ERR_TAG: Invalid tag argument"},
777 {AUTOPAS_MPI_ERR_COMM, "MPI_ERR_COMM: Invalid communicator"},
778 {AUTOPAS_MPI_ERR_RANK, "MPI_ERR_RANK: Invalid rank"},
779 {AUTOPAS_MPI_ERR_ROOT, "MPI_ERR_ROOT: Invalid root"},
780 {AUTOPAS_MPI_ERR_GROUP, "MPI_ERR_GROUP: Null group passed to function"},
781 {AUTOPAS_MPI_ERR_OP, "MPI_ERR_OP: Invalid operation"},
782 {AUTOPAS_MPI_ERR_TOPOLOGY, "MPI_ERR_TOPOLOGY: Invalid topology"},
783 {AUTOPAS_MPI_ERR_DIMS, "MPI_ERR_DIMS: Illegal dimension argument"},
784 {AUTOPAS_MPI_ERR_ARG, "MPI_ERR_ARG: Invalid argument"},
785 {AUTOPAS_MPI_ERR_UNKNOWN, "MPI_ERR_UNKNOWN: Unknown error"},
786 {AUTOPAS_MPI_ERR_TRUNCATE, "MPI_ERR_TRUNCATE: message truncated on receive"},
787 {AUTOPAS_MPI_ERR_OTHER, "MPI_ERR_OTHER: Other error; use Error_string"},
788 {AUTOPAS_MPI_ERR_INTERN, "MPI_ERR_INTERN: internal error code"},
789 {AUTOPAS_MPI_ERR_IN_STATUS, "MPI_ERR_IN_STATUS: Look in status for error value"},
790 {AUTOPAS_MPI_ERR_PENDING, "MPI_ERR_PENDING: Pending request"},
791 {AUTOPAS_MPI_ERR_REQUEST, "MPI_ERR_REQUEST: illegal mpi_request handle"},
792 {AUTOPAS_MPI_ERR_LASTCODE, "MPI_ERR_LASTCODE: Last error code -- always at end"},
793 };
794 snprintf(string, AUTOPAS_MPI_MAX_ERROR_STRING, "%s", errorStrings.at(errorcode));
795 *resultlen = strnlen(string, AUTOPAS_MPI_MAX_ERROR_STRING);
796 return AUTOPAS_MPI_SUCCESS;
797}
798
799inline int AutoPas_MPI_Comm_size(AutoPas_MPI_Comm comm, int *size) {
800 if (nullptr == size) {
801 return AUTOPAS_MPI_ERR_ARG;
802 }
803 *size = 1;
804 return AUTOPAS_MPI_SUCCESS;
805}
806
807inline int AutoPas_MPI_Comm_rank(AutoPas_MPI_Comm comm, int *rank) {
808 if (nullptr == rank) {
809 return AUTOPAS_MPI_ERR_ARG;
810 }
811 *rank = 0;
812 return AUTOPAS_MPI_SUCCESS;
813}
814
816 *newComm = comm;
817 return AUTOPAS_MPI_SUCCESS;
818}
819
821 *comm = AUTOPAS_MPI_COMM_NULL;
822 return AUTOPAS_MPI_SUCCESS;
823}
824
825inline int AutoPas_MPI_Send(const void *buf, int count, AutoPas_MPI_Datatype datatype, int dest, int tag,
826 AutoPas_MPI_Comm comm) {
827 return AUTOPAS_MPI_SUCCESS;
828}
829
830inline int AutoPas_MPI_Recv(void *buf, int count, AutoPas_MPI_Datatype datatype, int source, int tag,
831 AutoPas_MPI_Comm comm, AutoPas_MPI_Status *status) {
832 // if source==0 there is an error, because you cannot receive from yourself
833 // if source >0 there is an error, because there only exists one process
834 return AUTOPAS_MPI_ERR_RANK;
835}
836
837inline int AutoPas_MPI_Bcast(void *buffer, int count, AutoPas_MPI_Datatype datatype, int root, AutoPas_MPI_Comm comm) {
838 if (root > 0) {
839 return AUTOPAS_MPI_ERR_RANK;
840 } else {
841 return AUTOPAS_MPI_SUCCESS;
842 }
843}
844
845inline int AutoPas_MPI_Ibcast(void *buffer, int count, AutoPas_MPI_Datatype datatype, int root, AutoPas_MPI_Comm comm,
846 AutoPas_MPI_Request *request) {
847 if (root > 0) {
848 *request = REQUEST_NULL;
849 return AUTOPAS_MPI_ERR_RANK;
850 } else {
851 *request = COMPLETED_REQUEST;
852 return AUTOPAS_MPI_SUCCESS;
853 }
854}
855
856inline int AutoPas_MPI_Reduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
857 AutoPas_MPI_Op op, int root, AutoPas_MPI_Comm comm) {
858 if (sendbuf != AUTOPAS_MPI_IN_PLACE) {
859 memcpy(recvbuf, sendbuf, datatype * static_cast<size_t>(count));
860 }
861 return AUTOPAS_MPI_SUCCESS;
862}
863
864inline int AutoPas_MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
866 return AutoPas_MPI_Reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
867}
868
869inline int AutoPas_MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype,
871 *request = COMPLETED_REQUEST;
872 return AutoPas_MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm);
873}
874
875inline int AutoPas_MPI_Barrier(AutoPas_MPI_Comm comm) { return AUTOPAS_MPI_SUCCESS; }
876
878 *request = COMPLETED_REQUEST;
879 return AUTOPAS_MPI_SUCCESS;
880}
881
882inline int AutoPas_MPI_Test(AutoPas_MPI_Request *request, int *flag, AutoPas_MPI_Status *status) {
883 *request = REQUEST_NULL;
884 *flag = 1;
885 return AUTOPAS_MPI_SUCCESS;
886}
887
889 *request = REQUEST_NULL;
890 return AUTOPAS_MPI_SUCCESS;
891}
892
894 if (*request != COMPLETED_REQUEST) {
895 return AUTOPAS_MPI_ERR_REQUEST;
896 } else {
897 *request = REQUEST_NULL;
898 return AUTOPAS_MPI_SUCCESS;
899 }
900}
901
902inline int AutoPas_MPI_Gather(const void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
903 void *buffer_recv, int count_recv, AutoPas_MPI_Datatype datatype_recv, int root,
904 AutoPas_MPI_Comm comm) {
905 // in the non-MPI case this is equivalent to Allgather since there should be only one rank
906 if (root != 0) {
907 return AUTOPAS_MPI_ERR_ROOT;
908 }
909 // if MPI_IN_PLACE is passed nothing has to be done since everything is already in the receive buffer.
910 if (buffer_send != AUTOPAS_MPI_IN_PLACE) {
911 for (long i = 0; i < (count_recv / count_send); i++)
912 // offsets from pointers are of type ptrdiff_t which is an alias for long. Hence, i should be long.
913 memcpy(static_cast<char *>(buffer_recv) + (i * count_send * sizeof(datatype_send)), buffer_send,
914 count_send * sizeof(datatype_send));
915 }
916 return AUTOPAS_MPI_SUCCESS;
917}
918
919inline int AutoPas_MPI_Gatherv(const void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
920 void *buffer_recv, const int *count_recv, const int *displs,
921 AutoPas_MPI_Datatype datatype_recv, int root, AutoPas_MPI_Comm comm) {
922 return AutoPas_MPI_Gather(buffer_send, count_send, datatype_send,
923 // get offset address : receive buffer + displacement[0] * sizeof(receiveType)
924 static_cast<char *>(buffer_recv) + static_cast<std::ptrdiff_t>(displs[0] * datatype_recv),
925 count_recv[0], datatype_recv, root, comm);
926}
927
928inline int AutoPas_MPI_Allgather(void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send,
929 void *buffer_recv, int count_recv, AutoPas_MPI_Datatype datatype_recv,
930 AutoPas_MPI_Comm comm) {
931 return AutoPas_MPI_Gather(buffer_send, count_send, datatype_send, buffer_recv, count_recv, datatype_recv, 0, comm);
932}
933
934inline int AutoPas_MPI_Comm_split(AutoPas_MPI_Comm old_communicator, int color, int key,
935 AutoPas_MPI_Comm *new_communicator) {
936 *new_communicator = old_communicator;
937 return AUTOPAS_MPI_SUCCESS;
938}
939
940inline int AutoPas_MPI_Cart_create(AutoPas_MPI_Comm comm, int nDims, const int *dims, const int *periods, int reorder,
941 AutoPas_MPI_Comm *comm_cart) {
942 *comm_cart = AUTOPAS_MPI_COMM_WORLD;
943 return AUTOPAS_MPI_SUCCESS;
944}
945
946inline int AutoPas_MPI_Cart_get(AutoPas_MPI_Comm comm, int maxdims, int dims[], int periods[], int coords[]) {
947 return AUTOPAS_MPI_SUCCESS;
948}
949
950inline int AutoPas_MPI_Cart_coords(AutoPas_MPI_Comm comm, int rank, int maxdims, int coords[]) {
951 for (int i = 0; i < maxdims; ++i) {
952 coords[i] = 0;
953 }
954 return AUTOPAS_MPI_SUCCESS;
955}
956
957inline int AutoPas_MPI_Cart_rank(AutoPas_MPI_Comm comm, const int coords[], int *rank) {
958 *rank = 0;
959 return AUTOPAS_MPI_SUCCESS;
960}
961
962inline int AutoPas_MPI_Dims_create(int nnodes, int ndims, int dims[]) {
963 // in non-MPI case nnodes should always be 1. Therefore there is one rank in every dim.
964 for (int i = 0; i < ndims; ++i) {
965 dims[i] = 1;
966 }
967 return AUTOPAS_MPI_SUCCESS;
968}
969
970inline int AutoPas_MPI_Isend(const void *buf, int count, AutoPas_MPI_Datatype datatype, int dest, int tag,
971 AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request) {
972 return AUTOPAS_MPI_SUCCESS;
973}
974
975inline int AutoPas_MPI_Irecv(void *buf, int count, AutoPas_MPI_Datatype datatype, int source, int tag,
976 AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request) {
977 return AUTOPAS_MPI_SUCCESS;
978}
979
980inline int AutoPas_MPI_Probe(int source, int tag, AutoPas_MPI_Comm comm, AutoPas_MPI_Status *status) {
981 return AUTOPAS_MPI_SUCCESS;
982}
983
984inline int AutoPas_MPI_Get_count(const AutoPas_MPI_Status *status, AutoPas_MPI_Datatype datatype, int *count) {
985 *count = 0;
986 return AUTOPAS_MPI_SUCCESS;
987}
988
989inline int AutoPas_MPI_Waitall(int count, AutoPas_MPI_Request array_of_requests[],
990 AutoPas_MPI_Status *array_of_statuses) {
991 return AUTOPAS_MPI_SUCCESS;
992}
993#endif
994} // namespace autopas
#define AUTOPAS_MPI_IN_PLACE
Indicator for Collectives to happen in-place.
Definition: WrapMPI.h:254
#define AUTOPAS_MPI_COMM_NULL
Wrapper for MPI_COMM_NULL.
Definition: WrapMPI.h:118
#define AUTOPAS_MPI_MAX_ERROR_STRING
Dummy for MPI_MAX_ERROR_STRING.
Definition: WrapMPI.h:252
#define AUTOPAS_MPI_COMM_WORLD
Wrapper for MPI_COMM_WORLD.
Definition: WrapMPI.h:120
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
int AutoPas_MPI_Probe(int source, int tag, AutoPas_MPI_Comm comm, AutoPas_MPI_Status *status)
Wrapper for MPI_Probe.
Definition: WrapMPI.h:980
int AutoPas_MPI_Request_free(AutoPas_MPI_Request *request)
Wrapper for MPI_Request_free.
Definition: WrapMPI.h:893
int AutoPas_MPI_Test(AutoPas_MPI_Request *request, int *flag, AutoPas_MPI_Status *status)
Wrapper for MPI_Test.
Definition: WrapMPI.h:882
int AutoPas_MPI_Ibcast(void *buffer, int count, AutoPas_MPI_Datatype datatype, int root, AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request)
Wrapper for MPI_Ibcast.
Definition: WrapMPI.h:845
int AutoPas_MPI_Cart_get(AutoPas_MPI_Comm comm, int maxdims, int dims[], int periods[], int coords[])
Wrapper for MPI_Cart_get.
Definition: WrapMPI.h:946
int AutoPas_MPI_Finalized(int *flag)
Wrapper for MPI_Finalized.
Definition: WrapMPI.h:765
int AutoPas_MPI_Error_string(int errorcode, char *string, int *resultlen)
Wrapper for MPI_Error_string.
Definition: WrapMPI.h:770
int AutoPas_MPI_Isend(const void *buf, int count, AutoPas_MPI_Datatype datatype, int dest, int tag, AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request)
Wrapper for MPI_Isend.
Definition: WrapMPI.h:970
int AutoPas_MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype, AutoPas_MPI_Op op, AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request)
Wrapper for MPI_Iallreduce.
Definition: WrapMPI.h:869
int AutoPas_MPI_Gather(const void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send, void *buffer_recv, int count_recv, AutoPas_MPI_Datatype datatype_recv, int root, AutoPas_MPI_Comm comm)
Wrapper for MPI_Gather.
Definition: WrapMPI.h:902
int AutoPas_MPI_Wait(AutoPas_MPI_Request *request, AutoPas_MPI_Status *status)
Wrapper for MPI_Wait.
Definition: WrapMPI.h:888
int AutoPas_MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype, AutoPas_MPI_Op op, AutoPas_MPI_Comm comm)
Wrapper for MPI_Allreduce.
Definition: WrapMPI.h:864
int AutoPas_MPI_Cart_rank(AutoPas_MPI_Comm comm, const int coords[], int *rank)
Wrapper for MPI_Cart_rank Determines process rank in communicator given Cartesian location.
Definition: WrapMPI.h:957
int AutoPas_MPI_Irecv(void *buf, int count, AutoPas_MPI_Datatype datatype, int source, int tag, AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request)
Wrapper for MPI_Irecv.
Definition: WrapMPI.h:975
int AutoPas_MPI_Finalize()
Wrapper for MPI_Finalize Also frees the AutoPas communicator, so it needs to be called if AutoPas_MPI...
Definition: WrapMPI.h:763
int AutoPas_MPI_Bcast(void *buffer, int count, AutoPas_MPI_Datatype datatype, int root, AutoPas_MPI_Comm comm)
Wrapper for MPI_Bcast.
Definition: WrapMPI.h:837
int AutoPas_MPI_Send(const void *buf, int count, AutoPas_MPI_Datatype datatype, int dest, int tag, AutoPas_MPI_Comm comm)
Wrapper for MPI_Send.
Definition: WrapMPI.h:825
int AutoPas_MPI_Comm_size(AutoPas_MPI_Comm comm, int *size)
Wrapper for MPI_Comm_size.
Definition: WrapMPI.h:799
int AutoPas_MPI_Cart_create(AutoPas_MPI_Comm comm, int nDims, const int *dims, const int *periods, int reorder, AutoPas_MPI_Comm *comm_cart)
Wrapper for MPI_Cart_create.
Definition: WrapMPI.h:940
int AutoPas_MPI_Allgather(void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send, void *buffer_recv, int count_recv, AutoPas_MPI_Datatype datatype_recv, AutoPas_MPI_Comm comm)
Wrapper for MPI_Allgather.
Definition: WrapMPI.h:928
int AutoPas_MPI_Get_count(const AutoPas_MPI_Status *status, AutoPas_MPI_Datatype datatype, int *count)
Wrapper for MPI_Get_count.
Definition: WrapMPI.h:984
AutoPas_MPI_Error
Dummy for MPI_Error.
Definition: WrapMPI.h:228
int AutoPas_MPI_Gatherv(const void *buffer_send, int count_send, AutoPas_MPI_Datatype datatype_send, void *buffer_recv, const int *count_recv, const int *displs, AutoPas_MPI_Datatype datatype_recv, int root, AutoPas_MPI_Comm comm)
Wrapper for MPI_Gatherv.
Definition: WrapMPI.h:919
int AutoPas_MPI_Reduce(const void *sendbuf, void *recvbuf, int count, AutoPas_MPI_Datatype datatype, AutoPas_MPI_Op op, int root, AutoPas_MPI_Comm comm)
Wrapper for MPI_Reduce.
Definition: WrapMPI.h:856
int AutoPas_MPI_Comm_dup(AutoPas_MPI_Comm comm, AutoPas_MPI_Comm *newComm)
Wrapper for MPI_Comm_dup.
Definition: WrapMPI.h:815
int AutoPas_MPI_Ibarrier(AutoPas_MPI_Comm comm, AutoPas_MPI_Request *request)
Wrapper for MPI_Ibarrier.
Definition: WrapMPI.h:877
int AutoPas_MPI_Barrier(AutoPas_MPI_Comm comm)
Wrapper for MPI_Barrier.
Definition: WrapMPI.h:875
int AutoPas_MPI_Init(int *argc, char ***argv)
Wrapper for MPI_Init Also defines the AutoPas communicator, so it needs to be called when AutoPas sho...
Definition: WrapMPI.h:761
AutoPas_MPI_Comm
Dummy for MPI_Comm.
Definition: WrapMPI.h:113
int AutoPas_MPI_Comm_free(AutoPas_MPI_Comm *comm)
Wrapper for MPI_Comm_free.
Definition: WrapMPI.h:820
AutoPas_MPI_Op
Dummy for MPI_Op.
Definition: WrapMPI.h:163
int AutoPas_MPI_Comm_rank(AutoPas_MPI_Comm comm, int *rank)
Wrapper for MPI_Comm_rank.
Definition: WrapMPI.h:807
int AutoPas_MPI_Comm_split(AutoPas_MPI_Comm old_communicator, int color, int key, AutoPas_MPI_Comm *new_communicator)
Wrapper for MPI_Comm_split.
Definition: WrapMPI.h:934
int AutoPas_MPI_Dims_create(int nnodes, int ndims, int dims[])
Wrapper for MPI_Dims_create.
Definition: WrapMPI.h:962
AutoPas_MPI_Request
Dummy for MPI_Request.
Definition: WrapMPI.h:217
AutoPas_MPI_Datatype
Dummy for MPI_Datatype.
Definition: WrapMPI.h:126
int AutoPas_MPI_Cart_coords(AutoPas_MPI_Comm comm, int rank, int maxdims, int coords[])
Wrapper for MPI_Cart_coords Determines process coords in cartesian topology given rank in group.
Definition: WrapMPI.h:950
int AutoPas_MPI_Waitall(int count, AutoPas_MPI_Request array_of_requests[], AutoPas_MPI_Status *array_of_statuses)
Wrapper for MPI_Waitall.
Definition: WrapMPI.h:989
int AutoPas_MPI_Recv(void *buf, int count, AutoPas_MPI_Datatype datatype, int source, int tag, AutoPas_MPI_Comm comm, AutoPas_MPI_Status *status)
Wrapper for MPI_Recv.
Definition: WrapMPI.h:830
Dummy for MPI_Status.
Definition: WrapMPI.h:208
int count
additional field that the MPI standard does not necessitate, but that is often used in implementation...
Definition: WrapMPI.h:209
int AUTOPAS_MPI_ERROR
Dummy for MPI_Status::MPI_ERROR.
Definition: WrapMPI.h:209
int cancelled
additional field that the MPI standard does not necessitate, but that is often used in implementation...
Definition: WrapMPI.h:209
int AUTOPAS_MPI_TAG
Dummy for MPI_Status::MPI_TAG.
Definition: WrapMPI.h:209
int AUTOPAS_MPI_SOURCE
Dummy for MPI_Status::MPI_SOURCE.
Definition: WrapMPI.h:209