Skip to content
Snippets Groups Projects
Commit 00129ae7 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add first mpi unit tests

parent 90efb771
No related branches found
No related tags found
1 merge request!11Feature/mpi
#include <catch.hpp>
#include <Messenger.hpp>
#include <Array.hpp>
#include <pastis_config.hpp>
#ifdef PASTIS_HAS_MPI
#include <mpi.h>
#define IF_MPI(INSTRUCTION) INSTRUCTION
#else
#define IF_MPI(INSTRUCTION)
#endif // PASTIS_HAS_MPI
namespace mpi_check
{
template <typename T>
void test_allToAll()
{
Array<T> data_array(commSize());
for (size_t i=0; i< data_array.size(); ++i) {
data_array[i] = commRank();
}
auto exchanged_array = allToAll(data_array);
for (size_t i=0; i< data_array.size(); ++i) {
REQUIRE(exchanged_array[i] == i);
}
}
}
TEST_CASE("Messenger", "[mpi]") {
SECTION("check for parallel test") {
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
SECTION("communication info") {
int rank=0;
IF_MPI(MPI_Comm_rank(MPI_COMM_WORLD, &rank));
REQUIRE(rank == commRank());
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
int size=1;
IF_MPI(MPI_Comm_size(MPI_COMM_WORLD, &size));
REQUIRE(size == commSize());
}
SECTION("allToAll") {
mpi_check::test_allToAll<int8_t>();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment