Skip to content

Commit

Permalink
Merge branch 'develop' into fix-issue-125
Browse files Browse the repository at this point in the history
  • Loading branch information
prckent authored Jan 22, 2022
2 parents ac4961f + 35331d1 commit acb9193
Show file tree
Hide file tree
Showing 36 changed files with 652 additions and 69 deletions.
6 changes: 3 additions & 3 deletions CMake/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)
#MESSAGE("check command = ${CHECK_CMD}")
add_test(
NAME ${TEST_NAME}
COMMAND ${CHECK_CMD}
COMMAND ${Python3_EXECUTABLE} ${CHECK_CMD}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${FULL_NAME}")
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS ${FULL_NAME})
set_property(TEST ${TEST_NAME} APPEND PROPERTY LABELS "QMCPACK-checking-results")
Expand Down Expand Up @@ -536,7 +536,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)
${SCALAR_ERROR})
add_test(
NAME ${TEST_NAME}
COMMAND ${CHECK_CMD}
COMMAND ${Python3_EXECUTABLE} ${CHECK_CMD}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${FULL_NAME}")
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS ${FULL_NAME})
set_property(TEST ${TEST_NAME} APPEND PROPERTY LABELS "QMCPACK-checking-results")
Expand Down Expand Up @@ -595,7 +595,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)

add_test(
NAME "${test_name}"
COMMAND ${check_cmd} ${ARGN}
COMMAND ${Python3_EXECUTABLE} ${check_cmd} ${ARGN}
WORKING_DIRECTORY "${work_dir}")

# make test depend on the run
Expand Down
2 changes: 1 addition & 1 deletion CMake/test_labels.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function(ADD_TEST_LABELS TEST_NAME TEST_LABELS)
else()
set(SUCCESS FALSE)
execute_process(
COMMAND ${qmcpack_SOURCE_DIR}/tests/scripts/test_labels.py ${TEST_NAME} ${QMC_CUDA} ${QMC_COMPLEX}
COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/scripts/test_labels.py ${TEST_NAME} ${QMC_CUDA} ${QMC_COMPLEX}
${QMC_MIXED_PRECISION}
OUTPUT_VARIABLE TEST_LABELS_TEMP
RESULT_VARIABLE SUCCESS)
Expand Down
18 changes: 18 additions & 0 deletions CMake/unit_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,21 @@ function(ADD_UNIT_TEST TESTNAME PROCS THREADS TEST_BINARY)
APPEND
PROPERTY LABELS "unit")
endfunction()

# Add a test to see if the target output exists in the desired location in the build directory.
function(add_test_target_in_output_location TARGET_NAME_TO_TEST EXE_DIR_RELATIVE_TO_BUILD)

# obtain BASE_NAME
get_target_property(BASE_NAME ${TARGET_NAME_TO_TEST} OUTPUT_NAME)
if(NOT BASE_NAME)
set(BASE_NAME ${TARGET_NAME_TO_TEST})
endif()

set(TESTNAME build_output_${TARGET_NAME_TO_TEST}_exists)
add_test(NAME ${TESTNAME} COMMAND ls ${qmcpack_BINARY_DIR}/bin/${BASE_NAME})

set_property(
TEST ${TESTNAME}
APPEND
PROPERTY LABELS "unit;deterministic")
endfunction()
6 changes: 2 additions & 4 deletions docs/hamiltonianobservable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ attributes:
+-----------------------------+--------------+-----------------------+------------------------+--------------------------------------------------+
| ``format``:math:`^r` | text | xml/table | table | Select file format |
+-----------------------------+--------------+-----------------------+------------------------+--------------------------------------------------+
| ``algorithm``:math:`^o` | text | batched/non-batched | depends | Choose NLPP algorithm |
| ``algorithm``:math:`^o` | text | batched/non-batched | batched | Choose NLPP algorithm |
+-----------------------------+--------------+-----------------------+------------------------+--------------------------------------------------+
| ``DLA``:math:`^o` | text | yes/no | no | Use determinant localization approximation |
+-----------------------------+--------------+-----------------------+------------------------+--------------------------------------------------+
Expand Down Expand Up @@ -359,9 +359,7 @@ Additional information:
These elements specify individual file names and formats (both the
FSAtom XML and CASINO tabular data formats are supported).

- **algorithm** The default value is ``batched`` when OpenMP offload
is enabled and``non-batched`` otherwise.
The ``non-batched`` algorithm evaluates the ratios of
- **algorithm** The ``non-batched`` algorithm evaluates the ratios of
wavefunction components together for each quadrature point and then
one point after another. The ``batched`` algorithm evaluates the ratios
of quadrature points together for each wavefunction component and
Expand Down
1 change: 1 addition & 0 deletions src/QMCApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ if(USE_OBJECT_TARGET)
platform_omptarget_LA)
endif()

