Skip to content

Commit 7d24ccf

Browse files
committed
test: add allreduce test of MPIX_BFLOAT16
1 parent db50fcd commit 7d24ccf

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

test/mpi/configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,16 @@ AC_CACHE_CHECK([whether long long is supported],pac_cv_have_long_long,[
723723
if test "$pac_cv_have_long_long" = yes ; then
724724
AC_DEFINE(HAVE_LONG_LONG,1,[Define if compiler supports long long])
725725
fi
726+
727+
#
728+
# Check for _Float16
729+
AC_MSG_CHECKING([whether _Float16 is supported])
730+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[_Float16 a;])],[pac_cv_have_float16=yes],[pac_cv_have_float16=no])
731+
AC_MSG_RESULT($pac_cv_have_float16)
732+
if test "$pac_cv_have_float16" = "yes" ; then
733+
AC_DEFINE(HAVE_FLOAT16,1,[Define if _Float16 is supported])
734+
fi
735+
726736
#
727737
# Check for const and restrict (used in some of the performance tests)
728738
AC_C_CONST

test/mpi/impls/mpich/misc/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ EXTRA_DIST = testlist
1212
## correctly
1313
noinst_PROGRAMS = \
1414
type_iov \
15+
type_float16 \
1516
gpu_query

test/mpi/impls/mpich/misc/testlist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
gpu_query 1
2+
type_float16 4
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (C) by Argonne National Laboratory
3+
* See COPYRIGHT in top-level directory
4+
*/
5+
6+
#include "mpitest.h"
7+
#include <stdio.h>
8+
#include <stdlib.h>
9+
#include <assert.h>
10+
11+
#define N 4
12+
MPI_Comm comm = MPI_COMM_WORLD;
13+
14+
int main(int argc, char *argv[])
15+
{
16+
int errs = 0;
17+
MTest_Init(&argc, &argv);
18+
19+
/* Test MPIX_BFLOAT16 */
20+
unsigned short buf[N];
21+
for (int i = 0; i < N; i++) {
22+
buf[i] = 0x3f80; /* 1.0 in bfloat16 */
23+
}
24+
MPI_Allreduce(MPI_IN_PLACE, buf, N, MPIX_BFLOAT16, MPI_SUM, comm);
25+
26+
MTestPrintfMsg(1, "Allreduce %d MPIX_BFLOAT16 (val=0.1), result: 0x%x, 0x%x, ...\n",
27+
N, buf[0], buf[1]);
28+
29+
/* Test MPIX_C_FLOAT16 */
30+
#ifdef HAVE_FLOAT16
31+
_Float16 buf_f16[N];
32+
for (int i = 0; i < N; i++) {
33+
buf_f16[i] = 1.0;
34+
}
35+
MPI_Allreduce(MPI_IN_PLACE, buf_f16, N, MPIX_C_FLOAT16, MPI_SUM, comm);
36+
37+
MTestPrintfMsg(1, "Allreduce %d MPIX_C_FLOAT16 (val=0.1), result: %f, %f, ...\n",
38+
N, (float) buf_f16[0], (float) buf_f16[1]);
39+
#endif
40+
41+
MTest_Finalize(errs);
42+
43+
return MTestReturnValue(errs);
44+
}

0 commit comments

Comments
 (0)