Skip to content

Commit 08740cc

Browse files
author
Patrick McNally
committed
Updates for compatibility with hdf5 1.14.6
- The MPI_Count type was defined but not the associated datatype constant (MPI_COUNT). This has been added. - Fixed the signature for MPI_Get_address() to make `location` const. - Fixed the regex used to replace 'use mpi' with 'use yogimpi' in Fortran. It required space after 'mpi', which failed to find usage where only certain symbols are imported: use mpi, only: MPI_INTEGER
1 parent dc8e9b2 commit 08740cc

File tree

7 files changed

+89
-14
lines changed

7 files changed

+89
-14
lines changed

src/WrapMPI.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ if (comm_delete_attr_keep) {manPrefix}delAttrFn(*comm_keyval, comm_delete_attr_k
10571057
</Function>
10581058
<Function name="MPI_Get_address">
10591059
<ReturnType>int</ReturnType>
1060-
<Arg input="true" name="location" type="void*"/>
1060+
<Arg input="true" name="location" type="const void*"/>
10611061
<Arg name="address" output="true" type="MPI_Aint*"/>
10621062
</Function>
10631063
<Function name="MPI_Get_count">

src/YogiManager.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ YogiManager::YogiManager() {
249249
datatypePool.at(YogiMPI_C_LONG_DOUBLE_COMPLEX) = MPI_C_LONG_DOUBLE_COMPLEX;
250250
datatypePool.at(YogiMPI_AINT) = MPI_AINT;
251251
datatypePool.at(YogiMPI_OFFSET) = MPI_OFFSET;
252+
#if YogiMPI_VERSION == 3
253+
datatypePool.at(YogiMPI_COUNT) = MPI_COUNT;
254+
#endif
252255

253256
#if YogiMPI_VERSION == 3
254257
datatypePool.at(YogiMPI_CXX_BOOL) = MPI_CXX_BOOL;

src/mpitoyogi.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@
253253

254254
#define MPI_AINT YogiMPI_AINT
255255
#define MPI_OFFSET YogiMPI_OFFSET
256+
#if YogiMPI_VERSION == 3
257+
#define MPI_COUNT YogiMPI_COUNT
258+
#endif
256259

257260
#define MPI_COMM_WORLD YogiMPI_COMM_WORLD
258261
#define MPI_COMM_SELF YogiMPI_COMM_SELF

src/yogimpi.h.in

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,26 +287,30 @@ typedef int YogiMPI_Message;
287287
/* MPI 2.2 types that are needed for MPI I/O */
288288
#define YogiMPI_AINT 45
289289
#define YogiMPI_OFFSET 46
290+
/* May be Fortran-only and not relegated to IO, but this often flocks with OFFSET. */
291+
#if YogiMPI_VERSION == 3
292+
#define YogiMPI_COUNT 47
293+
#endif
290294

291295
/* These should probably be with the above "Optional datatypes (C)", */
292296
/* but they were added later so putting them here to avoid reordering the list. */
293-
#define YogiMPI_INT8_T 47
294-
#define YogiMPI_INT16_T 48
297+
#define YogiMPI_INT8_T 48
298+
#define YogiMPI_INT16_T 49
295299

296300
/* MPI 3 defined C++ types */
297301
#if YogiMPI_VERSION == 3
298-
#define YogiMPI_CXX_BOOL 49
299-
#define YogiMPI_CXX_FLOAT_COMPLEX 50
300-
#define YogiMPI_CXX_DOUBLE_COMPLEX 51
301-
#define YogiMPI_CXX_LONG_DOUBLE_COMPLEX 52
302+
#define YogiMPI_CXX_BOOL 50
303+
#define YogiMPI_CXX_FLOAT_COMPLEX 51
304+
#define YogiMPI_CXX_DOUBLE_COMPLEX 52
305+
#define YogiMPI_CXX_LONG_DOUBLE_COMPLEX 53
302306
#endif
303307

304308
/* MPI Unsigned Integer Types. */
305309
/* I kept breaking things when I tried to weave these in earlier */
306-
#define YogiMPI_UINT8_T 53
307-
#define YogiMPI_UINT16_T 54
308-
#define YogiMPI_UINT32_T 55
309-
#define YogiMPI_UINT64_T 56
310+
#define YogiMPI_UINT8_T 54
311+
#define YogiMPI_UINT16_T 55
312+
#define YogiMPI_UINT32_T 56
313+
#define YogiMPI_UINT64_T 57
310314

311315
/* reserved communicators (C and Fortran) */
312316
#define YogiMPI_COMM_WORLD 1

test/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif
2525

2626
c2tests: simple createOp errorHandler nonBlocking probe testAll writeFile1 \
2727
waitany collective sendrecv testComms nonblock_waitall waitsome \
28-
testAttr testInfo testFileModes
28+
testAttr testInfo testFileModes types
2929

3030
c3tests: mprobe
3131

@@ -83,6 +83,9 @@ waitsome: waitsome.c
8383
testAttr: testAttr.c
8484
$(YCC) $(CFLAGS) $(DEBUGFLAGS) testAttr.c -o testAttr
8585

86+
types: types.c
87+
$(YCC) $(CFLAGS) $(DEBUGFLAGS) types.c -o types
88+
8689
runc3tests: c3tests
8790
./testRunner.sh 2 ./mprobe
8891

@@ -104,6 +107,7 @@ runc2tests: c2tests
104107
./testRunner.sh 4 ./testAttr
105108
./testRunner.sh 4 ./testInfo
106109
./testRunner.sh 2 ./testFileModes
110+
./testRunner.sh 4 ./types
107111

108112
runftests: ftests
109113
./testRunner.sh 2 ./fsimple
@@ -154,7 +158,7 @@ ftests: fwriteFile1 fsendrecv fcollective ftestComms f_gatherscatter \
154158
clean:
155159
$(RM) *.o nonBlocking sendrecv fsendrecv simple testCancelled \
156160
writeFile1 fwriteFile1 f_gatherscatter fnonblock \
157-
nonblock_waitall testComms fsimple testInfo \
161+
nonblock_waitall testComms fsimple testInfo types \
158162
ftestComms probe mprobe collective fcollective fwtick \
159163
waitsome waitany fwaitsome createOp errorHandler testAll \
160164
cWriteFile.result fWriteFile.result testAttr ftestInfo \

test/types.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Transmit data of different types using their associated datatype constants.
2+
3+
#include "mpi.h"
4+
#include <assert.h>
5+
6+
void test_INT(MPI_Comm comm, int rank, int exp) {
7+
int send = rank;
8+
int recv = -1;
9+
MPI_Allreduce(&send, &recv, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
10+
assert(recv == exp);
11+
}
12+
13+
void test_LONG(MPI_Comm comm, int rank, int exp) {
14+
long int send = rank;
15+
long int recv = -1;
16+
MPI_Allreduce(&send, &recv, 1, MPI_LONG, MPI_SUM, MPI_COMM_WORLD);
17+
assert(recv == (long int)exp);
18+
}
19+
20+
void test_FLOAT(MPI_Comm comm, int rank, int exp) {
21+
float send = (float)rank;
22+
float recv = -1.0;
23+
MPI_Allreduce(&send, &recv, 1, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
24+
assert(recv == (float)exp);
25+
}
26+
27+
void test_DOUBLE(MPI_Comm comm, int rank, int exp) {
28+
double send = (double)rank;
29+
double recv = -1.0;
30+
MPI_Allreduce(&send, &recv, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
31+
assert(recv == (double)exp);
32+
}
33+
34+
void test_COUNT(MPI_Comm comm, int rank, int exp) {
35+
MPI_Count send = (MPI_Count)rank;
36+
MPI_Count recv = -1.0;
37+
MPI_Allreduce(&send, &recv, 1, MPI_COUNT, MPI_SUM, MPI_COMM_WORLD);
38+
assert(recv == (MPI_Count)exp);
39+
}
40+
41+
int main(int argc, char *argv[]) {
42+
int rank = -1;
43+
int size = -1;
44+
MPI_Init(&argc,&argv);
45+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
46+
MPI_Comm_size(MPI_COMM_WORLD, &size);
47+
48+
int exp = 0;
49+
for (int i=0; i<size; ++i) {
50+
exp = exp + i;
51+
}
52+
53+
test_INT(MPI_COMM_WORLD, rank, exp);
54+
test_LONG(MPI_COMM_WORLD, rank, exp);
55+
test_FLOAT(MPI_COMM_WORLD, rank, exp);
56+
test_DOUBLE(MPI_COMM_WORLD, rank, exp);
57+
test_COUNT(MPI_COMM_WORLD, rank, exp);
58+
59+
MPI_Finalize();
60+
return 0;
61+
}

wrapper/YogiMPIWrapper.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class YogiMPIWrapper(object):
4040
# The regular expression to find instances of use mpi in a Fortran file.
4141
# This is a newer Fortran 90 style that deprecates the "include 'mpif.h'"
4242
# We look for both.
43-
useMPIRegEx = re.compile(r"([\s]*)use[\s]+mpi([\s]+)", re.IGNORECASE)
43+
useMPIRegEx = re.compile(r"([\s]*)use[\s]+mpi([\s]*)", re.IGNORECASE)
4444
# Regular expression to find instances of command line preprocessor
4545
# definitions which have quoted values.
4646

0 commit comments

Comments
 (0)