Skip to content

Commit

Permalink
test: convert some coll tests to test function
Browse files Browse the repository at this point in the history
Convert all tests used in testlist.cvar to mpitests framework.
  • Loading branch information
hzhou committed Nov 18, 2024
1 parent f5b87fa commit 0c7f2f3
Show file tree
Hide file tree
Showing 65 changed files with 576 additions and 611 deletions.
3 changes: 1 addition & 2 deletions test/mpi/coll/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
##

include $(top_srcdir)/Makefile_single.mtest
include Makefile_mpitests.mk

EXTRA_DIST = testlist.in

Expand Down Expand Up @@ -143,8 +144,6 @@ noinst_PROGRAMS = \
allgather_gpu \
allgatherv_gpu

allgatherv4_LDADD = $(LDADD) -lm

bcast_CPPFLAGS = $(AM_CPPFLAGS)
bcast_SOURCES = bcast.c

Expand Down
15 changes: 7 additions & 8 deletions test/mpi/coll/allgather2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
* See COPYRIGHT in top-level directory
*/

#include "mpi.h"
#include "mpitest.h"
#include <stdlib.h>
#include <stdio.h>

#ifdef MULTI_TESTS
#define run coll_allgather2
int run(const char *arg);
#endif

/* Tests Allgather on array of doubles. Use IN_PLACE */

int main(int argc, char **argv)
int run(const char *arg)
{
double *vecout;
MPI_Comm comm;
int count, minsize = 2;
int i, errs = 0;
int rank, size;

MTest_Init(&argc, &argv);

while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
if (comm == MPI_COMM_NULL)
continue;
Expand Down Expand Up @@ -48,6 +48,5 @@ int main(int argc, char **argv)
MTestFreeComm(&comm);
}

MTest_Finalize(errs);
return MTestReturnValue(errs);
return errs;
}
15 changes: 7 additions & 8 deletions test/mpi/coll/allgather3.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
* See COPYRIGHT in top-level directory
*/

#include "mpi.h"
#include "mpitest.h"
#include <stdlib.h>
#include <stdio.h>

#ifdef MULTI_TESTS
#define run coll_allgather3
int run(const char *arg);
#endif

/* Tests Allgather on array of doubles. Same as allgather2 test
* but without MPI_IN_PLACE. */

int main(int argc, char **argv)
int run(const char *arg)
{
double *vecout, *invec;
MPI_Comm comm;
int count, minsize = 2;
int i, errs = 0;
int rank, size;

MTest_Init(&argc, &argv);

while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
if (comm == MPI_COMM_NULL)
continue;
Expand Down Expand Up @@ -54,6 +54,5 @@ int main(int argc, char **argv)
/* Do a zero byte gather */
MPI_Allgather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, NULL, 0, MPI_BYTE, MPI_COMM_WORLD);

MTest_Finalize(errs);
return MTestReturnValue(errs);
return errs;
}
15 changes: 7 additions & 8 deletions test/mpi/coll/allgatherv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
* See COPYRIGHT in top-level directory
*/

#include "mpi.h"
#include "mpitest.h"
#include <stdlib.h>
#include <stdio.h>

#ifdef MULTI_TESTS
#define run coll_allgatherv2
int run(const char *arg);
#endif

/* Test Allgatherv on array of doubles. Use IN_PLACE. This is
the trivial version based on the allgather2 test (allgatherv but with
constant data sizes) */

int main(int argc, char **argv)
int run(const char *arg)
{
double *vecout;
MPI_Comm comm;
Expand All @@ -21,8 +23,6 @@ int main(int argc, char **argv)
int rank, size;
int *displs, *recvcounts;

MTest_Init(&argc, &argv);

while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
if (comm == MPI_COMM_NULL)
continue;
Expand Down Expand Up @@ -61,6 +61,5 @@ int main(int argc, char **argv)
MTestFreeComm(&comm);
}

MTest_Finalize(errs);
return MTestReturnValue(errs);
return errs;
}
15 changes: 7 additions & 8 deletions test/mpi/coll/allgatherv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
* See COPYRIGHT in top-level directory
*/

#include "mpi.h"
#include "mpitest.h"
#include <stdlib.h>
#include <stdio.h>

#ifdef MULTI_TESTS
#define run coll_allgatherv3
int run(const char *arg);
#endif

/* Test Allgatherv on array of doubles, same as allgatherv2 but without
* MPI_IN_PLACE. This is the trivial version based on the allgather3
* test (allgatherv but with constant data sizes) */

int main(int argc, char **argv)
int run(const char *arg)
{
double *vecout, *invec;
MPI_Comm comm;
Expand All @@ -21,8 +23,6 @@ int main(int argc, char **argv)
int rank, size;
int *displs, *recvcounts;

MTest_Init(&argc, &argv);

while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
if (comm == MPI_COMM_NULL)
continue;
Expand Down Expand Up @@ -61,6 +61,5 @@ int main(int argc, char **argv)
MTestFreeComm(&comm);
}

