Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
HSU committed Nov 22, 2023
2 parents 2b7480c + 302ec29 commit 33f31b1
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 4 deletions.
70 changes: 70 additions & 0 deletions test/unit/coupling/CouplingMDDefinitionsTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "coupling/CouplingMDDefinitions.h"

class CouplingMDDefinitionsTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(CouplingMDDefinitionsTest);
CPPUNIT_TEST(testInitRange);
CPPUNIT_TEST(testInitDimVector);
CPPUNIT_TEST_SUITE_END();

public:
void setUp() {
}

void tearDown() {
}

void testInitRange() {
tarch::la::Vector<3, unsigned int> vec3{2,3,4};
tarch::la::Vector<3, unsigned int> results = coupling::initRange<3>(vec3);
tarch::la::Vector<3, unsigned int> expected = vec3;
CPPUNIT_ASSERT_EQUAL(expected, results);

tarch::la::Vector<2, unsigned int> vec2{2,3};
results = coupling::initRange<2>(vec2);
expected = tarch::la::Vector<3, unsigned int>{vec2[0], vec2[1], 1};
CPPUNIT_ASSERT_EQUAL(expected, results);

tarch::la::Vector<1, unsigned int> vec1{2};
results = coupling::initRange<1>(vec1);
expected = tarch::la::Vector<3, unsigned int>{vec1[0], 1, 1};
CPPUNIT_ASSERT_EQUAL(expected, results);
}

void testInitDivisionFactor() {
tarch::la::Vector<3, unsigned int> vec{2,3,4};
tarch::la::Vector<3, unsigned int> results3 = coupling::initDimVector<3>(vec);
tarch::la::Vector<3, unsigned int> expected3 = vec;
CPPUNIT_ASSERT_EQUAL(expected3, results3);

tarch::la::Vector<2, unsigned int> results2 = coupling::initDimVector<2>(vec);
tarch::la::Vector<2, unsigned int> expected2{vec[0], vec[1]};
CPPUNIT_ASSERT_EQUAL(expected2, results2);

tarch::la::Vector<1, unsigned int> results1 = coupling::initDimVector<1>(vec);
tarch::la::Vector<1, unsigned int> expected1{vec[0]};
CPPUNIT_ASSERT_EQUAL(expected1, results1);
}

void testInitDimVector() {
tarch::la::Vector<3, unsigned int> vec{2,3,4};
tarch::la::Vector<3, unsigned int> results3 = coupling::initDimVector<3>(vec);
tarch::la::Vector<3, unsigned int> expected3 = vec;
CPPUNIT_ASSERT_EQUAL(expected3, results3);

tarch::la::Vector<2, unsigned int> results2 = coupling::initDimVector<2>(vec);
tarch::la::Vector<2, unsigned int> expected2{vec[0], vec[1]};
CPPUNIT_ASSERT_EQUAL(expected2, results2);

tarch::la::Vector<1, unsigned int> results1 = coupling::initDimVector<1>(vec);
tarch::la::Vector<1, unsigned int> expected1{vec[0]};
CPPUNIT_ASSERT_EQUAL(expected1, results1);
}


private:
};

CPPUNIT_TEST_SUITE_REGISTRATION(CouplingMDDefinitionsTest);
24 changes: 24 additions & 0 deletions test/unit/coupling/paralleltopology/XYZTopologyTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "coupling/paralleltopology/XYZTopology.h"
#if (TARCH_PARALLEL == TARCH_YES)
#include <mpi.h>
#endif

class XYZTopologyTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(XYZTopologyTest);
CPPUNIT_TEST_SUITE_END();

public:
void setUp() {
}

void tearDown() {
}


private:
};

CPPUNIT_TEST_SUITE_REGISTRATION(XYZTopologyTest);
29 changes: 25 additions & 4 deletions test/unit/tarch/utils/MultiMDServiceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ using namespace utils;
class MultiMDServiceTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(MultiMDServiceTest);
#if (TARCH_PARALLEL == TARCH_YES)
CPPUNIT_TEST(testAvgNumberOfMDSimulations);
CPPUNIT_TEST(testNumberLocalComms);
CPPUNIT_TEST(testLocalNumberOfMDSimulations);
#endif
CPPUNIT_TEST_SUITE_END();

public:
Expand All @@ -36,6 +34,7 @@ class MultiMDServiceTest : public CppUnit::TestFixture
}