add_test_target_in_output_location(qmcpack bin)
install(TARGETS qmcpack RUNTIME DESTINATION bin)
9 changes: 1 addition & 8 deletions src/QMCHamiltonians/ECPotentialBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,13 @@ bool ECPotentialBuilder::put(xmlNodePtr cur)

OhmmsAttributeSet pAttrib;
pAttrib.add(ecpFormat, "format", {"table", "xml"});
pAttrib.add(NLPP_algo, "algorithm", {"", "batched", "non-batched"});
pAttrib.add(NLPP_algo, "algorithm", {"batched", "non-batched"});
pAttrib.add(use_DLA, "DLA", {"no", "yes"});
pAttrib.add(pbc, "pbc", {"yes", "no"});
pAttrib.add(forces, "forces", {"no", "yes"});
pAttrib.add(physicalSO, "physicalSO", {"yes", "no"});
pAttrib.put(cur);

if (NLPP_algo.empty())
#ifdef ENABLE_OFFLOAD
NLPP_algo = "batched";
#else
NLPP_algo = "non-batched";
#endif

bool doForces = (forces == "yes") || (forces == "true");
if (use_DLA == "yes")
app_log() << " Using determinant localization approximation (DLA)" << std::endl;
Expand Down
55 changes: 28 additions & 27 deletions src/QMCHamiltonians/tests/test_ion_derivs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "QMCHamiltonians/tests/MinimalHamiltonianPool.h"
#include "ParticleIO/XMLParticleIO.h"
#include "Utilities/RandomGenerator.h"
#include "QMCWaveFunctions/TWFFastDerivWrapper.h"

namespace qmcplusplus
{
Expand Down Expand Up @@ -766,9 +767,9 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]")
REQUIRE(psi != nullptr);
//end incantation

// TWFPrototype twf;
TWFFastDerivWrapper twf;

// psi->initialize_TWF_Prototype(elec, twf);
psi->initializeTWFFastDerivWrapper(elec, twf);
SPOSet::ValueVector_t values;
SPOSet::GradVector_t dpsi;
SPOSet::ValueVector_t d2psi;
Expand Down Expand Up @@ -833,7 +834,7 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]")
X.push_back(upmat);
X.push_back(dnmat);

// twf.get_M(elec, matlist);
twf.getM(elec, matlist);

OperatorBase* kinop = ham.getHamiltonian(KINETIC);

Expand All @@ -851,17 +852,17 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]")
minv.push_back(dnmat);


// twf.get_M(elec, matlist);
// twf.getM(elec, matlist);
std::vector<std::vector<ValueMatrix_t>> dB_gs;
std::vector<std::vector<ValueMatrix_t>> dM_gs;
std::vector<ValueMatrix_t> tmp_gs;
// twf.get_gs_matrix(B, B_gs);
// twf.get_gs_matrix(matlist, M_gs);
// twf.invert_M(M_gs, minv);
// twf.build_X(minv, B_gs, X);
twf.getGSMatrices(B, B_gs);
twf.getGSMatrices(matlist, M_gs);
twf.invertMatrices(M_gs, minv);
twf.buildX(minv, B_gs, X);
for (int id = 0; id < matlist.size(); id++)
{
// int ptclnum = twf.num_particles(id);
// int ptclnum = twf.numParticles(id);
int ptclnum = (id==0 ? Nup : Ndn); //hard coded until twf interface comes online.
ValueMatrix_t gs_m;
gs_m.resize(ptclnum, ptclnum);
Expand All @@ -887,26 +888,26 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]")
{
for (int idim = 0; idim < OHMMS_DIM; idim++)
{
// twf.wipe_matrix(dB[idim]);
// twf.wipe_matrix(dM[idim]);
twf.wipeMatrices(dB[idim]);
twf.wipeMatrices(dM[idim]);
}

// twf.get_igrad_M(elec, ions, ionid, dM);
twf.getIonGradM(elec, ions, ionid, dM);
// kinop->evaluateOneBodyOpMatrixForceDeriv(elec, ions, twf, ionid, dB);

for (int idim = 0; idim < OHMMS_DIM; idim++)
{
// twf.get_gs_matrix(dB[idim], dB_gs[idim]);
// twf.get_gs_matrix(dM[idim], dM_gs[idim]);
// fkin_complex[ionid][idim] = twf.compute_gs_derivative(minv, X, dM_gs[idim], dB_gs[idim]);
twf.getGSMatrices(dB[idim], dB_gs[idim]);
twf.getGSMatrices(dM[idim], dM_gs[idim]);
fkin_complex[ionid][idim] = twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]);
}
convertToReal(fkin_complex[ionid], fkin[ionid]);
}