MTest_Finalize(errs);
return MTestReturnValue(errs);
return errs;
}
29 changes: 14 additions & 15 deletions test/mpi/coll/allgatherv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
* See COPYRIGHT in top-level directory
*/

#include "mpi.h"
#include "mpitest.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <time.h>
#include <math.h>
#include <assert.h>

#ifdef MULTI_TESTS
#define run coll_allgatherv4
int run(const char *arg);
#endif

/* FIXME: What is this test supposed to accomplish? */

#define START_BUF (1)
Expand All @@ -23,9 +25,9 @@
#define MAX_BUF (128 * 1024 * 1024)
#define LOOPS 10

char *sbuf, *rbuf;
int *recvcounts, *displs;
int errs = 0;
static char *sbuf, *rbuf;
static int *recvcounts, *displs;
static int errs = 0;

typedef enum {
REGULAR,
Expand All @@ -36,15 +38,14 @@ typedef enum {
BELL_CURVE
} test_t;

void comm_tests(MPI_Comm comm);
double run_test(long long msg_size, MPI_Comm comm, test_t test_type, double *max_time);
static void comm_tests(MPI_Comm comm);
static double run_test(long long msg_size, MPI_Comm comm, test_t test_type, double *max_time);

int main(int argc, char **argv)
int run(const char *arg)
{
int comm_size, comm_rank;
MPI_Comm comm;

MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);

Expand Down Expand Up @@ -118,12 +119,10 @@ int main(int argc, char **argv)
free(displs);

fn_exit:
MTest_Finalize(errs);

return MTestReturnValue(errs);
return errs;
}

void comm_tests(MPI_Comm comm)
static void comm_tests(MPI_Comm comm)
{
int comm_size, comm_rank;
double rtime, max_time;
Expand Down Expand Up @@ -169,7 +168,7 @@ void comm_tests(MPI_Comm comm)
}
}

double run_test(long long msg_size, MPI_Comm comm, test_t test_type, double *max_time)
static double run_test(long long msg_size, MPI_Comm comm, test_t test_type, double *max_time)
{
int i, j;
int comm_size, comm_rank;
Expand Down
22 changes: 8 additions & 14 deletions test/mpi/coll/allred.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
*/

#include "mpitest.h"
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif

#include "mtest_dtp.h"
/* For simplicity, we precalculate solutions in integers. Use "long" type
* to prevent intermediate overflows, especially during get_pow(). On the
Expand All @@ -25,6 +17,11 @@
*/
#define LONG long long

#ifdef MULTI_TESTS
#define run coll_allred
int run(const char *arg);
#endif

struct int_test {
int a;
int b;
Expand Down Expand Up @@ -705,12 +702,10 @@ static int test_allred(mtest_mem_type_e evenmem, mtest_mem_type_e oddmem)
return errs;
}

int main(int argc, char **argv)
int run(const char *arg)
{
int errs = 0;

MTest_Init(&argc, &argv);

MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);

Expand All @@ -720,13 +715,12 @@ int main(int argc, char **argv)
}

struct dtp_args dtp_args;
dtp_args_init(&dtp_args, MTEST_COLL_COUNT, argc, argv);
dtp_args_init_arg(&dtp_args, MTEST_COLL_COUNT, arg);
while (dtp_args_get_next(&dtp_args)) {
count = dtp_args.count;
errs += test_allred(dtp_args.u.coll.evenmem, dtp_args.u.coll.oddmem);
}
dtp_args_finalize(&dtp_args);

MTest_Finalize(errs);
return MTestReturnValue(errs);
return errs;
}
16 changes: 8 additions & 8 deletions test/mpi/coll/allred2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
*/

#include "mpitest.h"
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include "mtest_dtp.h"

#ifdef MULTI_TESTS
#define run coll_allred2
int run(const char *arg);
#endif

/*
static char MTEST_Descrip[] = "Test MPI_Allreduce with MPI_IN_PLACE";
*/
Expand Down Expand Up @@ -76,18 +78,16 @@ static int test_allred(mtest_mem_type_e oddmem, mtest_mem_type_e evenmem)
return errs;
}

int main(int argc, char *argv[])
int run(const char *arg)
{
int errs = 0;
MTest_Init(&argc, &argv);

struct dtp_args dtp_args;
dtp_args_init(&dtp_args, MTEST_COLL_NOCOUNT, argc, argv);
dtp_args_init_arg(&dtp_args, MTEST_COLL_NOCOUNT, arg);
while (dtp_args_get_next(&dtp_args)) {
errs += test_allred(dtp_args.u.coll.evenmem, dtp_args.u.coll.oddmem);
}
dtp_args_finalize(&dtp_args);

MTest_Finalize(errs);
return MTestReturnValue(errs);
return errs;
}
Loading

0 comments on commit 0c7f2f3

Please sign in to comment.