SST  15.1.0
StructuralSimulationToolkit
sst_mpi.h
1 // Copyright 2009-2025 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2025, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_SST_MPI_H
13 #define SST_CORE_SST_MPI_H
14 
15 #include "warnmacros.h"
16 
17 #ifdef SST_CONFIG_HAVE_MPI
18 
19 DISABLE_WARN_MISSING_OVERRIDE
20 DISABLE_WARN_CAST_FUNCTION_TYPE
21 
22 #include <mpi.h>
23 
24 REENABLE_WARNING
25 REENABLE_WARNING
26 
27 #define UNUSED_WO_MPI(x) x
28 
29 #else
30 
31 #define UNUSED_WO_MPI(x) UNUSED(x)
32 
33 #endif
34 
35 /*************************************************************************
36  Make it so that we can do simple MPI functions without having to
37  guard using SST_CONFIG_HAVE_MPI. This will include SST_MPI_*
38  versions of the supported operations, as well as definitions for
39  some of the MPI types
40  *************************************************************************/
41 
43 {
44  short val;
45  int rank;
46 };
47 
49 {
50  long val;
51  int rank;
52 };
53 
55 {
56  double val;
57  int rank;
58 };
59 
61 {
62  double val;
63  int rank;
64 };
65 
66 #ifndef SST_CONFIG_HAVE_MPI
67 
68 // Define some MPI types and some of the values for those types
69 #define MPI_Datatype int
70 #define MPI_Op int
71 #define MPI_Comm int
72 
73 #define MPI_COMM_WORLD 0
74 
75 // MPI_datatype values. These will just be set to the sizeof() the represented type
76 
77 #define MPI_SIGNED_CHAR (sizeof(signed char))
78 #define MPI_UNSIGNED_CHAR (sizeof(unsigned char))
79 #define MPI_SHORT (sizeof(short))
80 #define MPI_UNSIGNED_SHORT (sizeof(unsigned short))
81 #define MPI_INT (sizeof(int))
82 #define MPI_UNSIGNED (sizeof(unsigned))
83 #define MPI_LONG (sizeof(long))
84 #define MPI_UNSIGNED_LONG (sizeof(unsigned long))
85 // MPI_LONG_LONG_INT (a.k.a MPI_LONG_LONG) / MPI_UNSIGNED_LONG_LONG
86 #define MPI_CHAR (sizeof(char))
87 #define MPI_WCHAR (sizeof(wchar))
88 #define MPI_FLOAT (sizeof(float))
89 #define MPI_DOUBLE (sizeof(double))
90 // MPI_LONG_DOUBLE
91 #define MPI_INT8_T (sizeof(int8_t))
92 #define MPI_UINT8_T (sizeof(uint8_t))
93 #define MPI_INT16_T (sizeof(int16_t))
94 #define MPI_UINT16_T (sizeof(uint16_t))
95 #define MPI_INT32_T (sizeof(int32_t))
96 #define MPI_UINT32_T (sizeof(uint32_t))
97 #define MPI_INT64_T (sizeof(int64_t))
98 #define MPI_UINT64_T (sizeof(uint64_t))
99 #define MPI_C_BOOL
100 // MPI_C_COMPLEX
101 // MPI_C_FLOAT_COMPLEX
102 // MPI_C_DOUBLE_COMPLEX
103 // MPI_C_LONG_DOUBLE_COMPLEX
104 // MPI_AINT
105 // MPI_COUNT
106 // MPI_OFFSET
107 // MPI_BYTE
108 // MPI_PACKED
109 
110 // List of datatypes for reduction functions MPI_MINLOC and MPI_MAXLOC:
111 #define MPI_SHORT_INT (sizeof(mpi_short_int_t))
112 #define MPI_LONG_INT (sizeof(mpi_long_int_t))
113 #define MPI_FLOAT_INT (sizeof(mpi_float_int_t))
114 #define MPI_DOUBLE_INT (sizeof(mpi_double_int_t))
115 // MPI_LONG_DOUBLE_INT
116 // MPI_2INT
117 
118 // Allreduce operations. Numbers are unused because they are all
119 // no-ops in the case of MPI
120 #define MPI_SUM 0
121 #define MPI_MAX 0
122 #define MPI_MIN 0
123 #define MPI_MAXLOC 0
124 #define MPI_MINLOC 0
125 
126 #endif
127 
128 // Verions of typical MPI functions that will hide the
129 // SST_CONFIG_HAVE_MPI macros
130 
131 int SST_MPI_Allreduce(const void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
132 int SST_MPI_Barrier(MPI_Comm comm);
133 int SST_MPI_Allgather(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
134  MPI_Datatype recvtype, MPI_Comm comm);
135 
136 #endif
Definition: sst_mpi.h:48
Definition: sst_mpi.h:54
Definition: sst_mpi.h:42
Definition: sst_mpi.h:60