ValueType keval = 0.0;
RealType keobs = 0.0;
// keval = twf.trAB(minv, B_gs);
keval = twf.trAB(minv, B_gs);
convertToReal(keval, keobs);
// CHECK(keobs == Approx(9.1821937928e+00));
#if defined(MIXED_PRECISION)
Expand All @@ -933,12 +934,12 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]")
app_log() << " Evaluated. Calling evaluteOneBodyOpMatrix\n";


// twf.wipe_matrix(B);
// twf.wipe_matrix(B_gs);
// twf.wipe_matrix(X);
// twf.wipeMatrices(B);
// twf.wipeMatrices(B_gs);
// twf.wipeMatrices(X);
// nlppop->evaluateOneBodyOpMatrix(elec, twf, B);
// twf.get_gs_matrix(B, B_gs);
// twf.build_X(minv, B_gs, X);
// twf.getGSMatrices(B, B_gs);
// twf.buildX(minv, B_gs, X);

ValueType nlpp = 0.0;
RealType nlpp_obs = 0.0;
Expand All @@ -955,18 +956,18 @@ TEST_CASE("Eloc_Derivatives:proto_sd_noj", "[hamiltonian]")
{
for (int idim = 0; idim < OHMMS_DIM; idim++)
{
// twf.wipe_matrix(dB[idim]);
// twf.wipe_matrix(dM[idim]);
// twf.wipeMatrices(dB[idim]);
// twf.wipeMatrices(dM[idim]);
}

// twf.get_igrad_M(elec, ions, ionid, dM);
// twf.getIonGradM(elec, ions, ionid, dM);
// nlppop->evaluateOneBodyOpMatrixForceDeriv(elec, ions, twf, ionid, dB);

for (int idim = 0; idim < OHMMS_DIM; idim++)
{
// twf.get_gs_matrix(dB[idim], dB_gs[idim]);
// twf.get_gs_matrix(dM[idim], dM_gs[idim]);
// fnlpp_complex[ionid][idim] = twf.compute_gs_derivative(minv, X, dM_gs[idim], dB_gs[idim]);
// twf.getGSMatrices(dB[idim], dB_gs[idim]);
// twf.getGSMatrices(dM[idim], dM_gs[idim]);
// fnlpp_complex[ionid][idim] = twf.computeGSDerivative(minv, X, dM_gs[idim], dB_gs[idim]);
}
convertToReal(fnlpp_complex[ionid], fnlpp[ionid]);
}
Expand Down
6 changes: 4 additions & 2 deletions src/QMCTools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ if(USE_OBJECT_TARGET)
target_link_libraries(qmcfinitesize qmcparticle qmcutil)
endif()

install(TARGETS convert4qmc qmc-extract-eshdf-kvectors qmc-get-supercell qmc-check-affinity convertpw4qmc qmcfinitesize
RUNTIME DESTINATION bin)
foreach(EXE_TARGET convert4qmc qmc-extract-eshdf-kvectors qmc-get-supercell qmc-check-affinity convertpw4qmc qmcfinitesize)
add_test_target_in_output_location(${EXE_TARGET} bin)
install(TARGETS ${EXE_TARGET} RUNTIME DESTINATION bin)
endforeach()

add_subdirectory(ppconvert)

Expand Down
3 changes: 3 additions & 0 deletions src/QMCTools/ppconvert/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ target_sources(
"${CMAKE_CURRENT_SOURCE_DIR}/ParserClass.cc")

target_link_libraries(ppconvert common platform_LA)

add_test_target_in_output_location(ppconvert bin)
install(TARGETS ppconvert RUNTIME DESTINATION bin)
1 change: 1 addition & 0 deletions src/QMCWaveFunctions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ set(FERMION_SRCS
SPOSetBuilderFactory.cpp
TrialWaveFunction.cpp
TWFdispatcher.cpp
TWFFastDerivWrapper.cpp
WaveFunctionFactory.cpp)

if(ENABLE_CUDA)
Expand Down
7 changes: 7 additions & 0 deletions src/QMCWaveFunctions/Fermion/DiracDeterminant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "CPU/SIMD/simd.hpp"
#include "Numerics/DeterminantOperators.h"
#include "Numerics/MatrixOperators.h"
#include "QMCWaveFunctions/TWFFastDerivWrapper.h"

