From 1d808c979221d56294d4282ca852fd7ae5fe4190 Mon Sep 17 00:00:00 2001 From: valentin petrov Date: Mon, 17 Jan 2022 14:05:27 +0300 Subject: [PATCH] TEST: mpi test fixes (#388) --- test/mpi/test_allgather.cc | 41 ++++++++++++------------- test/mpi/test_allgatherv.cc | 43 ++++++++++++-------------- test/mpi/test_allreduce.cc | 38 +++++++++-------------- test/mpi/test_alltoall.cc | 39 +++++++++++------------- test/mpi/test_alltoallv.cc | 36 +++++++++++----------- test/mpi/test_barrier.cc | 4 +-- test/mpi/test_bcast.cc | 23 ++++++-------- test/mpi/test_case.cc | 25 ++++++++------- test/mpi/test_mpi.h | 9 +++--- test/mpi/test_reduce.cc | 31 +++++++++---------- test/mpi/test_reduce_scatter.cc | 54 ++++++++++++++++----------------- 11 files changed, 156 insertions(+), 187 deletions(-) diff --git a/test/mpi/test_allgather.cc b/test/mpi/test_allgather.cc index be932cfccb..92876bf42a 100644 --- a/test/mpi/test_allgather.cc +++ b/test/mpi/test_allgather.cc @@ -12,11 +12,12 @@ TestAllgather::TestAllgather(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_memory_type_t _mt, ucc_test_team_t &_team, size_t _max_size) : - TestCase(_team, _mt, _msgsize, _inplace, _max_size) + TestCase(_team, UCC_COLL_TYPE_ALLGATHER, _mt, _msgsize, _inplace, _max_size) { - size_t dt_size = ucc_dt_size(TEST_DT); + size_t dt_size = ucc_dt_size(TEST_DT); size_t single_rank_count = _msgsize / dt_size; - int rank, size; + int rank, size; + MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &size); @@ -26,21 +27,17 @@ TestAllgather::TestAllgather(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, } UCC_CHECK(ucc_mc_alloc(&rbuf_mc_header, _msgsize * size, _mt)); - rbuf = rbuf_mc_header->addr; - check_rbuf = ucc_malloc(_msgsize*size, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); + rbuf = rbuf_mc_header->addr; + check_buf = ucc_malloc(_msgsize*size, "check buf"); + UCC_MALLOC_CHECK(check_buf); if (TEST_NO_INPLACE == inplace) { UCC_CHECK(ucc_mc_alloc(&sbuf_mc_header, _msgsize, _mt)); - UCC_CHECK(ucc_mc_alloc(&check_sbuf_mc_header, _msgsize, - UCC_MEMORY_TYPE_HOST)); sbuf = sbuf_mc_header->addr; - check_sbuf = check_sbuf_mc_header->addr; } else { args.mask = UCC_COLL_ARGS_FIELD_FLAGS; args.flags = UCC_COLL_ARGS_FLAG_IN_PLACE; } - args.coll_type = UCC_COLL_TYPE_ALLGATHER; if (TEST_NO_INPLACE == inplace) { args.src.info.buffer = sbuf; args.src.info.count = single_rank_count; @@ -57,22 +54,22 @@ TestAllgather::TestAllgather(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_status_t TestAllgather::set_input() { - size_t dt_size = ucc_dt_size(TEST_DT); + size_t dt_size = ucc_dt_size(TEST_DT); size_t single_rank_count = msgsize / dt_size; - size_t single_rank_size = single_rank_count * dt_size; - int rank; - void *buf, *check_buf; + size_t single_rank_size = single_rank_count * dt_size; + int rank; + void *buf, *check; MPI_Comm_rank(team.comm, &rank); if (inplace == TEST_NO_INPLACE) { - buf = sbuf; - check_buf = check_sbuf; + buf = sbuf; } else { - buf = PTR_OFFSET(rbuf, rank * single_rank_size); - check_buf = PTR_OFFSET(check_rbuf, rank * single_rank_size); + buf = PTR_OFFSET(rbuf, rank * single_rank_size); } + check = PTR_OFFSET(check_buf, rank * single_rank_size); + init_buffer(buf, single_rank_count, TEST_DT, mem_type, rank); - UCC_CHECK(ucc_mc_memcpy(check_buf, buf, single_rank_size, + UCC_CHECK(ucc_mc_memcpy(check, buf, single_rank_size, UCC_MEMORY_TYPE_HOST, mem_type)); return UCC_OK; } @@ -90,13 +87,13 @@ ucc_status_t TestAllgather::check() MPI_Datatype dt = ucc_dt_to_mpi(TEST_DT); MPI_Request req; - MPI_Iallgather(inplace ? MPI_IN_PLACE : check_sbuf, single_rank_count, dt, - check_rbuf, single_rank_count, dt, team.comm, &req); + MPI_Iallgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, + check_buf, single_rank_count, dt, team.comm, &req); do { MPI_Test(&req, &completed, MPI_STATUS_IGNORE); ucc_context_progress(team.ctx); } while(!completed); - return compare_buffers(rbuf, check_rbuf, single_rank_count * size, TEST_DT, + return compare_buffers(rbuf, check_buf, single_rank_count * size, TEST_DT, mem_type); } diff --git a/test/mpi/test_allgatherv.cc b/test/mpi/test_allgatherv.cc index bc0b1a4738..12559a4f90 100644 --- a/test/mpi/test_allgatherv.cc +++ b/test/mpi/test_allgatherv.cc @@ -36,12 +36,14 @@ static void fill_counts_and_displacements(int size, int count, TestAllgatherv::TestAllgatherv(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_memory_type_t _mt, ucc_test_team_t &_team, size_t _max_size) : - TestCase(_team, _mt, _msgsize, _inplace, _max_size) + TestCase(_team, UCC_COLL_TYPE_ALLGATHERV, _mt, _msgsize, _inplace, + _max_size) { size_t dt_size = ucc_dt_size(TEST_DT); - size_t count = _msgsize / dt_size; - int rank, size; - counts = NULL; + size_t count = _msgsize / dt_size; + int rank, size; + + counts = NULL; displacements = NULL; MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &size); @@ -56,24 +58,20 @@ TestAllgatherv::TestAllgatherv(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, displacements = (int *) ucc_malloc(size * sizeof(uint32_t), "displacements buf"); UCC_MALLOC_CHECK(displacements); UCC_CHECK(ucc_mc_alloc(&rbuf_mc_header, _msgsize * size, _mt)); - rbuf = rbuf_mc_header->addr; - check_rbuf = ucc_malloc(_msgsize*size, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); + rbuf = rbuf_mc_header->addr; + check_buf = ucc_malloc(_msgsize*size, "check buf"); + UCC_MALLOC_CHECK(check_buf); fill_counts_and_displacements(size, count, counts, displacements); if (TEST_NO_INPLACE == inplace) { args.mask = 0; UCC_CHECK(ucc_mc_alloc(&sbuf_mc_header, counts[rank] * dt_size, _mt)); - UCC_CHECK(ucc_mc_alloc(&check_sbuf_mc_header, counts[rank] * dt_size, - UCC_MEMORY_TYPE_HOST)); sbuf = sbuf_mc_header->addr; - check_sbuf = check_sbuf_mc_header->addr; } else { args.mask = UCC_COLL_ARGS_FIELD_FLAGS; args.flags = UCC_COLL_ARGS_FLAG_IN_PLACE; } - args.coll_type = UCC_COLL_TYPE_ALLGATHERV; if (TEST_NO_INPLACE == inplace) { args.src.info.buffer = sbuf; args.src.info.datatype = TEST_DT; @@ -92,19 +90,18 @@ TestAllgatherv::TestAllgatherv(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_status_t TestAllgatherv::set_input() { size_t dt_size = ucc_dt_size(TEST_DT); - int rank; - void *buf, *check_buf; + int rank; + void *buf, *check; MPI_Comm_rank(team.comm, &rank); if (inplace == TEST_NO_INPLACE) { - buf = sbuf; - check_buf = check_sbuf; + buf = sbuf; } else { - buf = PTR_OFFSET(rbuf, displacements[rank] * dt_size); - check_buf = PTR_OFFSET(check_rbuf, displacements[rank] * dt_size); + buf = PTR_OFFSET(rbuf, displacements[rank] * dt_size); } + check = PTR_OFFSET(check_buf, displacements[rank] * dt_size); init_buffer(buf, counts[rank], TEST_DT, mem_type, rank); - UCC_CHECK(ucc_mc_memcpy(check_buf, buf, counts[rank] * dt_size, + UCC_CHECK(ucc_mc_memcpy(check, buf, counts[rank] * dt_size, UCC_MEMORY_TYPE_HOST, mem_type)); return UCC_OK; } @@ -127,22 +124,20 @@ ucc_status_t TestAllgatherv::check() { MPI_Datatype dt = ucc_dt_to_mpi(TEST_DT); int total_count = 0; - int size, rank, completed, count, i; + int size, rank, completed, i; MPI_Request req; MPI_Comm_size(team.comm, &size); MPI_Comm_rank(team.comm, &rank); - count = counts[rank]; for (i = 0 ; i < size; i++) { total_count += counts[i]; } - MPI_Iallgatherv((inplace == TEST_INPLACE) ? MPI_IN_PLACE : check_sbuf, - count, dt, check_rbuf, (int*)counts, (int*)displacements, - dt, team.comm, &req); + MPI_Iallgatherv(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, check_buf, (int*)counts, + (int*)displacements, dt, team.comm, &req); do { MPI_Test(&req, &completed, MPI_STATUS_IGNORE); ucc_context_progress(team.ctx); } while(!completed); - return compare_buffers(rbuf, check_rbuf, total_count, TEST_DT, mem_type); + return compare_buffers(rbuf, check_buf, total_count, TEST_DT, mem_type); } diff --git a/test/mpi/test_allreduce.cc b/test/mpi/test_allreduce.cc index c474cdf8fb..8b81ca4aed 100644 --- a/test/mpi/test_allreduce.cc +++ b/test/mpi/test_allreduce.cc @@ -11,16 +11,15 @@ TestAllreduce::TestAllreduce(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_datatype_t _dt, ucc_reduction_op_t _op, ucc_memory_type_t _mt, ucc_test_team_t &_team, size_t _max_size) : - TestCase(_team, _mt, _msgsize, _inplace, _max_size) + TestCase(_team, UCC_COLL_TYPE_ALLREDUCE, _mt, _msgsize, _inplace, _max_size) { size_t dt_size = ucc_dt_size(_dt); - size_t count = _msgsize/dt_size; - int rank; + size_t count = _msgsize/dt_size; + int rank; MPI_Comm_rank(team.comm, &rank); op = _op; dt = _dt; - args.coll_type = UCC_COLL_TYPE_ALLREDUCE; if (skip_reduce(test_max_size < _msgsize, TEST_SKIP_MEM_LIMIT, team.comm)) { @@ -28,16 +27,12 @@ TestAllreduce::TestAllreduce(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, } UCC_CHECK(ucc_mc_alloc(&rbuf_mc_header, _msgsize, _mt)); - rbuf = rbuf_mc_header->addr; - check_rbuf = ucc_malloc(_msgsize, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); + rbuf = rbuf_mc_header->addr; + check_buf = ucc_malloc(_msgsize, "check buf"); + UCC_MALLOC_CHECK(check_buf); if (TEST_NO_INPLACE == inplace) { UCC_CHECK(ucc_mc_alloc(&sbuf_mc_header, _msgsize, _mt)); - UCC_CHECK(ucc_mc_alloc(&check_sbuf_mc_header, _msgsize, - UCC_MEMORY_TYPE_HOST)); - sbuf = sbuf_mc_header->addr; - check_sbuf = check_sbuf_mc_header->addr; - + sbuf = sbuf_mc_header->addr; args.src.info.buffer = sbuf; args.src.info.count = count; args.src.info.datatype = _dt; @@ -64,16 +59,14 @@ ucc_status_t TestAllreduce::set_input() { size_t dt_size = ucc_dt_size(dt); size_t count = msgsize / dt_size; - int rank; - void *buf, *check_buf; + int rank; + void *buf; MPI_Comm_rank(team.comm, &rank); if (TEST_NO_INPLACE == inplace) { buf = sbuf; - check_buf = check_sbuf; } else { buf = rbuf; - check_buf = check_rbuf; } init_buffer(buf, count, dt, mem_type, rank); UCC_CHECK(ucc_mc_memcpy(check_buf, buf, count * dt_size, @@ -88,13 +81,12 @@ ucc_status_t TestAllreduce::reset_sbuf() ucc_status_t TestAllreduce::check() { - size_t count = args.dst.info.count; - MPI_Request req; - int completed; + size_t count = args.dst.info.count; + MPI_Request req; + int completed; ucc_status_t status; - MPI_Iallreduce(inplace ? MPI_IN_PLACE : check_sbuf, check_rbuf, count, - ucc_dt_to_mpi(dt), + MPI_Iallreduce(MPI_IN_PLACE, check_buf, count, ucc_dt_to_mpi(dt), op == UCC_OP_AVG ? MPI_SUM : ucc_op_to_mpi(op), team.comm, &req); do { @@ -103,13 +95,13 @@ ucc_status_t TestAllreduce::check() } while(!completed); if (op == UCC_OP_AVG) { - status = divide_buffer(check_rbuf, team.team->size, count, dt); + status = divide_buffer(check_buf, team.team->size, count, dt); if (status != UCC_OK) { return status; } } - return compare_buffers(rbuf, check_rbuf, count, dt, mem_type); + return compare_buffers(rbuf, check_buf, count, dt, mem_type); } std::string TestAllreduce::str() { diff --git a/test/mpi/test_alltoall.cc b/test/mpi/test_alltoall.cc index a806fd8d66..21d9477d82 100644 --- a/test/mpi/test_alltoall.cc +++ b/test/mpi/test_alltoall.cc @@ -12,7 +12,7 @@ TestAlltoall::TestAlltoall(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_memory_type_t _mt, ucc_test_team_t &_team, size_t _max_size) : - TestCase(_team, _mt, _msgsize, _inplace, _max_size) + TestCase(_team, UCC_COLL_TYPE_ALLTOALL, _mt, _msgsize, _inplace, _max_size) { size_t dt_size = ucc_dt_size(TEST_DT); size_t single_rank_count = _msgsize / dt_size; @@ -22,23 +22,18 @@ TestAlltoall::TestAlltoall(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &nprocs); - args.coll_type = UCC_COLL_TYPE_ALLTOALL; - if (TEST_SKIP_NONE != skip_reduce(test_max_size < (_msgsize * nprocs), TEST_SKIP_MEM_LIMIT, team.comm)) { return; } UCC_CHECK(ucc_mc_alloc(&rbuf_mc_header, _msgsize * nprocs, _mt)); - rbuf = rbuf_mc_header->addr; - check_rbuf = ucc_malloc(_msgsize * nprocs, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); + rbuf = rbuf_mc_header->addr; + check_buf = ucc_malloc(_msgsize * nprocs, "check buf"); + UCC_MALLOC_CHECK(check_buf); if (TEST_NO_INPLACE == inplace) { UCC_CHECK(ucc_mc_alloc(&sbuf_mc_header, _msgsize * nprocs, _mt)); - UCC_CHECK(ucc_mc_alloc(&check_sbuf_mc_header, _msgsize * nprocs, - UCC_MEMORY_TYPE_HOST)); sbuf = sbuf_mc_header->addr; - check_sbuf = check_sbuf_mc_header->addr; } else { args.mask = UCC_COLL_ARGS_FIELD_FLAGS; args.flags = UCC_COLL_ARGS_FLAG_IN_PLACE; @@ -63,17 +58,15 @@ ucc_status_t TestAlltoall::set_input() { size_t dt_size = ucc_dt_size(TEST_DT); size_t single_rank_count = msgsize / dt_size; - void *buf, *check_buf; - int rank, nprocs; + void *buf; + int rank, nprocs; MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &nprocs); if (TEST_NO_INPLACE == inplace) { buf = sbuf; - check_buf = check_sbuf; } else { buf = rbuf; - check_buf = rbuf; } init_buffer(buf, single_rank_count * nprocs, TEST_DT, mem_type, rank); UCC_CHECK(ucc_mc_memcpy(check_buf, buf, single_rank_count * nprocs * dt_size, @@ -83,9 +76,9 @@ ucc_status_t TestAlltoall::set_input() ucc_status_t TestAlltoall::reset_sbuf() { - size_t dt_size = ucc_dt_size(TEST_DT); + size_t dt_size = ucc_dt_size(TEST_DT); size_t single_rank_count = msgsize / dt_size; - int rank, nprocs; + int rank, nprocs; MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &nprocs); @@ -97,19 +90,21 @@ ucc_status_t TestAlltoall::reset_sbuf() ucc_status_t TestAlltoall::check() { - int size, completed; - MPI_Comm_size(team.comm, &size); - size_t single_rank_count = args.src.info.count / size; + int size, completed; + size_t single_rank_count; MPI_Request req; - MPI_Ialltoall(inplace ? MPI_IN_PLACE : check_sbuf, single_rank_count, - ucc_dt_to_mpi(TEST_DT), check_rbuf, single_rank_count, - ucc_dt_to_mpi(TEST_DT), team.comm, &req); + MPI_Comm_size(team.comm, &size); + single_rank_count = args.src.info.count / size; + + MPI_Ialltoall(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, + check_buf, single_rank_count, ucc_dt_to_mpi(TEST_DT), + team.comm, &req); do { MPI_Test(&req, &completed, MPI_STATUS_IGNORE); ucc_context_progress(team.ctx); } while(!completed); - return compare_buffers(rbuf, check_rbuf, single_rank_count * size, TEST_DT, + return compare_buffers(rbuf, check_buf, single_rank_count * size, TEST_DT, mem_type); } diff --git a/test/mpi/test_alltoallv.cc b/test/mpi/test_alltoallv.cc index a6b73f5f34..bdba0ecaab 100644 --- a/test/mpi/test_alltoallv.cc +++ b/test/mpi/test_alltoallv.cc @@ -26,18 +26,17 @@ TestAlltoallv::TestAlltoallv(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, size_t _max_size, ucc_test_vsize_flag_t _count_bits, ucc_test_vsize_flag_t _displ_bits) : - TestCase(_team, _mt, _msgsize, _inplace, _max_size) + TestCase(_team, UCC_COLL_TYPE_ALLTOALLV, _mt, _msgsize, _inplace, _max_size) { size_t dt_size = ucc_dt_size(TEST_DT); - size_t count = _msgsize/dt_size; + size_t count = _msgsize/dt_size; + std::uniform_int_distribution urd(count/2, count); + std::default_random_engine eng; int rank; int nprocs; int rank_count; - std::default_random_engine eng; eng.seed(test_rand_seed); - std::uniform_int_distribution urd(count/2, count); - MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &nprocs); @@ -57,8 +56,6 @@ TestAlltoallv::TestAlltoallv(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &nprocs); - args.coll_type = UCC_COLL_TYPE_ALLTOALLV; - if (TEST_SKIP_NONE != skip_reduce(test_max_size < (_msgsize * nprocs), TEST_SKIP_MEM_LIMIT, team.comm)) { return; @@ -104,14 +101,11 @@ TestAlltoallv::TestAlltoallv(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, } UCC_CHECK(ucc_mc_alloc(&sbuf_mc_header, sncounts * dt_size, _mt)); - UCC_CHECK(ucc_mc_alloc(&check_sbuf_mc_header, sncounts * dt_size, - UCC_MEMORY_TYPE_HOST)); - sbuf = sbuf_mc_header->addr; - check_sbuf = check_sbuf_mc_header->addr; UCC_CHECK(ucc_mc_alloc(&rbuf_mc_header, rncounts * dt_size, _mt)); - rbuf = rbuf_mc_header->addr; - check_rbuf = ucc_malloc(rncounts * dt_size, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); + sbuf = sbuf_mc_header->addr; + rbuf = rbuf_mc_header->addr; + check_buf = ucc_malloc((sncounts + rncounts) * dt_size, "check buf"); + UCC_MALLOC_CHECK(check_buf); args.src.info_v.buffer = sbuf; args.src.info_v.datatype = TEST_DT; @@ -145,12 +139,12 @@ TestAlltoallv::TestAlltoallv(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_status_t TestAlltoallv::set_input() { - int rank; size_t dt_size = ucc_dt_size(TEST_DT); + int rank; MPI_Comm_rank(team.comm, &rank); init_buffer(sbuf, sncounts, TEST_DT, mem_type, rank); - UCC_CHECK(ucc_mc_memcpy(check_sbuf, sbuf, sncounts * dt_size, + UCC_CHECK(ucc_mc_memcpy(check_buf, sbuf, sncounts * dt_size, UCC_MEMORY_TYPE_HOST, mem_type)); return UCC_OK; @@ -175,17 +169,21 @@ TestAlltoallv::~TestAlltoallv() ucc_status_t TestAlltoallv::check() { + size_t dt_size = ucc_dt_size(TEST_DT); MPI_Request req; int completed; + void *check; - MPI_Ialltoallv(check_sbuf, scounts, sdispls, ucc_dt_to_mpi(TEST_DT), check_rbuf, - rcounts, rdispls, ucc_dt_to_mpi(TEST_DT), team.comm, &req); + check = PTR_OFFSET(check_buf, sncounts * dt_size); + MPI_Ialltoallv(check_buf, scounts, sdispls, ucc_dt_to_mpi(TEST_DT), + check, rcounts, rdispls, ucc_dt_to_mpi(TEST_DT), + team.comm, &req); do { MPI_Test(&req, &completed, MPI_STATUS_IGNORE); ucc_context_progress(team.ctx); } while(!completed); - return compare_buffers(rbuf, check_rbuf, rncounts, TEST_DT, mem_type); + return compare_buffers(rbuf, check, rncounts, TEST_DT, mem_type); } std::string TestAlltoallv::str() diff --git a/test/mpi/test_barrier.cc b/test/mpi/test_barrier.cc index bf1ff4c44c..7183c5396c 100644 --- a/test/mpi/test_barrier.cc +++ b/test/mpi/test_barrier.cc @@ -6,10 +6,10 @@ #include "test_mpi.h" -TestBarrier::TestBarrier(ucc_test_team_t &team) : TestCase(team) +TestBarrier::TestBarrier(ucc_test_team_t &team) : + TestCase(team, UCC_COLL_TYPE_BARRIER) { status = UCC_OK; - args.coll_type = UCC_COLL_TYPE_BARRIER; UCC_CHECK(ucc_collective_init(&args, &req, team.team)); } diff --git a/test/mpi/test_bcast.cc b/test/mpi/test_bcast.cc index a5ea015e3e..12bfd6e521 100644 --- a/test/mpi/test_bcast.cc +++ b/test/mpi/test_bcast.cc @@ -12,11 +12,12 @@ TestBcast::TestBcast(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_memory_type_t _mt, int _root, ucc_test_team_t &_team, size_t _max_size) : - TestCase(_team, _mt, _msgsize, _inplace, _max_size) + TestCase(_team, UCC_COLL_TYPE_BCAST, _mt, _msgsize, _inplace, _max_size) { size_t dt_size = ucc_dt_size(TEST_DT); - size_t count = _msgsize / dt_size; + size_t count = _msgsize / dt_size; int rank, size; + MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &size); root = _root; @@ -26,15 +27,11 @@ TestBcast::TestBcast(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, return; } - check_rbuf = ucc_malloc(_msgsize * size, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); + check_buf = ucc_malloc(_msgsize, "check buf"); + UCC_MALLOC_CHECK(check_buf); UCC_CHECK(ucc_mc_alloc(&sbuf_mc_header, _msgsize, _mt)); sbuf = sbuf_mc_header->addr; - UCC_CHECK( - ucc_mc_alloc(&check_sbuf_mc_header, _msgsize, UCC_MEMORY_TYPE_HOST)); - check_sbuf = check_sbuf_mc_header->addr; - args.coll_type = UCC_COLL_TYPE_BCAST; args.src.info.buffer = sbuf; args.src.info.count = count; args.src.info.datatype = TEST_DT; @@ -47,13 +44,13 @@ TestBcast::TestBcast(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_status_t TestBcast::set_input() { size_t dt_size = ucc_dt_size(TEST_DT); - size_t count = msgsize / dt_size; - int rank; + size_t count = msgsize / dt_size; + int rank; MPI_Comm_rank(team.comm, &rank); if (rank == root) { init_buffer(sbuf, count, TEST_DT, mem_type, rank); - UCC_CHECK(ucc_mc_memcpy(check_sbuf, sbuf, count * dt_size, + UCC_CHECK(ucc_mc_memcpy(check_buf, sbuf, count * dt_size, UCC_MEMORY_TYPE_HOST, mem_type)); } return UCC_OK; @@ -72,12 +69,12 @@ ucc_status_t TestBcast::check() MPI_Request req; MPI_Comm_rank(team.comm, &rank); - MPI_Ibcast((rank == root) ? check_sbuf : check_rbuf, count, dt, root, team.comm, &req); + MPI_Ibcast(check_buf, count, dt, root, team.comm, &req); do { MPI_Test(&req, &completed, MPI_STATUS_IGNORE); ucc_context_progress(team.ctx); } while(!completed); return (rank == root) ? UCC_OK : - compare_buffers(sbuf, check_rbuf, count, TEST_DT, mem_type); + compare_buffers(sbuf, check_buf, count, TEST_DT, mem_type); } diff --git a/test/mpi/test_case.cc b/test/mpi/test_case.cc index 217ea926af..dff88c6ec4 100644 --- a/test/mpi/test_case.cc +++ b/test/mpi/test_case.cc @@ -159,20 +159,22 @@ test_skip_cause_t TestCase::skip_reduce(test_skip_cause_t cause, MPI_Comm comm) return skip_reduce(1, cause, comm); } -TestCase::TestCase(ucc_test_team_t &_team, ucc_memory_type_t _mem_type, +TestCase::TestCase(ucc_test_team_t &_team, ucc_coll_type_t ct, + ucc_memory_type_t _mem_type, size_t _msgsize, ucc_test_mpi_inplace_t _inplace, size_t _max_size) : team(_team), mem_type(_mem_type), msgsize(_msgsize), inplace(_inplace), test_max_size(_max_size) { int rank; - sbuf = NULL; - rbuf = NULL; - check_sbuf = NULL; - check_rbuf = NULL; - test_skip = TEST_SKIP_NONE; - args.flags = 0; - args.mask = 0; + + sbuf = NULL; + rbuf = NULL; + check_buf = NULL; + test_skip = TEST_SKIP_NONE; + args.flags = 0; + args.mask = 0; + args.coll_type = ct; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Irecv((void*)progress_buf, 1, MPI_CHAR, rank, 0, MPI_COMM_WORLD, @@ -194,10 +196,7 @@ TestCase::~TestCase() if (rbuf) { UCC_CHECK(ucc_mc_free(rbuf_mc_header)); } - if (check_sbuf) { - UCC_CHECK(ucc_mc_free(check_sbuf_mc_header)); - } - if (check_rbuf) { - ucc_free(check_rbuf); + if (check_buf) { + ucc_free(check_buf); } } diff --git a/test/mpi/test_mpi.h b/test/mpi/test_mpi.h index 1da77d4ea0..59f18e0eaa 100644 --- a/test/mpi/test_mpi.h +++ b/test/mpi/test_mpi.h @@ -170,12 +170,10 @@ class TestCase { ucc_test_mpi_inplace_t inplace; ucc_coll_args_t args; ucc_coll_req_h req; - ucc_mc_buffer_header_t *sbuf_mc_header, *rbuf_mc_header, - *check_sbuf_mc_header; + ucc_mc_buffer_header_t *sbuf_mc_header, *rbuf_mc_header; void *sbuf; void *rbuf; - void *check_sbuf; - void *check_rbuf; + void *check_buf; MPI_Request progress_request; uint8_t progress_buf[1]; size_t test_max_size; @@ -207,7 +205,8 @@ class TestCase { ucc_reduction_op_t op = UCC_OP_SUM, ucc_test_vsize_flag_t count_vsize = TEST_FLAG_VSIZE_64BIT, ucc_test_vsize_flag_t displ_vsize = TEST_FLAG_VSIZE_64BIT); - TestCase(ucc_test_team_t &_team, ucc_memory_type_t _mem_type = UCC_MEMORY_TYPE_UNKNOWN, + TestCase(ucc_test_team_t &_team, ucc_coll_type_t ct, + ucc_memory_type_t _mem_type = UCC_MEMORY_TYPE_UNKNOWN, size_t _msgsize = 0, ucc_test_mpi_inplace_t _inplace = TEST_NO_INPLACE, size_t _max_size = TEST_UCC_RANK_BUF_SIZE_MAX); virtual ~TestCase(); diff --git a/test/mpi/test_reduce.cc b/test/mpi/test_reduce.cc index aac26308f8..4cfdcae850 100644 --- a/test/mpi/test_reduce.cc +++ b/test/mpi/test_reduce.cc @@ -11,27 +11,27 @@ TestReduce::TestReduce(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, ucc_datatype_t _dt, ucc_reduction_op_t _op, ucc_memory_type_t _mt, int _root, ucc_test_team_t &_team, size_t _max_size) : - TestCase(_team, _mt, _msgsize, _inplace, _max_size) + TestCase(_team, UCC_COLL_TYPE_REDUCE, _mt, _msgsize, _inplace, _max_size) { size_t dt_size = ucc_dt_size(_dt); - size_t count = _msgsize/dt_size; + size_t count = _msgsize/dt_size; int rank; + MPI_Comm_rank(team.comm, &rank); - dt = _dt; - op = _op; + dt = _dt; + op = _op; root = _root; - args.coll_type = UCC_COLL_TYPE_REDUCE; if (skip_reduce(test_max_size < _msgsize, TEST_SKIP_MEM_LIMIT, team.comm)) { return; } + check_buf = ucc_malloc(_msgsize, "check buf"); + UCC_MALLOC_CHECK(check_buf); if (rank == root) { UCC_CHECK(ucc_mc_alloc(&rbuf_mc_header, _msgsize, _mt)); rbuf = rbuf_mc_header->addr; - check_rbuf = ucc_malloc(_msgsize, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); args.dst.info.buffer = rbuf; args.dst.info.count = count; args.dst.info.datatype = _dt; @@ -45,9 +45,6 @@ TestReduce::TestReduce(size_t _msgsize, ucc_test_mpi_inplace_t _inplace, args.mask = UCC_COLL_ARGS_FIELD_FLAGS; args.flags = UCC_COLL_ARGS_FLAG_IN_PLACE; } - UCC_CHECK(ucc_mc_alloc(&check_sbuf_mc_header, _msgsize, - UCC_MEMORY_TYPE_HOST)); - check_sbuf = check_sbuf_mc_header->addr; args.op = _op; args.src.info.buffer = sbuf; @@ -63,8 +60,8 @@ ucc_status_t TestReduce::set_input() { size_t dt_size = ucc_dt_size(dt); size_t count = msgsize / dt_size; - int rank; - void *buf; + int rank; + void *buf; MPI_Comm_rank(team.comm, &rank); if (inplace && rank == root) { @@ -74,7 +71,7 @@ ucc_status_t TestReduce::set_input() } init_buffer(buf, count, dt, mem_type, rank); - UCC_CHECK(ucc_mc_memcpy(check_sbuf, buf, count * dt_size, + UCC_CHECK(ucc_mc_memcpy(check_buf, buf, count * dt_size, UCC_MEMORY_TYPE_HOST, mem_type)); return UCC_OK; } @@ -92,19 +89,21 @@ ucc_status_t TestReduce::check() MPI_Request req; MPI_Comm_rank(team.comm, &rank); - MPI_Ireduce(check_sbuf, check_rbuf, count, ucc_dt_to_mpi(dt), + MPI_Ireduce((root == rank) ? MPI_IN_PLACE : check_buf, check_buf, + count, ucc_dt_to_mpi(dt), op == UCC_OP_AVG ? MPI_SUM : ucc_op_to_mpi(op), root, team.comm, &req); do { MPI_Test(&req, &completed, MPI_STATUS_IGNORE); ucc_context_progress(team.ctx); } while(!completed); + if (rank == root && op == UCC_OP_AVG) { - status = divide_buffer(check_rbuf, team.team->size, count, dt); + status = divide_buffer(check_buf, team.team->size, count, dt); if (status != UCC_OK) { return status; } } return (rank != root) ? UCC_OK : - compare_buffers(rbuf, check_rbuf, count, dt, mem_type); + compare_buffers(rbuf, check_buf, count, dt, mem_type); } diff --git a/test/mpi/test_reduce_scatter.cc b/test/mpi/test_reduce_scatter.cc index 13b2db21af..9de9b6322e 100644 --- a/test/mpi/test_reduce_scatter.cc +++ b/test/mpi/test_reduce_scatter.cc @@ -12,17 +12,17 @@ TestReduceScatter::TestReduceScatter(size_t _msgsize, ucc_datatype_t _dt, ucc_reduction_op_t _op, ucc_memory_type_t _mt, ucc_test_team_t &_team, size_t _max_size) : - TestCase(_team, _mt, _msgsize, _inplace, _max_size) + TestCase(_team, UCC_COLL_TYPE_REDUCE_SCATTER, _mt, _msgsize, _inplace, + _max_size) { size_t dt_size = ucc_dt_size(_dt); - size_t count = _msgsize / dt_size; - int rank, comm_size; + size_t count = _msgsize / dt_size; + int rank, comm_size; MPI_Comm_rank(team.comm, &rank); MPI_Comm_size(team.comm, &comm_size); op = _op; dt = _dt; - args.coll_type = UCC_COLL_TYPE_REDUCE_SCATTER; if (skip_reduce(test_max_size < _msgsize, TEST_SKIP_MEM_LIMIT, team.comm) || @@ -30,28 +30,21 @@ TestReduceScatter::TestReduceScatter(size_t _msgsize, team.comm)) { return; } + check_buf = ucc_malloc( _msgsize, "check buf"); + UCC_MALLOC_CHECK(check_buf); if (TEST_NO_INPLACE == inplace) { args.dst.info.count = count / comm_size; - UCC_CHECK(ucc_mc_alloc(&rbuf_mc_header, _msgsize / comm_size, _mt)); - rbuf = rbuf_mc_header->addr; - check_rbuf = ucc_malloc( _msgsize / comm_size, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); UCC_CHECK(ucc_mc_alloc(&sbuf_mc_header, _msgsize, _mt)); - UCC_CHECK(ucc_mc_alloc(&check_sbuf_mc_header, _msgsize, - UCC_MEMORY_TYPE_HOST)); - sbuf = sbuf_mc_header->addr; - check_sbuf = check_sbuf_mc_header->addr; + rbuf = rbuf_mc_header->addr; + sbuf = sbuf_mc_header->addr; } else { args.mask = UCC_COLL_ARGS_FIELD_FLAGS; args.flags = UCC_COLL_ARGS_FLAG_IN_PLACE; args.dst.info.count = count; - UCC_CHECK(ucc_mc_alloc(&rbuf_mc_header, _msgsize, _mt)); rbuf = rbuf_mc_header->addr; - check_rbuf = ucc_malloc(_msgsize, "check rbuf"); - UCC_MALLOC_CHECK(check_rbuf); } if (inplace == TEST_NO_INPLACE) { @@ -72,16 +65,14 @@ ucc_status_t TestReduceScatter::set_input() { size_t dt_size = ucc_dt_size(dt); size_t count = msgsize / dt_size; - void *buf, *check_buf; - int rank; + void *buf; + int rank; MPI_Comm_rank(team.comm, &rank); if (TEST_NO_INPLACE == inplace) { buf = sbuf; - check_buf = check_sbuf; } else { buf = rbuf; - check_buf = check_rbuf; } init_buffer(buf, count, dt, mem_type, rank); UCC_CHECK(ucc_mc_memcpy(check_buf, buf, count * dt_size, @@ -97,28 +88,35 @@ ucc_status_t TestReduceScatter::reset_sbuf() ucc_status_t TestReduceScatter::check() { ucc_status_t status; - int comm_rank, comm_size; - size_t block_size, block_count; + int comm_rank, comm_size, completed; + size_t block_size, block_count; + MPI_Request req; MPI_Comm_rank(team.comm, &comm_rank); MPI_Comm_size(team.comm, &comm_size); block_size = msgsize / comm_size; block_count = block_size / ucc_dt_size(dt); - MPI_Reduce_scatter_block(inplace ? MPI_IN_PLACE : check_sbuf, check_rbuf, - block_count, ucc_dt_to_mpi(dt), - op == UCC_OP_AVG ? MPI_SUM : ucc_op_to_mpi(op), - team.comm); + + MPI_Ireduce_scatter_block(MPI_IN_PLACE, check_buf, + block_count, ucc_dt_to_mpi(dt), + op == UCC_OP_AVG ? MPI_SUM : ucc_op_to_mpi(op), + team.comm, &req); + do { + MPI_Test(&req, &completed, MPI_STATUS_IGNORE); + ucc_context_progress(team.ctx); + } while(!completed); + if (op == UCC_OP_AVG) { - status = divide_buffer(check_rbuf, team.team->size, block_count, dt); + status = divide_buffer(check_buf, team.team->size, block_count, dt); if (status != UCC_OK) { return status; } } if (inplace) { return compare_buffers(PTR_OFFSET(rbuf, comm_rank * block_size), - check_rbuf, block_count, dt, mem_type); + check_buf, block_count, dt, mem_type); } - return compare_buffers(rbuf, check_rbuf, block_count, dt, mem_type); + return compare_buffers(rbuf, check_buf, block_count, dt, mem_type); } TestReduceScatter::~TestReduceScatter() {}