Commit fd4457ff authored by gbalduzz's avatar gbalduzz
Browse files

Test MPI reduction on a large function

parent 3db9256c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -62,6 +62,18 @@ public:
  }
};

template <>
struct MPITypeMap<std::uint8_t> {
  static constexpr std::size_t factor() {
    return 1;
  }

  static MPI_Datatype value() {
    return MPI_UNSIGNED_CHAR;
  }
};


template <>
class MPITypeMap<int> {
public:
+1 −0
Original line number Diff line number Diff line
@@ -6,5 +6,6 @@ add_subdirectory(interpolation)
add_subdirectory(phys/lattice_mapping)
add_subdirectory(math/statistical_testing)
add_subdirectory(nfft)
add_subdirectory(parallel/mpi_concurrency)
add_subdirectory(statistical_tests/real_materials)
add_subdirectory(statistical_tests/square_lattice)
+5 −0
Original line number Diff line number Diff line
dca_add_gtest(large_mpi_sum_test
              EXTENSIVE
              GTEST_MAIN
              LIBS parallel_mpi_concurrency function
              MPI MPI_NUMPROC 2)
+54 −0
Original line number Diff line number Diff line
// Copyright (C) 2018 ETH Zurich
// Copyright (C) 2018 UT-Battelle, LLC
// All rights reserved.
//
// See LICENSE for terms of usage.
// See CITATION.md for citation guidelines, if DCA++ is used for scientific publications.
//
// Author: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)
//
// This file the collective sum of a large function object.
// Warning: 8 GB of memory will be allocated.

#include "gtest/gtest.h"

#include "dca/function/domains/dmn.hpp"
#include "dca/function/domains/dmn_0.hpp"
#include "dca/function/domains/dmn_variadic.hpp"
#include "dca/function/function.hpp"
#include "dca/parallel/mpi_concurrency/mpi_concurrency.hpp"

// Note: the minimalist printer is not used for compatibility with the Summit cluster at the moment of writing.

using dca::func::dmn;
using dca::func::dmn_0;
using dca::func::dmn_variadic;
using dca::func::function;

TEST(MPICollectiveSumTest, SumScalar) {
  dca::parallel::MPIConcurrency concurrency(0, nullptr);
  const int rank = concurrency.id();
  const int comm_size = concurrency.number_of_processors();

  using Dmn1 = dmn_0<dmn<(1 << 16), int>>;
  using Dmn2 = dmn_0<dmn<2 + (1 << 15), char>>;

  dca::func::function<std::uint8_t, dmn_variadic<Dmn1, Dmn2>> large_f;
  ASSERT_EQ(static_cast<unsigned long int>(Dmn1::dmn_size()) * Dmn2::dmn_size(), large_f.size());
  ASSERT_GT(large_f.size(), std::numeric_limits<int>::max());

  const int rank_sum = (comm_size * (comm_size + 1)) / 2;  // considers the +1 in (rank + 1).
  ASSERT_LE(2 * rank_sum, std::numeric_limits<std::uint8_t>::max());

  for (std::size_t i = 0; i < large_f.size(); i+=2) {
    large_f(i) = (rank + 1) * 1;
    large_f(i + 1) = (rank + 1) * 2;
  }

  concurrency.sum(large_f);

  for (std::size_t i = 0; i < large_f.size(); i+=2) {
    EXPECT_EQ(1 * rank_sum, large_f(i));
    EXPECT_EQ(2 * rank_sum, large_f(i + 1));
  }
}
+4 −4
Original line number Diff line number Diff line
@@ -269,8 +269,8 @@ struct function_test<dca::func::function<double, Domain>> {
  fType& f;
};

}  // testing
}  // dca
}  // namespace testing
}  // namespace dca

TEST(Function, TestDomain4a) {
  try {
@@ -545,8 +545,8 @@ private:

int VariableDmn::size_ = 0;

}  // testing
}  // dca
}  // namespace testing
}  // namespace dca

TEST(FunctionTest, Reset) {
  // Size of test_domain_0b = 2.