namespace qmcplusplus
{
Expand Down Expand Up @@ -344,6 +345,12 @@ void DiracDeterminant<DU_TYPE>::copyFromBuffer(ParticleSet& P, WFBufferType& buf
updateEng.initializeInv(psiM);
}

template<typename DU_TYPE>
void DiracDeterminant<DU_TYPE>::registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const
{
twf.addGroup(P, P.getGroupID(FirstIndex), Phi.get());
}

/** return the ratio only for the iat-th partcle move
* @param P current configuration
* @param iat the particle thas is being moved
Expand Down
4 changes: 4 additions & 0 deletions src/QMCWaveFunctions/Fermion/DiracDeterminant.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class DiracDeterminant : public DiracDeterminantBase

void copyFromBuffer(ParticleSet& P, WFBufferType& buf) override;

/** Finds the SPOSet associated with this determinant, and registers it with WFN wrapper
*/
void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const final;

/** return the ratio only for the iat-th partcle move
* @param P current configuration
* @param iat the particle thas is being moved
Expand Down
4 changes: 4 additions & 0 deletions src/QMCWaveFunctions/Fermion/DiracDeterminantBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class DiracDeterminantBase : public WaveFunctionComponent

inline void reportStatus(std::ostream& os) final {}

virtual void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const override
{
APP_ABORT("DiracDeterminantBase::registerTWFFastDerivWrapper must be overridden\n");
}
// expose CPU interfaces
using WaveFunctionComponent::evaluateDerivatives;
using WaveFunctionComponent::evaluateGL;
Expand Down
7 changes: 7 additions & 0 deletions src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "CPU/BLAS.hpp"
#include "OhmmsPETE/OhmmsMatrix.h"
#include "Numerics/MatrixOperators.h"
#include "QMCWaveFunctions/TWFFastDerivWrapper.h"
#include "CPU/SIMD/simd.hpp"
#include <cassert>

Expand Down Expand Up @@ -956,6 +957,12 @@ void DiracDeterminantBatched<DET_ENGINE>::evaluateDerivatives(ParticleSet& P,
Phi->evaluateDerivatives(P, active, dlogpsi, dhpsioverpsi, FirstIndex, LastIndex);
}

template<typename DET_ENGINE>
void DiracDeterminantBatched<DET_ENGINE>::registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const
{
twf.addGroup(P, P.getGroupID(FirstIndex), Phi.get());
}

template<typename DET_ENGINE>
std::unique_ptr<DiracDeterminantBase> DiracDeterminantBatched<DET_ENGINE>::makeCopy(std::shared_ptr<SPOSet>&& spo) const
{
Expand Down
4 changes: 4 additions & 0 deletions src/QMCWaveFunctions/Fermion/DiracDeterminantBatched.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
namespace qmcplusplus
{

//forward declaration
class TWFFastDerivWrapper;

template<typename DET_ENGINE = MatrixUpdateOMPTarget<QMCTraits::ValueType, QMCTraits::QTFull::ValueType>>
class DiracDeterminantBatched : public DiracDeterminantBase
{
Expand Down Expand Up @@ -209,6 +212,7 @@ class DiracDeterminantBatched : public DiracDeterminantBase
void releaseResource(ResourceCollection& collection,
const RefVectorWithLeader<WaveFunctionComponent>& wfc_list) const override;

void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const override;
/** cloning function
* @param tqp target particleset
* @param spo spo set
Expand Down
8 changes: 8 additions & 0 deletions src/QMCWaveFunctions/Fermion/SlaterDet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,12 @@ std::unique_ptr<WaveFunctionComponent> SlaterDet::makeClone(ParticleSet& tqp) co
return myclone;
}

void SlaterDet::registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const
{
for (int i = 0; i < Dets.size(); ++i)
{
Dets[i]->registerTWFFastDerivWrapper(P, twf);
}
}

} // namespace qmcplusplus
4 changes: 4 additions & 0 deletions src/QMCWaveFunctions/Fermion/SlaterDet.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef QMCPLUSPLUS_SLATERDETERMINANT_WITHBASE_H
#define QMCPLUSPLUS_SLATERDETERMINANT_WITHBASE_H
#include "QMCWaveFunctions/Fermion/DiracDeterminantBase.h"

#include <map>

namespace qmcplusplus
Expand All @@ -28,6 +29,7 @@ namespace qmcplusplus
// then change SlaterDet to SlaterDet<false>
// and SlaterDeterminantWithBackflow to SlaterDet<true>
// and remove all virtuals and inline them
class TWFFastDerivWrapper;

class SlaterDet : public WaveFunctionComponent
{
Expand All @@ -53,6 +55,8 @@ class SlaterDet : public WaveFunctionComponent

void reportStatus(std::ostream& os) override;

void registerTWFFastDerivWrapper(const ParticleSet& P, TWFFastDerivWrapper& twf) const override;

LogValueType evaluateLog(const ParticleSet& P,
ParticleSet::ParticleGradient_t& G,
ParticleSet::ParticleLaplacian_t& L) override;
Expand Down
Loading

0 comments on commit acb9193

Please sign in to comment.