void testAvgNumberOfMDSimulations() {
#if (TARCH_PARALLEL == TARCH_YES)
unsigned int expectedAvgNumberOfMDSimulations = 1;
unsigned int actualAvgNumberOfMDSimulations = _multiMDService_122_1->getAvgNumberOfMDSimulations();
CPPUNIT_ASSERT_EQUAL(expectedAvgNumberOfMDSimulations, actualAvgNumberOfMDSimulations);
Expand All @@ -55,9 +54,19 @@ class MultiMDServiceTest : public CppUnit::TestFixture
expectedAvgNumberOfMDSimulations = 2;
actualAvgNumberOfMDSimulations = _multiMDService_111_10->getAvgNumberOfMDSimulations();
CPPUNIT_ASSERT_EQUAL(expectedAvgNumberOfMDSimulations, actualAvgNumberOfMDSimulations);
#else
unsigned int expectedAvgNumberOfMDSimulations = 4;
unsigned int actualAvgNumberOfMDSimulations = _multiMDService_111_4->getAvgNumberOfMDSimulations();
CPPUNIT_ASSERT_EQUAL(expectedAvgNumberOfMDSimulations, actualAvgNumberOfMDSimulations);

expectedAvgNumberOfMDSimulations = 10;
actualAvgNumberOfMDSimulations = _multiMDService_111_10->getAvgNumberOfMDSimulations();
CPPUNIT_ASSERT_EQUAL(expectedAvgNumberOfMDSimulations, actualAvgNumberOfMDSimulations);
#endif
}

void testNumberLocalComms() {
#if (TARCH_PARALLEL == TARCH_YES)
unsigned int expectedNumberOfLocalComms = 1;
unsigned int actualNumberOfLocalComms = _multiMDService_122_1->getNumberLocalComms();
CPPUNIT_ASSERT_EQUAL(expectedNumberOfLocalComms, actualNumberOfLocalComms);
Expand All @@ -77,9 +86,19 @@ class MultiMDServiceTest : public CppUnit::TestFixture
expectedNumberOfLocalComms = 4;
actualNumberOfLocalComms = _multiMDService_111_10->getNumberLocalComms();
CPPUNIT_ASSERT_EQUAL(expectedNumberOfLocalComms, actualNumberOfLocalComms);
#else
unsigned int expectedNumberOfLocalComms = 1;
unsigned int actualNumberOfLocalComms = _multiMDService_111_4->getNumberLocalComms();
CPPUNIT_ASSERT_EQUAL(expectedNumberOfLocalComms, actualNumberOfLocalComms);

expectedNumberOfLocalComms = 1;
actualNumberOfLocalComms = _multiMDService_111_10->getNumberLocalComms();
CPPUNIT_ASSERT_EQUAL(expectedNumberOfLocalComms, actualNumberOfLocalComms);
#endif
}

void testLocalNumberOfMDSimulations() {
#if (TARCH_PARALLEL == TARCH_YES)
CPPUNIT_ASSERT_EQUAL(_multiMDService_122_1->getLocalNumberOfMDSimulations(), _multiMDService_122_1->getAvgNumberOfMDSimulations());

CPPUNIT_ASSERT_EQUAL(_multiMDService_122_2->getLocalNumberOfMDSimulations(), _multiMDService_122_2->getAvgNumberOfMDSimulations());
Expand All @@ -90,14 +109,16 @@ class MultiMDServiceTest : public CppUnit::TestFixture

unsigned int expectedLocalNumberOfMDSimulations = 2;
int rank;
#if (TARCH_PARALLEL == TARCH_YES)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
#endif
if (rank == 3) {
expectedLocalNumberOfMDSimulations = _multiMDService_111_10->getTotalNumberOfMDSimulations() - expectedLocalNumberOfMDSimulations * (_multiMDService_111_10->getNumberLocalComms()-1);
}
unsigned int actualLocalNumberOfMDSimulations = _multiMDService_111_10->getLocalNumberOfMDSimulations();
CPPUNIT_ASSERT_EQUAL(expectedLocalNumberOfMDSimulations, actualLocalNumberOfMDSimulations);
#else
CPPUNIT_ASSERT_EQUAL(_multiMDService_111_4->getLocalNumberOfMDSimulations(), _multiMDService_111_4->getAvgNumberOfMDSimulations());
CPPUNIT_ASSERT_EQUAL(_multiMDService_111_10->getLocalNumberOfMDSimulations(), _multiMDService_111_10->getAvgNumberOfMDSimulations());
#endif
}

private:
Expand Down

0 comments on commit 33f31b1

Please sign in to comment.