Unverified Commit 27667188 authored by Peter Doak's avatar Peter Doak Committed by GitHub
Browse files

Merge pull request #163 from weilewei/g4_mpi_test

Adding distributed_tp_accumulator_gpu_test
parents 82834619 26c5e001
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
add_subdirectory(ctaux)
add_subdirectory(ss_ct_hyb)
add_subdirectory(stdthread_qmci)
add_subdirectory(shared_tools/accumulation/tp)
+7 −0
Original line number Diff line number Diff line
dca_add_gtest(distributed_tp_accumulator_gpu_test
  CUDA
  MPI MPI_NUMPROC 3
  GTEST_MAIN
  INCLUDE_DIRS ${DCA_INCLUDE_DIRS};${PROJECT_SOURCE_DIR}
  LIBS     ${DCA_LIBS} parallel_mpi_concurrency
  )
+86 −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.txt for terms of usage.
// See CITATION.txt for citation guidelines if you use this code for scientific publications.
//
// Author: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch)
//         Weile Wei (wwei9@lsu.edu)
//
// This file implements a no-change test for the two particles accumulation on the GPU.

#include "dca/phys/dca_step/cluster_solver/shared_tools/accumulation/tp/tp_accumulator_gpu.hpp"

#include <array>
#include <functional>
#include <string>
#include "gtest/gtest.h"

#include "dca/function/util/difference.hpp"
#include "dca/math/random/std_random_wrapper.hpp"
#include "dca/phys/four_point_type.hpp"
#include "test/unit/phys/dca_step/cluster_solver/shared_tools/accumulation/accumulation_test.hpp"
#include "test/integration/cluster_solver/shared_tools/accumulation/tp/test_setup.hpp"

constexpr bool update_baseline = false;

#define INPUT_DIR \
  DCA_SOURCE_DIR "/test/unit/phys/dca_step/cluster_solver/shared_tools/accumulation/tp/"

constexpr char input_file[] = INPUT_DIR "input_4x4_multitransfer.json";

using ConfigGenerator = dca::testing::AccumulationTest<double>;
using Configuration = ConfigGenerator::Configuration;
using Sample = ConfigGenerator::Sample;

using DistributedTpAccumulatorGpuTest =
    dca::testing::G0Setup<dca::testing::LatticeBilayer, dca::phys::solver::CT_AUX, input_file>;

uint loop_counter = 0;

