Skip to content

Commit f650d3c

Browse files
committed
libompitrace: handle MPI_DATATYPE_NULL
Ensure to check for MPI_DATATYPE_NULL before calling PMPI_Type_get_name(). As of MPI-4.0, there's still at least some disagreement as to whether MPI_DATATYPE_NULL is a valid input parameter for MPI_TYPE_GET_NAME. While that discussion is ongoing, fix up libompitrace to do what is guaranteed to work. Signed-off-by: Jeff Squyres <[email protected]>
1 parent 580984b commit f650d3c

File tree

9 files changed

+75
-21
lines changed

9 files changed

+75
-21
lines changed

ompi/contrib/libompitrace/allgather.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2007-2022 Cisco Systems, Inc. All rights reserved
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* $COPYRIGHT$
@@ -38,8 +38,18 @@ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
3838
int rank;
3939

4040
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
41-
PMPI_Type_get_name(sendtype, sendtypename, &len);
42-
PMPI_Type_get_name(recvtype, recvtypename, &len);
41+
if (sendtype != MPI_DATATYPE_NULL) {
42+
PMPI_Type_get_name(sendtype, sendtypename, &len);
43+
} else {
44+
strncpy(sendtypename, "MPI_DATATYPE_NULL",
45+
sizeof(sendtypename));
46+
}
47+
if (recvtype != MPI_DATATYPE_NULL) {
48+
PMPI_Type_get_name(recvtype, recvtypename, &len);
49+
} else {
50+
strncpy(recvtypename, "MPI_DATATYPE_NULL",
51+
sizeof(recvtypename));
52+
}
4353
PMPI_Comm_get_name(comm, commname, &len);
4454

