Skip to content

Commit

Permalink
Merge pull request #3474 from quantumsteve/afqmc_override
Browse files Browse the repository at this point in the history
AFQMC: add override keyword where appropriate
  • Loading branch information
ye-luo authored Sep 24, 2021
2 parents ad5998c + 764f9d4 commit f5dbe4b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/AFQMC/Estimators/BackPropagatedEstimator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ class BackPropagatedEstimator : public EstimatorBase

~BackPropagatedEstimator() {}

void accumulate_step(WalkerSet& wset, std::vector<ComplexType>& curData) {}
void accumulate_step(WalkerSet& wset, std::vector<ComplexType>& curData) override {}

void accumulate_block(WalkerSet& wset)
void accumulate_block(WalkerSet& wset) override
{
// MAM: BP will not work as written if steps in execute don't sync with steps in BP.
// Maybe keep track of which steps in nback_prop_steps have been done
Expand Down Expand Up @@ -251,13 +251,13 @@ class BackPropagatedEstimator : public EstimatorBase
}
}

void tags(std::ofstream& out)
void tags(std::ofstream& out) override
{
if (writer)
out << "BP_timer ";
}

void print(std::ofstream& out, hdf_archive& dump, WalkerSet& wset)
void print(std::ofstream& out, hdf_archive& dump, WalkerSet& wset) override
{
// I doubt we will ever collect a billion blocks of data.
if (writer)
Expand Down
16 changes: 8 additions & 8 deletions src/AFQMC/Estimators/BasicEstimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class BasicEstimator : public EstimatorBase

~BasicEstimator() {}

void accumulate_block(WalkerSet& wset) {}
void accumulate_block(WalkerSet& wset) override {}


// curData:
Expand All @@ -101,7 +101,7 @@ class BasicEstimator : public EstimatorBase
// 4: 1/nW * sum_i abs(<psi_T|phi_i>)
// 5: nW (total number of walkers)
// 6: "healthy" nW (total number of "healthy" walkers)
void accumulate_step(WalkerSet& wset, std::vector<ComplexType>& curData)
void accumulate_step(WalkerSet& wset, std::vector<ComplexType>& curData) override
{
ncalls++;
if (nwfacts > 0)
Expand Down Expand Up @@ -129,7 +129,7 @@ class BasicEstimator : public EstimatorBase
nwalk_good += static_cast<int>(std::floor(curData[6].real()));
}

void tags(std::ofstream& out)
void tags(std::ofstream& out) override
{
if (writer)
{
Expand All @@ -145,15 +145,15 @@ class BasicEstimator : public EstimatorBase
}
}

void tags_timers(std::ofstream& out)
void tags_timers(std::ofstream& out) override
{
if (writer)
if (timers)
out << "PseudoEnergy_t vHS_t vbias_t G_t Propagate_t Energy_comm_t vHS_comm_t X_t popC_t ortho_t setup_t "
"extra_t Block_t ";
}

void print(std::ofstream& out, hdf_archive& dump, WalkerSet& wset)
void print(std::ofstream& out, hdf_archive& dump, WalkerSet& wset) override
{
data[0] = enume.real() / ncalls;
data[1] = edeno.real() / ncalls;
Expand Down Expand Up @@ -185,7 +185,7 @@ class BasicEstimator : public EstimatorBase
ovlp = 0;
}

void print_timers(std::ofstream& out)
void print_timers(std::ofstream& out) override
{
if (writer)
{
Expand Down Expand Up @@ -217,9 +217,9 @@ class BasicEstimator : public EstimatorBase
}
}

double getEloc() { return data[0] / data[1]; }
double getEloc() override { return data[0] / data[1]; }

double getEloc_step() { return data2[0] / data2[1]; }
double getEloc_step() override { return data2[0] / data2[1]; }


private:
Expand Down
8 changes: 4 additions & 4 deletions src/AFQMC/Estimators/EnergyEstimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class EnergyEstimator : public EstimatorBase

~EnergyEstimator() {}

void accumulate_step(WalkerSet& wlks, std::vector<ComplexType>& curData) {}
void accumulate_step(WalkerSet& wlks, std::vector<ComplexType>& curData) override {}

void accumulate_block(WalkerSet& wset)
void accumulate_block(WalkerSet& wset) override
{
ScopedTimer local_timer(AFQMCTimers[energy_timer]);
size_t nwalk = wset.size();
Expand Down Expand Up @@ -101,7 +101,7 @@ class EnergyEstimator : public EstimatorBase
}
}

void tags(std::ofstream& out)
void tags(std::ofstream& out) override
{
if (TG.Global().root())
{
Expand All @@ -117,7 +117,7 @@ class EnergyEstimator : public EstimatorBase
}
}

void print(std::ofstream& out, hdf_archive& dump, WalkerSet& wset)
void print(std::ofstream& out, hdf_archive& dump, WalkerSet& wset) override
{
if (TG.Global().root())
{
Expand Down
8 changes: 4 additions & 4 deletions src/AFQMC/Estimators/MixedRDMEstimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class MixedRDMEstimator : public EstimatorBase

~MixedRDMEstimator() {}

void accumulate_step(WalkerSet& wset, std::vector<ComplexType>& curData) {}
void accumulate_step(WalkerSet& wset, std::vector<ComplexType>& curData) override {}

void accumulate_block(WalkerSet& wset)
void accumulate_block(WalkerSet& wset) override
{
// check to see whether we should be accumulating estimates.
CMatrix_ref OneRDM(DMBuffer.data(), {dm_dims.first, dm_dims.second});
Expand All @@ -108,9 +108,9 @@ class MixedRDMEstimator : public EstimatorBase
iblock++;
}

void tags(std::ofstream& out) {}
void tags(std::ofstream& out) override {}

void print(std::ofstream& out, hdf_archive& dump, WalkerSet& wset)
void print(std::ofstream& out, hdf_archive& dump, WalkerSet& wset) override
{
// I doubt we will ever collect a billion blocks of data.
int n_zero = 9;
Expand Down
5 changes: 3 additions & 2 deletions src/AFQMC/Numerics/detail/CUDA/Kernels/inplace_cast.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <cassert>
#include <complex>
#include <type_traits>
#include <cuda.h>
#include <thrust/complex.h>
#include <cuda_runtime.h>
Expand Down Expand Up @@ -59,10 +60,10 @@ __global__ void kernel_inplace_cast(Size n, thrust::complex<T>* A, thrust::compl
ni = n - 1 - ni;
for (Size i = 0; i < n; i += nb, ni -= nb)
{
if (ni >= 0)
if (std::is_unsigned<Size>::value || ni >= 0)
Bi = static_cast<thrust::complex<Q>>(*(A + ni));
__syncthreads();
if (ni >= 0)
if (std::is_unsigned<Size>::value || ni >= 0)
*(B + ni) = Bi;
// __syncthreads();
}
Expand Down

0 comments on commit f5dbe4b

Please sign in to comment.