TEST_F(DistributedTpAccumulatorGpuTest, Accumulate) {
    dca::linalg::util::initializeMagma();

    const std::array<int, 2> n{3, 4};
    Sample M;
    Configuration config;
    ConfigGenerator::prepareConfiguration(config, M, DistributedTpAccumulatorGpuTest::BDmn::dmn_size(),
          DistributedTpAccumulatorGpuTest::RDmn::dmn_size(),
                                        parameters_.get_beta(), n);

    using namespace dca::phys;
    parameters_.set_four_point_channels(
      std::vector<FourPointType>{PARTICLE_HOLE_TRANSVERSE, PARTICLE_HOLE_MAGNETIC,
                                 PARTICLE_HOLE_CHARGE, PARTICLE_HOLE_LONGITUDINAL_UP_UP,
                                 PARTICLE_HOLE_LONGITUDINAL_UP_DOWN, PARTICLE_PARTICLE_UP_DOWN});

    dca::phys::solver::accumulator::TpAccumulator<Parameters, dca::linalg::GPU> accumulatorDevice(
      data_->G0_k_w_cluster_excluded, parameters_);
    const int sign = 1;

    accumulatorDevice.resetAccumulation(loop_counter);
    accumulatorDevice.accumulate(M, config, sign);
    accumulatorDevice.finalize();

    ++loop_counter;

    std::vector<DcaData<Parameters>::TpGreensFunction> G4s;
    for (std::size_t channel = 0; channel < accumulatorDevice.get_sign_times_G4().size(); ++channel) {
        G4s.push_back(accumulatorDevice.get_sign_times_G4()[channel]);
    }

    auto& concurrency = parameters_.get_concurrency();

    for (int channel = 0; channel < accumulatorDevice.get_sign_times_G4().size(); ++channel) {
        auto G4 = accumulatorDevice.get_sign_times_G4()[channel];
        concurrency_.localSum(G4, concurrency.first());
        if (concurrency.get_id() == 0){
            G4s[channel] *= concurrency.number_of_processors();
            const auto diff_mpi_allreduce = dca::func::util::difference(G4, G4s[channel]);
            EXPECT_DOUBLE_EQ(0, diff_mpi_allreduce.l1);
            EXPECT_DOUBLE_EQ(0, diff_mpi_allreduce.l2);
            EXPECT_DOUBLE_EQ(0, diff_mpi_allreduce.l_inf);
        }
    }
}
+79 −0
Original line number Diff line number Diff line
{
  "output" :
  {
    "output-format"         : "HDF5",

    "output-ED"  : "ed_results.hdf5",
    "output-QMC" : "output_QMC.hdf5"
  },

  "physics" :
  {
    "beta"                      :  2,
    "chemical-potential"        : 0
  },

  "bilayer-Hubbard-model":
  {
    "t"       : 1,
    "U"       : 2
  },

  "Hund-model":
  {
    "t"       : 1,
    "U"       : 1,
    "V"       : 1,
    "Jh"      : 2
  },

  "single-band-Hubbard-model":
  {
    "t"       : 1,
    "U"       : 2
  },

  "domains": {
    "real-space-grids": {
      "cluster": [[4, 0],
        [0, 4]]
    },

    "imaginary-time": {
      "sp-time-intervals": 512
    },

    "imaginary-frequency": {
      "sp-fermionic-frequencies": 512,
      "four-point-fermionic-frequencies" : 8
    }
  },

  "four-point": {
    "type": "NONE",
    "momentum-transfer": [0., 3.1415],
    "frequency-transfer": 2
  },


  "Monte-Carlo-integration" :
  {
    "Sigma-file" : "zero",

    "warm-up-sweeps"         : 100,
    "sweeps-per-measurement" : 1,
    "measurements-per-process-and-accumulator" : 500,
    "seed" : 0,

    "threaded-solver" : {
      "accumulators" : 3
    }
  },


  "CT-INT" :
  {
    "initial-configuration-size" :5,
    "alpha-dd-pos" : 0.51
  }
}
+65 −0
Original line number Diff line number Diff line
{
  "output" :
  {
    "output-format"         : "HDF5",

    "output-ED"  : "ed_results.hdf5",
    "output-QMC" : "output_QMC.hdf5"
  },

  "physics" :
  {
    "beta"                      :  2,
    "chemical-potential"        : 0
  },

  "bilayer-Hubbard-model":
  {
    "t"       : 1,
    "U"       : 2
  },

  "domains": {
    "real-space-grids": {
      "cluster": [[2, 0],
        [0, 2]]
    },

    "imaginary-time": {
      "sp-time-intervals": 512
    },

    "imaginary-frequency": {
      "sp-fermionic-frequencies": 512,
      "four-point-fermionic-frequencies" : 4
    }
  },

  "four-point": {
    "type": "NONE",
    "frequency-transfer": 3,
    "compute-all-transfers" : true
  },


  "Monte-Carlo-integration" :
  {
    "Sigma-file" : "zero",

    "warm-up-sweeps"         : 100,
    "sweeps-per-measurement" : 1,
    "measurements-per-process-and-accumulator" : 500,
    "seed" : 0,

    "threaded-solver" : {
      "accumulators" : 3
    }
  },


  "CT-INT" :
  {
    "initial-configuration-size" :5,
    "alpha-dd-pos" : 0.51
  }
}
Loading