4555
fprintf(stderr, "MPI_ALLGATHER[%d]: sendbuf %0" PRIxPTR " sendcount %d sendtype %s\n\trecvbuf %0" PRIxPTR " recvcount %d recvtype %s comm %s\n",

ompi/contrib/libompitrace/allgatherv.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2009-2022 Cisco Systems, Inc. All rights reserved
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* $COPYRIGHT$
@@ -38,8 +38,18 @@ int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
3838
int rank;
3939

4040
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
41-
PMPI_Type_get_name(sendtype, sendtypename, &len);
42-
PMPI_Type_get_name(recvtype, recvtypename, &len);
41+
if (sendtype != MPI_DATATYPE_NULL) {
42+
PMPI_Type_get_name(sendtype, sendtypename, &len);
43+
} else {
44+
strncpy(sendtypename, "MPI_DATATYPE_NULL",
45+
sizeof(sendtypename));
46+
}
47+
if (recvtype != MPI_DATATYPE_NULL) {
48+
PMPI_Type_get_name(recvtype, recvtypename, &len);
49+
} else {
50+
strncpy(recvtypename, "MPI_DATATYPE_NULL",
51+
sizeof(recvtypename));
52+
}
4353
PMPI_Comm_get_name(comm, commname, &len);
4454

4555
fprintf(stderr, "MPI_ALLGATHERV[%d]: sendbuf %0" PRIxPTR " sendcount %d sendtype %s\n\trecvbuf %0" PRIxPTR " recvtype %s comm %s\n",

ompi/contrib/libompitrace/allreduce.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2009-2022 Cisco Systems, Inc. All rights reserved
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* $COPYRIGHT$
@@ -36,7 +36,11 @@ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
3636
int rank;
3737

3838
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
39-
PMPI_Type_get_name(datatype, typename, &len);
39+
if (datatype != MPI_DATATYPE_NULL) {
40+
PMPI_Type_get_name(datatype, typename, &len);
41+
} else {
42+
strncpy(typename, "MPI_DATATYPE_NULL", sizeof(typename));
43+
}
4044
PMPI_Comm_get_name(comm, commname, &len);
4145

4246
fprintf(stderr, "MPI_ALLREDUCE[%d]: sendbuf %0" PRIxPTR " recvbuf %0" PRIxPTR " count %d datatype %s op %s comm %s\n",

ompi/contrib/libompitrace/bcast.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
12+
* Copyright (c) 2009-2022 Cisco Systems, Inc. All rights reserved
1313
* $COPYRIGHT$
1414
*
1515
* Additional copyrights may follow
@@ -34,7 +34,11 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
3434
int rank;
3535

3636
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
37-
PMPI_Type_get_name(datatype, typename, &len);
37+
if (datatype != MPI_DATATYPE_NULL) {
38+
PMPI_Type_get_name(datatype, typename, &len);
39+
} else {
40+
strncpy(typename, "MPI_DATATYPE_NULL", sizeof(typename));
41+
}
3842
PMPI_Comm_get_name(comm, commname, &len);
3943

4044
fprintf(stderr, "MPI_BCAST[%d]: buffer %0" PRIxPTR " count %d datatype %s root %d comm %s\n",

ompi/contrib/libompitrace/isend.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2006-2022 Cisco Systems, Inc. All rights reserved
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* $COPYRIGHT$
@@ -36,7 +36,11 @@ int MPI_Isend(const void *buf, int count, MPI_Datatype type, int dest,
3636
int rank;
3737

3838
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
39-
PMPI_Type_get_name(type, typename, &len);
39+
if (type != MPI_DATATYPE_NULL) {
40+
PMPI_Type_get_name(type, typename, &len);
41+
} else {
42+
strncpy(typename, "MPI_DATATYPE_NULL", sizeof(typename));
43+
}
4044
PMPI_Comm_get_name(comm, commname, &len);
4145

4246
fprintf(stderr, "MPI_ISEND[%d]: buf %0" PRIxPTR " count %d datatype %s dest %d tag %d comm %s\n",

ompi/contrib/libompitrace/recv.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
12+
* Copyright (c) 2009-2022 Cisco Systems, Inc. All rights reserved
1313
* $COPYRIGHT$
1414
*
1515
* Additional copyrights may follow
@@ -33,7 +33,11 @@ int MPI_Recv(void *buf, int count, MPI_Datatype type, int source,
3333
int rank;
3434

3535
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
36-
PMPI_Type_get_name(type, typename, &len);
36+
if (type != MPI_DATATYPE_NULL) {
37+
PMPI_Type_get_name(type, typename, &len);
38+
} else {
39+
strncpy(typename, "MPI_DATATYPE_NULL", sizeof(typename));
40+
}
3741
PMPI_Comm_get_name(comm, commname, &len);
3842

3943
fprintf(stderr, "MPI_RECV[%d]: buf %0" PRIxPTR " count %d datatype %s source %d tag %d comm %s\n",

ompi/contrib/libompitrace/reduce.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2006-2022 Cisco Systems, Inc. All rights reserved
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* $COPYRIGHT$
@@ -37,7 +37,11 @@ int MPI_Reduce(const void *sendbuf, void *recvbuf, int count,
3737
int rank;
3838

3939
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
40-
PMPI_Type_get_name(datatype, typename, &len);
40+
if (datatype != MPI_DATATYPE_NULL) {
41+
PMPI_Type_get_name(datatype, typename, &len);
42+
} else {
43+
strncpy(typename, "MPI_DATATYPE_NULL", sizeof(typename));
44+
}
4145
PMPI_Comm_get_name(comm, commname, &len);
4246

4347
fprintf(stderr,"MPI_REDUCE[%d]: sendbuf %0" PRIxPTR " recvbuf %0" PRIxPTR " count %d datatype %s op %s root %d comm %s\n",

ompi/contrib/libompitrace/send.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2009-2022 Cisco Systems, Inc. All rights reserved
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* $COPYRIGHT$
@@ -36,7 +36,11 @@ int MPI_Send(const void *buf, int count, MPI_Datatype type, int dest,
3636
int rank;
3737

3838
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
39-
PMPI_Type_get_name(type, typename, &len);
39+
if (type != MPI_DATATYPE_NULL) {
40+
PMPI_Type_get_name(type, typename, &len);
41+
} else {
42+
strncpy(typename, "MPI_DATATYPE_NULL", sizeof(typename));
43+
}
4044
PMPI_Comm_get_name(comm, commname, &len);
4145

4246
fprintf(stderr, "MPI_SEND[%d]: : buf %0" PRIxPTR " count %d datatype %s dest %d tag %d comm %s\n",

ompi/contrib/libompitrace/sendrecv.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2009-2022 Cisco Systems, Inc. All rights reserved
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* $COPYRIGHT$
@@ -41,8 +41,18 @@ int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
4141
int size;
4242

4343
PMPI_Comm_rank(MPI_COMM_WORLD, &rank);
44-
PMPI_Type_get_name(sendtype, sendtypename, &len);
45-
PMPI_Type_get_name(sendtype, recvtypename, &len);
44+
if (sendtype != MPI_DATATYPE_NULL) {
45+
PMPI_Type_get_name(sendtype, sendtypename, &len);
46+
} else {
47+
strncpy(sendtypename, "MPI_DATATYPE_NULL",
48+
sizeof(sendtypename));
49+
}
50+
if (recvtype != MPI_DATATYPE_NULL) {
51+
PMPI_Type_get_name(recvtype, recvtypename, &len);
52+
} else {
53+
strncpy(recvtypename, "MPI_DATATYPE_NULL",
54+
sizeof(recvtypename));
55+
}
4656
PMPI_Comm_get_name(comm, commname, &len);
4757
PMPI_Type_size(recvtype, &size);
4858

0 commit comments

Comments
 (0)