├── CMake ├── ClangCompilers.cmake ├── FindMKL.cmake ├── GNUCompilers.cmake ├── IBMCompilers.cmake ├── IntelCompilers.cmake ├── PGICompilers.cmake ├── compareGCOV.cmake ├── ctest_script.cmake ├── macros.cmake ├── python.cmake └── unit_test.cmake ├── CMakeLists.txt ├── Doxyfile ├── LICENSE ├── README.md ├── build.sh ├── build └── .gitignore ├── configure ├── external_codes └── catch │ ├── Readme │ ├── catch.hpp │ ├── complex_approx.hpp │ └── log_complex_approx.hpp ├── goals.md ├── miniqmc.settings ├── src ├── .clang-format ├── CMakeLists.txt ├── Drivers │ ├── CMakeLists.txt │ ├── MiniQMCOptions.cpp │ ├── MiniQMCOptions.h │ ├── Mover.hpp │ ├── NonLocalPP.hpp │ ├── check_spo.cpp │ ├── check_wfc.cpp │ ├── miniqmc.cpp │ ├── miniqmc_sync_move.cpp │ └── tests │ │ ├── CMakeLists.txt │ │ └── test_MiniQMCOptions.cpp ├── Input │ ├── Input.hpp │ ├── graphite.hpp │ └── nio.hpp ├── Numerics │ ├── .clang-format │ ├── BlasThreadingEnv.h │ ├── Blasf.h │ ├── Containers.h │ ├── DeterminantOperators.h │ ├── Einspline │ │ ├── bspline.h │ │ ├── bspline_base.h │ │ ├── bspline_structs.h │ │ └── multi_bspline_structs.h │ ├── OhmmsBlas.h │ ├── OhmmsPETE │ │ ├── OhmmsArray.h │ │ ├── OhmmsMatrix.h │ │ ├── OhmmsMatrixOperators.h │ │ ├── OhmmsTinyMeta.h │ │ ├── OhmmsVector.h │ │ ├── OhmmsVectorOperators.h │ │ ├── PosTransformer.h │ │ ├── Tensor.h │ │ ├── TensorOps.h │ │ ├── TinyVector.h │ │ ├── TinyVectorOps.h │ │ ├── TinyVectorTensorOps.h │ │ └── VectorSoAContainer.h │ ├── OptimizableFunctorBase.h │ ├── PETE │ │ ├── Combiners.h │ │ ├── CreateLeaf.h │ │ ├── ForEach.h │ │ ├── Functors.h │ │ ├── OperatorTags.h │ │ ├── PETE.h │ │ ├── Scalar.h │ │ ├── TreeNodes.h │ │ └── TypeComputations.h │ ├── Spline2 │ │ ├── BsplineAllocator.hpp │ │ ├── MultiBspline.hpp │ │ ├── MultiBsplineData.hpp │ │ ├── MultiBsplineEvalHelper.hpp │ │ ├── MultiBsplineRef.hpp │ │ └── bspline_traits.hpp │ └── readme_soa.md ├── Particle │ ├── DistanceTable.h │ ├── DistanceTableAA.cpp │ ├── DistanceTableAA.h │ ├── DistanceTableAB.cpp │ ├── DistanceTableBA.h │ ├── DistanceTableData.h │ ├── FastParticleOperators.h │ ├── Lattice │ │ ├── CrystalLattice.cpp │ │ ├── CrystalLattice.h │ │ ├── LatticeAnalyzer.h │ │ ├── LatticeOperations.h │ │ └── ParticleBConds.h │ ├── ParticleAttrib.h │ ├── ParticleIOUtility.h │ ├── ParticleSet.BC.cpp │ ├── ParticleSet.cpp │ ├── ParticleSet.h │ ├── ParticleSet_builder.cpp │ ├── ParticleSet_builder.hpp │ ├── VirtualParticleSet.cpp │ ├── VirtualParticleSet.h │ ├── Walker.h │ └── tests │ │ ├── CMakeLists.txt │ │ └── test_particle.cpp ├── QMCWaveFunctions │ ├── CMakeLists.txt │ ├── DelayedUpdate.h │ ├── DeterminantHelper.h │ ├── DiracDeterminant.cpp │ ├── DiracDeterminant.h │ ├── DiracDeterminantRef.cpp │ ├── DiracDeterminantRef.h │ ├── DiracMatrix.h │ ├── Jastrow │ │ ├── BsplineFunctor.h │ │ ├── OneBodyJastrow.h │ │ ├── OneBodyJastrowRef.h │ │ ├── PolynomialFunctor3D.h │ │ ├── ThreeBodyJastrow.h │ │ ├── ThreeBodyJastrowRef.h │ │ ├── TwoBodyJastrow.h │ │ └── TwoBodyJastrowRef.h │ ├── SPOSet.h │ ├── SPOSet_builder.cpp │ ├── SPOSet_builder.h │ ├── WaveFunction.cpp │ ├── WaveFunction.h │ ├── WaveFunctionComponent.h │ ├── einspline_spo.hpp │ ├── einspline_spo_ref.hpp │ └── tests │ │ ├── CMakeLists.txt │ │ ├── test_dirac_det.cpp │ │ └── test_dirac_matrix.cpp ├── Utilities │ ├── CMakeLists.txt │ ├── Clock.h │ ├── Communicate.cpp │ ├── Communicate.h │ ├── Configuration.h │ ├── Constants.h │ ├── InfoStream.cpp │ ├── InfoStream.h │ ├── NewTimer.cpp │ ├── NewTimer.h │ ├── OutputManager.cpp │ ├── OutputManager.h │ ├── ParallelBlock.hpp │ ├── PooledData.h │ ├── PrimeNumberSet.h │ ├── QMCTypes.h │ ├── RandomGenerator.h │ ├── SIMD │ │ ├── Mallocator.hpp │ │ ├── algorithm.hpp │ │ ├── allocator.hpp │ │ └── allocator_traits.hpp │ ├── SpeciesSet.cpp │ ├── SpeciesSet.h │ ├── StdRandom.h │ ├── XMLWriter.cpp │ ├── XMLWriter.h │ ├── catch_main.cpp │ ├── qmcpack_version.cpp │ ├── qmcpack_version.h │ ├── scalar_traits.h │ ├── tests │ │ ├── CMakeLists.txt │ │ ├── test_ParallelBlock.cpp │ │ └── test_PrimeNumberSet.cpp │ └── tinyxml │ │ ├── .clang-format │ │ ├── tinyxml2.cpp │ │ └── tinyxml2.h └── config.h.cmake.in └── testing ├── miniqmc_openshift_rhea.sh └── nightly_scripts └── nightly_anl_bora.sh /CMake/ClangCompilers.cmake: -------------------------------------------------------------------------------- 1 | # Check compiler version 2 | IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3 ) 3 | MESSAGE(STATUS "Compiler Version ${CMAKE_CXX_COMPILER_VERSION}") 4 | MESSAGE(FATAL_ERROR "Requires clang 3.3 or higher ") 5 | ENDIF() 6 | 7 | # Enable OpenMP 8 | IF(QMC_OMP) 9 | SET(ENABLE_OPENMP 1) 10 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") 11 | ENDIF(QMC_OMP) 12 | 13 | # Set clang specfic flags (which we always want) 14 | ADD_DEFINITIONS( -Drestrict=__restrict__ ) 15 | 16 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -fstrict-aliasing -D__forceinline=inline") 17 | SET( HAVE_POSIX_MEMALIGN 0 ) # Clang doesn't support -malign-double 18 | 19 | # Set extra optimization specific flags 20 | SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math" ) 21 | SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math" ) 22 | 23 | #-------------------------------------- 24 | # Special architectural flags 25 | #-------------------------------------- 26 | # case arch 27 | # x86_64: -march 28 | # powerpc: -mpcu 29 | # arm: -mpcu 30 | # default or cray: none 31 | #-------------------------------------- 32 | IF($ENV{CRAYPE_VERSION} MATCHES ".") 33 | # It's a cray machine. Don't do anything 34 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") 35 | # the case for x86_64 36 | #check if the user has already specified -march=XXXX option for cross-compiling. 37 | if(NOT CMAKE_CXX_FLAGS MATCHES "-march=") 38 | # use -march=native 39 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") 40 | endif(NOT CMAKE_CXX_FLAGS MATCHES "-march=") 41 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") 42 | # the case for PowerPC and ARM 43 | #check if the user has already specified -mcpu=XXXX option for cross-compiling. 44 | if(NOT CMAKE_CXX_FLAGS MATCHES "-mcpu=") 45 | # use -mcpu=native 46 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=native") 47 | endif(NOT CMAKE_CXX_FLAGS MATCHES "-mcpu=") 48 | ENDIF() 49 | 50 | # Add static flags if necessary 51 | IF(QMC_BUILD_STATIC) 52 | SET(CMAKE_CXX_LINK_FLAGS " -static") 53 | ENDIF(QMC_BUILD_STATIC) 54 | 55 | # Coverage 56 | IF (ENABLE_GCOV) 57 | SET(GCOV_COVERAGE TRUE) 58 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") 59 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") 60 | SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") 61 | ENDIF(ENABLE_GCOV) 62 | 63 | SET(XRAY_PROFILE FALSE CACHE BOOL "Use llvm xray profiling") 64 | SET(XRAY_INSTRUCTION_THRESHOLD 200 CACHE STRING "Instruction threshold for xray instrumentation") 65 | 66 | IF(XRAY_PROFILE) 67 | set(XRAY_FLAGS "-fxray-instrument -fxray-instruction-threshold=${XRAY_INSTRUCTION_THRESHOLD}") 68 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XRAY_FLAGS}") 69 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XRAY_FLAGS}") 70 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${XRAY_FLAGS}") 71 | ENDIF(XRAY_PROFILE) 72 | -------------------------------------------------------------------------------- /CMake/FindMKL.cmake: -------------------------------------------------------------------------------- 1 | # Simple file to refine MKL search. 2 | # It relies on FindLAPACK to locate MKL library files and set up linker options first. 3 | INCLUDE( CheckCXXSourceCompiles ) 4 | 5 | SET(MKL_LIBRARIES ${LAPACK_LINKER_FLAGS} ${LAPACK_LIBRARIES}) 6 | 7 | MESSAGE(STATUS "Looking for Intel MKL library header files") 8 | 9 | # Finding and setting the MKL_INCLUDE_DIRECTORIES based on MKL_ROOT, $ENV{MKLROOT}, $ENV{MKL_ROOT}, $ENV{MKL_HOME} 10 | # Extremely Basic Support of common mkl module environment variables 11 | FIND_PATH(MKL_INCLUDE_DIRECTORIES "mkl.h" 12 | HINTS ${MKL_ROOT} $ENV{MKLROOT} $ENV{MKL_ROOT} $ENV{MKL_HOME} 13 | PATH_SUFFIXES include) 14 | IF(NOT MKL_INCLUDE_DIRECTORIES) 15 | # Finding MKL headers in the system 16 | FIND_PATH(MKL_INCLUDE_DIRECTORIES "mkl.h" PATH_SUFFIXES mkl) 17 | ENDIF() 18 | 19 | IF(MKL_INCLUDE_DIRECTORIES) 20 | MESSAGE(STATUS "MKL_INCLUDE_DIRECTORIES: ${MKL_INCLUDE_DIRECTORIES}") 21 | ELSE(MKL_INCLUDE_DIRECTORIES) 22 | MESSAGE(STATUS "mkl.h cannot be found") 23 | IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") 24 | MESSAGE(FATAL_ERROR "Intel's standard compilervar.sh sets the env variable MKLROOT.\n" 25 | "If you are invoking icc without the customary environment\n" 26 | "you must set the the environment variable or pass cmake MKL_ROOT.") 27 | ELSE(CMAKE_CXX_COMPILER_ID MATCHES "Intel") 28 | MESSAGE(FATAL_ERROR "Pass mkl root directory to cmake via MKL_ROOT." ) 29 | ENDIF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") 30 | ENDIF(MKL_INCLUDE_DIRECTORIES) 31 | 32 | # Check for mkl.h 33 | FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx" 34 | "#include \n #include \n int main() { return 0; }\n" ) 35 | TRY_COMPILE(HAVE_MKL ${CMAKE_BINARY_DIR} 36 | ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx 37 | CMAKE_FLAGS 38 | "-DINCLUDE_DIRECTORIES=${MKL_INCLUDE_DIRECTORIES} " 39 | LINK_LIBRARIES "${MKL_LIBRARIES}" 40 | OUTPUT_VARIABLE MKL_OUT) 41 | IF( NOT HAVE_MKL ) 42 | MESSAGE( "${MKL_OUT}" ) 43 | ENDIF( NOT HAVE_MKL ) 44 | 45 | IF ( HAVE_MKL ) 46 | SET( MKL_FOUND TRUE ) 47 | MESSAGE(STATUS "MKL found: HAVE_MKL=${HAVE_MKL}") 48 | 49 | #Add BLAS_LAPACK header 50 | SET_TARGET_PROPERTIES(Math::BLAS_LAPACK PROPERTIES INTERFACE_COMPILE_DEFINITIONS "HAVE_MKL" 51 | INTERFACE_INCLUDE_DIRECTORIES "${MKL_INCLUDE_DIRECTORIES}") 52 | 53 | ELSE( HAVE_MKL ) 54 | SET( MKL_FOUND FALSE ) 55 | MESSAGE(STATUS "MKL header files not found") 56 | ENDIF( HAVE_MKL ) 57 | -------------------------------------------------------------------------------- /CMake/GNUCompilers.cmake: -------------------------------------------------------------------------------- 1 | # Check compiler version 2 | IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8 ) 3 | MESSAGE(FATAL_ERROR "Requires gcc 4.8 or higher ") 4 | ENDIF() 5 | 6 | # Enable OpenMP 7 | IF(QMC_OMP) 8 | SET(ENABLE_OPENMP 1) 9 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") 10 | ENDIF(QMC_OMP) 11 | 12 | # Set gnu specfic flags (which we always want) 13 | ADD_DEFINITIONS( -Drestrict=__restrict__ ) 14 | 15 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -finline-limit=1000 -fstrict-aliasing -funroll-all-loops -D__forceinline=inline") 16 | 17 | # Suppress compile warnings 18 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") 19 | 20 | # Set extra optimization specific flags 21 | SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math" ) 22 | SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math" ) 23 | 24 | #-------------------------------------- 25 | # Special architectural flags 26 | #-------------------------------------- 27 | # case arch 28 | # x86_64: -march 29 | # powerpc: -mpcu 30 | # arm: -mpcu 31 | # default or cray: none 32 | #-------------------------------------- 33 | IF($ENV{CRAYPE_VERSION} MATCHES ".") 34 | # It's a cray machine. Don't do anything 35 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") 36 | # the case for x86_64 37 | #check if the user has already specified -march=XXXX option for cross-compiling. 38 | if(NOT CMAKE_CXX_FLAGS MATCHES "-march=") 39 | # use -march=native 40 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") 41 | endif(NOT CMAKE_CXX_FLAGS MATCHES "-march=") 42 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") 43 | # the case for PowerPC and ARM 44 | #check if the user has already specified -mcpu=XXXX option for cross-compiling. 45 | if(NOT CMAKE_CXX_FLAGS MATCHES "-mcpu=") 46 | # use -mcpu=native 47 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=native") 48 | endif(NOT CMAKE_CXX_FLAGS MATCHES "-mcpu=") 49 | ENDIF() 50 | 51 | # Add static flags if necessary 52 | IF(QMC_BUILD_STATIC) 53 | SET(CMAKE_CXX_LINK_FLAGS " -static") 54 | ENDIF(QMC_BUILD_STATIC) 55 | 56 | # Coverage 57 | IF (ENABLE_GCOV) 58 | SET(GCOV_SUPPORTED TRUE) 59 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") 60 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") 61 | SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") 62 | ENDIF(ENABLE_GCOV) 63 | 64 | 65 | -------------------------------------------------------------------------------- /CMake/IBMCompilers.cmake: -------------------------------------------------------------------------------- 1 | IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le") 2 | MESSAGE(STATUS "Power8+ system using xlC/xlc/xlf") 3 | 4 | ADD_DEFINITIONS( -Drestrict=__restrict__ ) 5 | 6 | # Clean up flags 7 | IF(CMAKE_CXX_FLAGS MATCHES "-qhalt=e") 8 | SET(CMAKE_CXX_FLAGS "") 9 | ENDIF() 10 | 11 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__forceinline=inline") 12 | 13 | # Suppress compile warnings 14 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-unused-value") 15 | 16 | # Set extra optimization specific flags 17 | SET( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" ) 18 | SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" ) 19 | 20 | # Set language standardards 21 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qnoxlcompatmacros") 22 | 23 | # CMake < 3.9 didn't have support for language standards in XL 24 | IF(NOT CMAKE_CXX11_STANDARD_COMPILE_OPTION) 25 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 26 | ENDIF() 27 | 28 | IF(QMC_OMP) 29 | SET(ENABLE_OPENMP 1) 30 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qsmp=omp") 31 | ELSE(QMC_OMP) 32 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qnothreaded") 33 | ENDIF(QMC_OMP) 34 | 35 | # Add static flags if necessary 36 | IF(QMC_BUILD_STATIC) 37 | SET(CMAKE_CXX_LINK_FLAGS " -static") 38 | ENDIF(QMC_BUILD_STATIC) 39 | 40 | ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le") 41 | -------------------------------------------------------------------------------- /CMake/IntelCompilers.cmake: -------------------------------------------------------------------------------- 1 | # Check compiler version 2 | IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0 ) 3 | MESSAGE(FATAL_ERROR "Requires Intel 18.0 or higher ") 4 | ENDIF() 5 | 6 | # Enable OpenMP 7 | IF(QMC_OMP) 8 | SET(ENABLE_OPENMP 1) 9 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopenmp") 10 | ENDIF(QMC_OMP) 11 | 12 | # Suppress compile warnings 13 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") 14 | 15 | # Set extra optimization specific flags 16 | SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -restrict -unroll -ip" ) 17 | SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -restrict -unroll -ip" ) 18 | SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -restrict -unroll -ip" ) 19 | 20 | # Set prefetch flag 21 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopt-prefetch" ) 22 | 23 | #check if -ftz is accepted 24 | CHECK_CXX_COMPILER_FLAG( "${CMAKE_CXX_FLAGS} -ftz" INTEL_FTZ ) 25 | IF( INTEL_FTZ) 26 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftz" ) 27 | ENDIF( INTEL_FTZ) 28 | 29 | #------------------------ 30 | # Not on Cray's machine 31 | #------------------------ 32 | IF(NOT $ENV{CRAYPE_VERSION} MATCHES ".") 33 | 34 | SET(X_OPTION "^-x| -x") 35 | SET(AX_OPTION "^-ax| -ax") 36 | #check if the user has already specified -x option for cross-compiling. 37 | if(NOT (CMAKE_CXX_FLAGS MATCHES ${X_OPTION} OR CMAKE_CXX_FLAGS MATCHES ${AX_OPTION})) 38 | #check if -xHost is accepted 39 | CHECK_CXX_COMPILER_FLAG( "-xHost" INTEL_CXX_FLAGS ) 40 | IF(INTEL_CXX_FLAGS) 41 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost") 42 | ENDIF(INTEL_CXX_FLAGS) 43 | endif() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_CXX_FLAGS MATCHES "-ax") 44 | 45 | ENDIF(NOT $ENV{CRAYPE_VERSION} MATCHES ".") 46 | -------------------------------------------------------------------------------- /CMake/PGICompilers.cmake: -------------------------------------------------------------------------------- 1 | # Enable OpenMP 2 | # If just -mp is specified, OMP_NUM_THREADS must be set in order to run in parallel 3 | # Specifying 'allcores' will run on all cores if OMP_NUM_THREADS is not set (which seems 4 | # to be the default for other OpenMP implementations) 5 | IF(QMC_OMP) 6 | SET(ENABLE_OPENMP 1) 7 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mp=allcores") 8 | ENDIF(QMC_OMP) 9 | 10 | ADD_DEFINITIONS( -Drestrict=__restrict__ ) 11 | 12 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__forceinline=inline") 13 | 14 | # Set extra optimization specific flags 15 | SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fast" ) 16 | SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fast" ) 17 | 18 | 19 | # Setting this to 'OFF' adds the -A flag, which enforces strict standard compliance 20 | # and causes the compilation to fail with some GNU header files 21 | SET(CMAKE_CXX_EXTENSIONS ON) 22 | 23 | # Add static flags if necessary 24 | IF(QMC_BUILD_STATIC) 25 | SET(CMAKE_CXX_LINK_FLAGS " -Bstatic") 26 | ENDIF(QMC_BUILD_STATIC) 27 | -------------------------------------------------------------------------------- /CMake/compareGCOV.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Heavily inspired by the CTestCoverageCollectGCOV CMake module. 3 | # Functions for handling coverage data 4 | # - create gcov files 5 | # - compare multiple runs 6 | # - create tar file for CDash upload 7 | 8 | # Generate gcov files from gcda and gcno files 9 | # Create the data.json file cdash expects 10 | FUNCTION(GENERATE_GCOV BINARY_DIR OUTPUT_DIR GCOV_OPTIONS SOURCE_DIR) 11 | FILE(MAKE_DIRECTORY ${OUTPUT_DIR}) 12 | 13 | FILE(GLOB_RECURSE GCDA_FILES "${BINARY_DIR}/*.gcda") 14 | 15 | SET(GCOV_CMD_OPTIONS "-b;-p") 16 | IF (GCOV_OPTIONS STREQUAL "USE_LONG_FILE_NAMES") 17 | SET(GCOV_CMD_OPTIONS "${GCOV_CMD_OPTIONS};-l;-s;${SOURCE_DIR}") 18 | ENDIF() 19 | MESSAGE("GCOV_CMD_OPTIONS = ${GCOV_CMD_OPTIONS}") 20 | 21 | FOREACH(GCDA_FILE ${GCDA_FILES}) 22 | EXECUTE_PROCESS(COMMAND gcov ${GCOV_CMD_OPTIONS} ${GCDA_FILE} WORKING_DIRECTORY ${OUTPUT_DIR} OUTPUT_VARIABLE out) 23 | ENDFOREACH() 24 | 25 | FILE(WRITE ${OUTPUT_DIR}/data.json 26 | "{ 27 | \"Source\":\"${CTEST_SOURCE_DIRECTORY}\", 28 | \"Binary\":\"${CTEST_BINARY_DIRECTORY}\" 29 | }") 30 | 31 | ENDFUNCTION() 32 | 33 | # Remove unwanted gcov files (files in /usr, unit tests, files with coverage only in static initializers, etc.) 34 | FUNCTION(FILTER_GCOV GCOV_DIR) 35 | EXECUTE_PROCESS(COMMAND python ${CTEST_SOURCE_DIRECTORY}/tests/coverage/compare_gcov.py --action process --base-dir ${GCOV_DIR}) 36 | 37 | ENDFUNCTION() 38 | 39 | # Use after running gcov with the -l (--long-file-names) option to merge all the 40 | # gcov files from the input directory into one gcov file for each source file in 41 | # the output directory. 42 | FUNCTION(MERGE_GCOV INPUT_DIR OUTPUT_DIR SOURCE_DIR) 43 | FILE(MAKE_DIRECTORY ${OUTPUT_DIR}) 44 | 45 | EXECUTE_PROCESS(COMMAND python ${CTEST_SOURCE_DIRECTORY}/tests/coverage/compare_gcov.py --action merge --base-dir ${INPUT_DIR} --output-dir ${OUTPUT_DIR} --prefix ${SOURCE_DIR}) 46 | 47 | FILE(COPY ${INPUT_DIR}/data.json DESTINATION ${OUTPUT_DIR}) 48 | 49 | ENDFUNCTION() 50 | 51 | 52 | # Create tar file of gcov files 53 | FUNCTION(CREATE_GCOV_TAR BINARY_DIRECTORY OUTPUT_DIR) 54 | EXECUTE_PROCESS(COMMAND tar cfj gcov_${OUTPUT_DIR}.tar 55 | "--mtime=1970-01-01 0:0:0 UTC" 56 | ${OUTPUT_DIR} 57 | WORKING_DIRECTORY ${BINARY_DIRECTORY}) 58 | ENDFUNCTION() 59 | 60 | 61 | # Clear the coverage data files in preparation for another run 62 | FUNCTION(CLEAR_GCDA BINARY_DIRECTORY) 63 | FILE(GLOB_RECURSE GCDA_FILES "${BINARY_DIRECTORY}/*.gcda") 64 | FOREACH(GCDA_FILE ${GCDA_FILES}) 65 | FILE(REMOVE ${GCDA_FILE}) 66 | ENDFOREACH() 67 | ENDFUNCTION() 68 | 69 | 70 | # Compare two coverage runs 71 | FUNCTION(COMPARE_GCOV BASE_DIR UNIT_DIR OUTPUT_DIR REL_OUTPUT_DIR) 72 | FILE(MAKE_DIRECTORY ${OUTPUT_DIR}) 73 | 74 | EXECUTE_PROCESS(COMMAND python ${CTEST_SOURCE_DIRECTORY}/tests/coverage/compare_gcov.py --action compare --base-dir ${BASE_DIR} --unit-dir ${UNIT_DIR} --output-dir ${OUTPUT_DIR}) 75 | 76 | 77 | FILE(WRITE ${OUTPUT_DIR}/data.json 78 | "{ 79 | \"Source\":\"${CTEST_SOURCE_DIRECTORY}\", 80 | \"Binary\":\"${CTEST_BINARY_DIRECTORY}\" 81 | }") 82 | 83 | #FILE(RELATIVE_PATH REL_OUTPUT_DIR ${CTEST_BINARY_DIRECTORY} ${OUTPUT_DIR}) 84 | ##MESSAGE("*** Relative output dir = ${REL_OUTPUT_DIR}") 85 | 86 | EXECUTE_PROCESS(COMMAND tar cfj gcov.tar 87 | "--mtime=1970-01-01 0:0:0 UTC" 88 | ${REL_OUTPUT_DIR} 89 | WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY}) 90 | 91 | ENDFUNCTION() 92 | 93 | -------------------------------------------------------------------------------- /CMake/ctest_script.cmake: -------------------------------------------------------------------------------- 1 | # ctest script for building, running, and submitting the test results 2 | # Usage: ctest -s script,build 3 | # build = debug / optimized / valgrind / coverage 4 | # Note: this test will use use the number of processors defined in the variable N_PROCS, 5 | # the environment variables 6 | # N_PROCS, or the number of processors available (if not specified) 7 | # N_PROCS_BUILD, or N_PROCS (if not specified) 8 | # N_CONCURRENT_TESTS, or N_PROCS (if not specified) 9 | # TEST_SITE_NAME, or HOSTNAME (if not specified) 10 | 11 | # Get the source directory based on the current directory 12 | IF ( NOT QMC_SOURCE_DIR ) 13 | SET( QMC_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ) 14 | ENDIF() 15 | IF ( NOT MAKE_CMD ) 16 | SET( MAKE_CMD make ) 17 | ENDIF() 18 | 19 | # Check that we specified the build type to run 20 | IF ( DEFINED ENV{MINIQMC_TEST_SUBMIT_NAME} ) 21 | SET( CTEST_BUILD_NAME "$ENV{MINIQMC_TEST_SUBMIT_NAME}" ) 22 | ELSE() 23 | SET( CTEST_BUILD_NAME "MINIQMC_TEST_SUBMIT_NAME-unset" ) 24 | ENDIF() 25 | 26 | # Set the number of processors 27 | IF( DEFINED ENV{N_PROCS} ) 28 | SET( N_PROCS $ENV{N_PROCS} ) 29 | ELSE() 30 | SET(N_PROCS 1) 31 | # Linux: 32 | SET(cpuinfo_file "/proc/cpuinfo") 33 | IF(EXISTS "${cpuinfo_file}") 34 | FILE(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") 35 | list(LENGTH procs N_PROCS) 36 | ENDIF() 37 | # Mac: 38 | IF(APPLE) 39 | find_program(cmd_sys_pro "system_profiler") 40 | if(cmd_sys_pro) 41 | execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info) 42 | STRING(REGEX REPLACE "^.*Total Number of Cores: ([0-9]+).*$" "\\1" N_PROCS "${info}") 43 | ENDIF() 44 | ENDIF() 45 | # Windows: 46 | IF(WIN32) 47 | SET(N_PROCS "$ENV{NUMBER_OF_PROCESSORS}") 48 | ENDIF() 49 | ENDIF() 50 | 51 | MESSAGE("Testing with ${N_PROCS} processors") 52 | 53 | # Set the number of processors for compilation and running tests 54 | IF( DEFINED ENV{N_PROCS_BUILD} ) 55 | SET( N_PROCS_BUILD $ENV{N_PROCS_BUILD} ) 56 | ELSE() 57 | SET( N_PROCS_BUILD ${N_PROCS} ) 58 | ENDIF() 59 | 60 | IF( DEFINED ENV{N_CONCURRENT_TESTS} ) 61 | SET( N_CONCURRENT_TESTS $ENV{N_CONCURRENT_TESTS} ) 62 | ELSE() 63 | SET( N_CONCURRENT_TESTS ${N_PROCS} ) 64 | ENDIF() 65 | 66 | # Set basic variables 67 | SET( CTEST_PROJECT_NAME "miniQMC" ) 68 | SET( CTEST_SOURCE_DIRECTORY "${QMC_SOURCE_DIR}" ) 69 | SET( CTEST_BINARY_DIRECTORY "." ) 70 | SET( CTEST_DASHBOARD "Nightly" ) 71 | SET( CTEST_TEST_TIMEOUT 900 ) 72 | SET( CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 500 ) 73 | SET( CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 500 ) 74 | SET( CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 100000 ) 75 | SET( CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 100000 ) 76 | SET( NIGHTLY_START_TIME "18:00:00 EST" ) 77 | SET( CTEST_NIGHTLY_START_TIME "22:00:00 EST" ) 78 | SET( CTEST_COMMAND "\"${CTEST_EXECUTABLE_NAME}\" -D ${CTEST_DASHBOARD}" ) 79 | SET( CTEST_USE_LAUNCHERS TRUE ) 80 | 81 | IF ( BUILD_SERIAL ) 82 | SET( CTEST_BUILD_COMMAND "${MAKE_CMD} -i" ) 83 | ELSE ( BUILD_SERIAL ) 84 | SET( CTEST_BUILD_COMMAND "${MAKE_CMD} -i -j ${N_PROCS_BUILD}" ) 85 | MESSAGE("Building with ${N_PROCS_BUILD} processors") 86 | ENDIF( BUILD_SERIAL ) 87 | 88 | # Clear the binary directory and create an initial cache 89 | CTEST_EMPTY_BINARY_DIRECTORY( ${CTEST_BINARY_DIRECTORY} ) 90 | FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "CTEST_TEST_CTEST:BOOL=1") 91 | 92 | MESSAGE("Configure options: ${CMAKE_CONFIGURE_OPTIONS}") 93 | 94 | SET( CTEST_CMAKE_GENERATOR "Unix Makefiles") 95 | 96 | IF ( DEFINED ENV{TEST_SITE_NAME} ) 97 | SET( CTEST_SITE $ENV{TEST_SITE_NAME} ) 98 | ELSE() 99 | SITE_NAME( HOSTNAME ) 100 | SET( CTEST_SITE ${HOSTNAME} ) 101 | ENDIF() 102 | 103 | # Run the configure 104 | CTEST_START("${CTEST_DASHBOARD}") 105 | CTEST_UPDATE() 106 | CTEST_CONFIGURE( 107 | BUILD ${CTEST_BINARY_DIRECTORY} 108 | SOURCE ${CTEST_SOURCE_DIRECTORY} 109 | OPTIONS "${CMAKE_CONFIGURE_OPTIONS}" 110 | ) 111 | 112 | 113 | # Run the build 114 | CTEST_BUILD() 115 | 116 | # Run and submit unclassified tests to the default track 117 | CTEST_TEST( EXCLUDE_LABEL "performance" PARALLEL_LEVEL ${N_CONCURRENT_TESTS} ) 118 | CTEST_SUBMIT( PARTS Test ) 119 | 120 | # Submit the results to oblivion 121 | SET( CTEST_DROP_METHOD "https" ) 122 | SET( CTEST_DROP_SITE "cdash.qmcpack.org" ) 123 | SET( CTEST_DROP_LOCATION "/CDash/submit.php?project=miniQMC" ) 124 | SET( CTEST_DROP_SITE_CDASH TRUE ) 125 | SET( DROP_SITE_CDASH TRUE ) 126 | CTEST_SUBMIT( PARTS Configure Build Test ) 127 | 128 | # Run and submit the classified tests to their corresponding track 129 | CTEST_START( "${CTEST_DASHBOARD}" TRACK "Performance" APPEND) 130 | CTEST_TEST( INCLUDE_LABEL "performance" PARALLEL_LEVEL 16 ) 131 | CTEST_SUBMIT( PARTS Test ) 132 | -------------------------------------------------------------------------------- /CMake/python.cmake: -------------------------------------------------------------------------------- 1 | # Support functions for handling python scripts 2 | 3 | # Test whether a python modules is present 4 | # MODULE_NAME - input, name of module to test for 5 | # MODULE_PRESENT - output - True/False based on success of the import 6 | FUNCTION (TEST_PYTHON_MODULE MODULE_NAME MODULE_PRESENT) 7 | EXECUTE_PROCESS( 8 | COMMAND python ${miniqmc_SOURCE_DIR}/utils/test_import.py ${MODULE_NAME} 9 | OUTPUT_VARIABLE TMP_OUTPUT_VAR 10 | OUTPUT_STRIP_TRAILING_WHITESPACE 11 | ) 12 | SET(${MODULE_PRESENT} ${TMP_OUTPUT_VAR} PARENT_SCOPE) 13 | ENDFUNCTION() 14 | 15 | # Test python module prerequisites for a particular test script 16 | # module_list - input - list of module names 17 | # test_name - input - name of test (used for missing module message) 18 | # add_test - output - true if all modules are present, false otherwise 19 | FUNCTION(CHECK_PYTHON_REQS module_list test_name add_test) 20 | set(${add_test} true PARENT_SCOPE) 21 | foreach(python_module IN LISTS ${module_list}) 22 | TEST_PYTHON_MODULE(${python_module} has_python_module) 23 | if (NOT(has_python_module)) 24 | MESSAGE("Missing python module ${python_module}, not adding test ${test_name}") 25 | set(${add_test} false PARENT_SCOPE) 26 | endif() 27 | endforeach() 28 | ENDFUNCTION() 29 | 30 | -------------------------------------------------------------------------------- /CMake/unit_test.cmake: -------------------------------------------------------------------------------- 1 | # Runs unit tests 2 | FUNCTION( ADD_UNIT_TEST TESTNAME TEST_BINARY ) 3 | MESSAGE("Adding test ${TESTNAME}") 4 | IF ( USE_MPI ) 5 | ADD_TEST(NAME ${TESTNAME} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 1 ${TEST_BINARY}) 6 | #SET_TESTS_PROPERTIES( ${TESTNAME} PROPERTIES ENVIRONMENT OMP_NUM_THREADS=1 ) 7 | ELSE() 8 | ADD_TEST(NAME ${TESTNAME} COMMAND ${TEST_BINARY}) 9 | #SET_TESTS_PROPERTIES( ${TESTNAME} PROPERTIES ENVIRONMENT OMP_NUM_THREADS=1 ) 10 | ENDIF() 11 | SET_PROPERTY(TEST ${TESTNAME} APPEND PROPERTY LABELS "unit") 12 | ENDFUNCTION() 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Important Notice for qmcpack developers and end-users: 2 | 3 | i) The original programs developed by Jeongnim Kim and her collaborators 4 | are distributed under UIUC/NCSA Open Source License (below). 5 | 6 | ii) Some packages/features are not available under open source license and require 7 | separate license agreements with the authors. Contact the responsible authors. 8 | 9 | iii) autoconf/automake scripts are distributed under GPL (see COPYING). 10 | 11 | iv) The sources derived from any package distributed under GPL contain 12 | explicit acknowledgments of the original works and are distributed under GPL. 13 | 14 | ------------- 15 | University of Illinois/NCSA Open Source License 16 | 17 | Copyright (c) 2003, University of Illinois Board of Trustees. 18 | All rights reserved. 19 | 20 | Developed by: 21 | Jeongnim Kim 22 | Condensed Matter Physics, 23 | National Center for Supercomputing Applications, University of Illinois 24 | Materials computation Center, University of Illinois 25 | http://www.mcc.uiuc.edu/qmc/ 26 | 27 | Permission is hereby granted, free of charge, to any person obtaining a 28 | copy of this software and associated documentation files (the 29 | ``Software''), to deal with the Software without restriction, including 30 | without limitation the rights to use, copy, modify, merge, publish, 31 | distribute, sublicense, and/or sell copies of the Software, and to 32 | permit persons to whom the Software is furnished to do so, subject to 33 | the following conditions: 34 | 35 | * Redistributions of source code must retain the above copyright 36 | notice, this list of conditions and the following disclaimers. 37 | * Redistributions in binary form must reproduce the above copyright 38 | notice, this list of conditions and the following disclaimers in 39 | the documentation and/or other materials provided with the 40 | distribution. 41 | * Neither the names of the NCSA, the MCC, the University of Illinois, 42 | nor the names of its contributors may be used to endorse or promote 43 | products derived from this Software without specific prior written 44 | permission. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 47 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 50 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 51 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 52 | OTHER DEALINGS WITH THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # miniQMC - QMCPACK Miniapp 2 | 3 | **This is the CPU only version of miniQMC. OpenMP offload version is in the [OMP_offload](https://github.com/QMCPACK/miniqmc/tree/OMP_offload) branch.** 4 | 5 | # Documentation and support 6 | 1. Out-of-source documentation at https://github.com/QMCPACK/miniqmc/wiki 7 | 2. In-source doxygen documentation can be created via 'doxygen Doxyfile'. The 8 | HTML pages will be in the html/ directory with the top level file in 9 | 'html/index.html'. 10 | 3. Any issue or discussion, please use github issue. 11 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo Configuring and building froom inside the build directory. 3 | echo Check the results of the CMake configuration to ensure that the preferred 4 | echo compilers and libraries have been selected. See README and documentation 5 | echo for guidance. 6 | cd build; cmake ..; make; cd .. 7 | -------------------------------------------------------------------------------- /build/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | echo 3 | echo ' You are not running autoconf/automake tools!' 4 | echo ' To build qmcpack, cmake, lapack/blas, hdf5 and boost are required.' 5 | echo ' Check http://www.qmcpack.org' 6 | echo 7 | 8 | tcmake=`which cmake` 9 | if test $tcmake; then 10 | echo ' cd build; cmake ..; make' 11 | cd build; cmake ..; make 12 | else 13 | echo 14 | echo ' cmake is not found. Get cmake at http://www.cmake.org/' 15 | fi 16 | -------------------------------------------------------------------------------- /external_codes/catch/Readme: -------------------------------------------------------------------------------- 1 | C++ Unit test framework 2 | 3 | https://github.com/catchorg/Catch2 4 | 5 | The single include file is downloaded from here: 6 | https://github.com/catchorg/Catch2/releases/download/v2.4.2/catch.hpp 7 | 8 | The default value of m_scale in Approx was changed from 0.0 to 1.0 to match the 9 | original Catch behavior, and to avoid adding .scale(1.0) all over the code. 10 | 11 | -------------------------------------------------------------------------------- /external_codes/catch/complex_approx.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CATCH_COMPLEX_APPROX 2 | #define CATCH_COMPLEX_APPROX 3 | 4 | #include 5 | #include 6 | 7 | // Copy and modify the Approx class to handle complex numbers 8 | 9 | namespace Catch { 10 | namespace Detail { 11 | class ComplexApprox 12 | { 13 | std::complex m_value; 14 | double m_epsilon; 15 | 16 | bool approx_compare_zero(const double dist, const double magnitude) const 17 | { 18 | /* need to workaround catch to provide consistent behavior for a real value. 19 | bool Approx::equalityComparisonImpl(const double other) const { 20 | return marginComparison(m_value, other, m_margin) || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(m_value))); 21 | } 22 | */ 23 | return Approx(dist).epsilon(0.0).margin(m_epsilon * (1.0 + magnitude)) == 0.0; 24 | } 25 | 26 | public: 27 | ComplexApprox(const std::complex &value) : m_value(value) { 28 | init_epsilon(); 29 | } 30 | 31 | ComplexApprox(const std::complex &value) : m_value(value) { 32 | init_epsilon(); 33 | } 34 | 35 | ComplexApprox(const double &value) : m_value(value) { 36 | init_epsilon(); 37 | } 38 | 39 | ComplexApprox(const float &value) : m_value(value) { 40 | init_epsilon(); 41 | } 42 | 43 | void init_epsilon() { 44 | // Copied from catch.hpp - would be better to copy it from Approx object 45 | m_epsilon = std::numeric_limits::epsilon()*100; 46 | } 47 | 48 | ComplexApprox& epsilon(double new_epsilon) 49 | { 50 | m_epsilon = new_epsilon; 51 | return *this; 52 | } 53 | 54 | double epsilon() const 55 | { 56 | return m_epsilon; 57 | } 58 | 59 | friend bool operator == (std::complex const& lhs, ComplexApprox const& rhs) 60 | { 61 | return rhs.approx_compare_zero(std::abs(lhs - rhs.m_value), std::abs(rhs.m_value)); 62 | } 63 | 64 | friend bool operator == (std::complex const& lhs, ComplexApprox const& rhs) 65 | { 66 | return rhs.approx_compare_zero(std::abs(std::complex(lhs) - rhs.m_value), std::abs(rhs.m_value)); 67 | } 68 | 69 | friend bool operator == (ComplexApprox const &lhs, std::complex const& rhs) 70 | { 71 | return operator==( rhs, lhs ); 72 | } 73 | 74 | friend bool operator == (ComplexApprox const &lhs, std::complex const& rhs) 75 | { 76 | return operator==( rhs, lhs ); 77 | } 78 | 79 | std::string toString() const { 80 | std::ostringstream oss; 81 | oss <<"ComplexApprox( " << ::Catch::Detail::stringify(m_value) << " )"; 82 | return oss.str(); 83 | } 84 | 85 | friend std::ostream& operator << ( std::ostream& os, ComplexApprox const& ca ) 86 | { 87 | os << ca.toString(); 88 | return os; 89 | } 90 | }; 91 | } 92 | 93 | template<> 94 | struct StringMaker { 95 | static std::string convert(Catch::Detail::ComplexApprox const &value); 96 | }; 97 | 98 | #ifdef CATCH_IMPL 99 | std::string StringMaker::convert(Catch::Detail::ComplexApprox const& value) 100 | { 101 | return value.toString(); 102 | } 103 | #endif 104 | 105 | } 106 | 107 | using Catch::Detail::ComplexApprox; 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /external_codes/catch/log_complex_approx.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CATCH_LOG_COMPLEX_APPROX 2 | #define CATCH_LOG_COMPLEX_APPROX 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | // Copy and modify the ComplexApprox class to handle complex numbers for log(complex) 9 | 10 | namespace Catch { 11 | namespace Detail { 12 | class LogComplexApprox 13 | { 14 | std::complex m_value; 15 | double m_epsilon; 16 | 17 | public: 18 | 19 | LogComplexApprox(const std::complex &value) : m_value(value) { 20 | init_epsilon(); 21 | } 22 | 23 | LogComplexApprox(const std::complex &value) : m_value(value) { 24 | init_epsilon(); 25 | } 26 | 27 | LogComplexApprox(const double &value) : m_value(value) { 28 | init_epsilon(); 29 | } 30 | 31 | LogComplexApprox(const float &value) : m_value(value) { 32 | init_epsilon(); 33 | } 34 | 35 | void init_epsilon() { 36 | // Copied from catch.hpp - would be better to copy it from Approx object 37 | m_epsilon = std::numeric_limits::epsilon()*100; 38 | } 39 | 40 | LogComplexApprox& epsilon(double new_epsilon) 41 | { 42 | m_epsilon = new_epsilon; 43 | return *this; 44 | } 45 | 46 | double epsilon() const 47 | { 48 | return m_epsilon; 49 | } 50 | 51 | friend bool operator == (std::complex const& lhs, LogComplexApprox const& rhs) 52 | { 53 | return std::exp(lhs) == ComplexApprox(std::exp(rhs.m_value)).epsilon(rhs.m_epsilon); 54 | } 55 | 56 | friend bool operator == (std::complex const& lhs, LogComplexApprox const& rhs) 57 | { 58 | return std::exp(lhs) == ComplexApprox(std::exp(rhs.m_value)).epsilon(rhs.m_epsilon); 59 | } 60 | 61 | friend bool operator == (LogComplexApprox const &lhs, std::complex const& rhs) 62 | { 63 | return operator==( rhs, lhs ); 64 | } 65 | 66 | friend bool operator == (LogComplexApprox const &lhs, std::complex const& rhs) 67 | { 68 | return operator==( rhs, lhs ); 69 | } 70 | 71 | std::string toString() const { 72 | std::ostringstream oss; 73 | oss <<"LogComplexApprox( " << ::Catch::Detail::stringify(m_value) << " )"; 74 | return oss.str(); 75 | } 76 | 77 | friend std::ostream& operator << ( std::ostream& os, LogComplexApprox const& ca ) 78 | { 79 | os << ca.toString(); 80 | return os; 81 | } 82 | }; 83 | } 84 | 85 | template<> 86 | struct StringMaker { 87 | static std::string convert(Catch::Detail::LogComplexApprox const &value); 88 | }; 89 | 90 | #ifdef CATCH_IMPL 91 | std::string StringMaker::convert(Catch::Detail::LogComplexApprox const& value) 92 | { 93 | return value.toString(); 94 | } 95 | #endif 96 | } 97 | 98 | using Catch::Detail::LogComplexApprox; 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /miniqmc.settings: -------------------------------------------------------------------------------- 1 | #qmcpack variables 2 | QMCPACK_VERSION = @QMCPACK_VERSION@ 3 | # See qmcpack --version for the most up-to-date information about the 4 | # most recent git commit 5 | 6 | QMC_MPI = @QMC_MPI@ 7 | QMC_OMP = @QMC_OMP@ 8 | QMC_COMPLEX = @QMC_COMPLEX@ 9 | BUILD_AFQMC = @BUILD_AFQMC@ 10 | BUILD_FCIQMC = @BUILD_FCIQMC@ 11 | 12 | #system variables 13 | QMC_HOSTNAME = @QMC_HOSTNAME@ 14 | SYSTEM = @CMAKE_SYSTEM@ 15 | SYSTEM_NAME = @CMAKE_SYSTEM_NAME@ 16 | SYSTEM_PROCESSOR = @CMAKE_SYSTEM_PROCESSOR@ 17 | SYSTEM_VERSION = @CMAKE_SYSTEM_VERSION@ 18 | CMAKE_VERSION = @CMAKE_VERSION@ 19 | CMAKE_BUILD_TYPE = @CMAKE_BUILD_TYPE@ 20 | 21 | CXX_COMPILER = @CMAKE_CXX_COMPILER@ 22 | CXX_COMPILER_ID = @CMAKE_CXX_COMPILER_ID@ 23 | CXX_FLAGS = @CMAKE_CXX_FLAGS@ 24 | 25 | C_COMPILER = @CMAKE_C_COMPILER@ 26 | C_FLAGS = @CMAKE_C_FLAGS@ 27 | 28 | LAPACK_LIBRARIES = @LAPACK_LIBRARIES@ 29 | HDF5_INCLUDE_DIR = @HDF5_INCLUDE_DIR@ 30 | HDF5_LIBRARIES = @HDF5_LIBRARIES@ 31 | LIBXML2_INCLUDE_DIR = @LIBXML2_INCLUDE_DIR@ 32 | LIBXML2_LIBRARIES = @LIBXML2_LIBRARIES@ 33 | FFTW_INCLUDE_DIR = @FFTW_INCLUDE_DIR@ 34 | FFTW_LIBRARIES = @FFTW_LIBRARIES@ 35 | Boost_INCLUDE_DIR = @Boost_INCLUDE_DIR@ 36 | -------------------------------------------------------------------------------- /src/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -2 4 | AlignAfterOpenBracket: Align 5 | AlignConsecutiveAssignments: true 6 | AlignConsecutiveDeclarations: false 7 | AlignEscapedNewlines: Left 8 | AlignOperands: false 9 | AlignTrailingComments: true 10 | AllowAllParametersOfDeclarationOnNextLine: false 11 | AllowShortBlocksOnASingleLine: true 12 | AllowShortCaseLabelsOnASingleLine: false 13 | AllowShortFunctionsOnASingleLine: All 14 | AllowShortIfStatementsOnASingleLine: false 15 | AllowShortLoopsOnASingleLine: false 16 | AlwaysBreakAfterDefinitionReturnType: None 17 | AlwaysBreakAfterReturnType: None 18 | AlwaysBreakBeforeMultilineStrings: false 19 | AlwaysBreakTemplateDeclarations: true 20 | BinPackArguments: true 21 | BinPackParameters: false 22 | BraceWrapping: 23 | AfterClass: true 24 | AfterControlStatement: true 25 | AfterEnum: true 26 | AfterFunction: true 27 | AfterNamespace: true 28 | AfterObjCDeclaration: true 29 | AfterStruct: true 30 | AfterUnion: true 31 | AfterExternBlock: true 32 | BeforeCatch: true 33 | BeforeElse: true 34 | IndentBraces: false 35 | SplitEmptyFunction: false 36 | SplitEmptyRecord: false 37 | SplitEmptyNamespace: false 38 | BreakBeforeBinaryOperators: None 39 | BreakBeforeBraces: Custom 40 | BreakBeforeInheritanceComma: false 41 | BreakBeforeTernaryOperators: true 42 | BreakConstructorInitializersBeforeComma: false 43 | BreakConstructorInitializers: BeforeColon 44 | BreakAfterJavaFieldAnnotations: false 45 | BreakStringLiterals: true 46 | ColumnLimit: 120 47 | CommentPragmas: '^ IWYU pragma:' 48 | CompactNamespaces: false 49 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 50 | ConstructorInitializerIndentWidth: 4 51 | ContinuationIndentWidth: 4 52 | Cpp11BracedListStyle: true 53 | DerivePointerAlignment: false 54 | DisableFormat: false 55 | ExperimentalAutoDetectBinPacking: false 56 | FixNamespaceComments: true 57 | ForEachMacros: 58 | - foreach 59 | - Q_FOREACH 60 | - BOOST_FOREACH 61 | IncludeBlocks: Preserve 62 | IncludeCategories: 63 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 64 | Priority: 2 65 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 66 | Priority: 3 67 | - Regex: '.*' 68 | Priority: 1 69 | IncludeIsMainRegex: '(Test)?$' 70 | IndentCaseLabels: false 71 | IndentPPDirectives: None 72 | IndentWidth: 2 73 | IndentWrappedFunctionNames: true 74 | JavaScriptQuotes: Leave 75 | JavaScriptWrapImports: true 76 | KeepEmptyLinesAtTheStartOfBlocks: false 77 | MacroBlockBegin: '' 78 | MacroBlockEnd: '' 79 | MaxEmptyLinesToKeep: 2 80 | NamespaceIndentation: None 81 | ObjCBlockIndentWidth: 2 82 | ObjCSpaceAfterProperty: false 83 | ObjCSpaceBeforeProtocolList: true 84 | PenaltyBreakAssignment: 2 85 | PenaltyBreakBeforeFirstCallParameter: 30000 86 | PenaltyBreakComment: 300 87 | PenaltyBreakFirstLessLess: 120 88 | PenaltyBreakString: 1000 89 | PenaltyExcessCharacter: 1000000 90 | PenaltyReturnTypeOnItsOwnLine: 10000 91 | PointerAlignment: Left 92 | ReflowComments: false 93 | SortIncludes: false 94 | SortUsingDeclarations: true 95 | SpaceAfterCStyleCast: false 96 | SpaceAfterTemplateKeyword: false 97 | SpaceBeforeAssignmentOperators: true 98 | SpaceBeforeParens: ControlStatements 99 | SpaceInEmptyParentheses: false 100 | SpacesBeforeTrailingComments: 1 101 | SpacesInAngles: false 102 | SpacesInContainerLiterals: true 103 | SpaceBeforeCtorInitializerColon: true 104 | SpaceBeforeInheritanceColon: true 105 | SpaceBeforeRangeBasedForLoopColon: true 106 | SpaceInEmptyParentheses: false 107 | SpacesInCStyleCastParentheses: false 108 | SpacesInParentheses: false 109 | SpacesInSquareBrackets: false 110 | Standard: Cpp11 111 | TabWidth: 8 112 | UseTab: Never 113 | ... 114 | 115 | -------------------------------------------------------------------------------- /src/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #////////////////////////////////////////////////////////////////////////////////////// 2 | #// This file is distributed under the University of Illinois/NCSA Open Source License. 3 | #// See LICENSE file in top directory for details. 4 | #// 5 | #// Copyright (c) 2019 QMCPACK developers. 6 | #// 7 | #// File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | #// 9 | #// File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | #////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | SET(DRIVERS check_spo check_wfc miniqmc miniqmc_sync_move) 13 | 14 | FOREACH(p ${DRIVERS}) 15 | ADD_EXECUTABLE( ${p} ${p}.cpp) 16 | TARGET_LINK_LIBRARIES(${p} qmcwfs qmcbase qmcutil ${QMC_UTIL_LIBS}) 17 | ENDFOREACH(p ${ESTEST}) 18 | 19 | SUBDIRS(tests) 20 | 21 | -------------------------------------------------------------------------------- /src/Drivers/MiniQMCOptions.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 9 | // 10 | // File created by: 11 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef QMCPLUSPLUS_MINIQMC_OPTIONS_H 15 | #define QMCPLUSPLUS_MINIQMC_OPTIONS_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include "Utilities/qmcpack_version.h" 21 | #include "Utilities/NewTimer.h" 22 | 23 | namespace qmcplusplus 24 | { 25 | enum MiniQMCTimers 26 | { 27 | Timer_Total, 28 | Timer_Init, 29 | Timer_Diffusion, 30 | Timer_ECP, 31 | Timer_Value, 32 | Timer_evalGrad, 33 | Timer_evalVGH, 34 | Timer_ratioGrad, 35 | Timer_Update, 36 | }; 37 | 38 | /** Reads and holds the options to support more flexible non 'c main()' drivers 39 | * 40 | */ 41 | class MiniQMCOptions 42 | { 43 | public: 44 | TimerNameList_t MiniQMCTimerNames{ 45 | {Timer_Total, "Total"}, 46 | {Timer_Init, "Initialization"}, 47 | {Timer_Diffusion, "Diffusion"}, 48 | {Timer_ECP, "Pseudopotential"}, 49 | {Timer_Value, "Value"}, 50 | {Timer_evalGrad, "Current Gradient"}, 51 | {Timer_evalVGH, "Spline Hessian Evaluation"}, 52 | {Timer_ratioGrad, "New Gradient"}, 53 | {Timer_Update, "Update"}, 54 | }; 55 | 56 | static void print_help(); 57 | 58 | using QMCT = QMCTraits; 59 | //Devices device = Devices::CPU; 60 | bool valid = true; 61 | //int device_number = 0; 62 | int na = 1; 63 | int nb = 1; 64 | int nc = 1; 65 | int nsteps = 5; 66 | int iseed = 11; 67 | int nx = 37, ny = 37, nz = 37; 68 | int num_crowds = 1; 69 | int splines_per_block = -1; 70 | int nsubsteps = 1; 71 | int nels = 0; 72 | // Set cutoff for NLPP use. 73 | // This makes precision an issue to select at run time. 74 | QMCT::RealType Rmax = 1.7; 75 | QMCT::RealType accept_ratio = 0.5; 76 | //useRef is a particular implementation of numerous objects fix that remove this option 77 | //and many branch statements 78 | bool useRef = false; 79 | bool enableJ3 = false; 80 | bool enableCrowd = false; 81 | bool verbose = false; 82 | std::string timer_level_name = "fine"; 83 | TimerList_t Timers; 84 | int crowd_size = 1; 85 | int walkers_per_rank = 0; 86 | MiniQMCOptions() = default; 87 | MiniQMCOptions(const MiniQMCOptions&) = default; 88 | }; 89 | 90 | MiniQMCOptions readOptions(int argc,char** argv); 91 | 92 | } // namespace qmcplusplus 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /src/Drivers/Mover.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Ye Luo, yeluo@anl.gov, 9 | // Argonne National Laboratory 10 | // 11 | // File created by: 12 | // Ye Luo, yeluo@anl.gov, 13 | // Argonne National Laboratory 14 | //////////////////////////////////////////////////////////////////////////////// 15 | // -*- C++ -*- 16 | 17 | /** 18 | * @file Mover.h 19 | * @brief Declaration of Mover class 20 | * 21 | */ 22 | 23 | #ifndef QMCPLUSPLUS_MOVER_HPP 24 | #define QMCPLUSPLUS_MOVER_HPP 25 | 26 | #include 27 | #include 28 | #include 29 | #include "QMCWaveFunctions/SPOSet.h" 30 | #include 31 | #include 32 | #include 33 | 34 | namespace qmcplusplus 35 | { 36 | /** 37 | * @brief Container class includes all the classes required to operate walker moves 38 | * 39 | * Movers are distinct from walkers. Walkers are lightweight in memory, while 40 | * Movers carry additional data needed to evolve the walkers efficiently. 41 | * In a memory capacity limited scenario, a limited number of movers can be used to 42 | * handle a large amount of walkers. 43 | * 44 | * This class is used only by QMC drivers. 45 | */ 46 | struct Mover 47 | { 48 | using RealType = QMCTraits::RealType; 49 | 50 | /// random number generator 51 | RandomGenerator rng; 52 | /// electrons 53 | ParticleSet els; 54 | /// wavefunction container 55 | WaveFunction wavefunction; 56 | /// non-local pseudo-potentials 57 | NonLocalPP nlpp; 58 | 59 | /// constructor 60 | Mover(const uint32_t myPrime, const ParticleSet& ions) : rng(myPrime), nlpp(rng, ions) 61 | { 62 | build_els(els, ions, rng); 63 | } 64 | }; 65 | 66 | inline void FairDivideLow(int ntot, int nparts, int me, int& first, int& last) 67 | { 68 | int bat = ntot / nparts; 69 | int residue = nparts - ntot % nparts; 70 | if(me extract_sub_list(const std::vector& mover_list, int first, int last) 83 | { 84 | std::vector sub_list; 85 | for (auto it = mover_list.begin() + first; it != mover_list.begin() + last; it++) 86 | sub_list.push_back(*it); 87 | return sub_list; 88 | } 89 | 90 | const std::vector extract_els_list(const std::vector& mover_list) 91 | { 92 | std::vector els_list; 93 | for (auto it = mover_list.begin(); it != mover_list.end(); it++) 94 | els_list.push_back(&(*it)->els); 95 | return els_list; 96 | } 97 | 98 | const std::vector extract_wf_list(const std::vector& mover_list) 99 | { 100 | std::vector wf_list; 101 | for (auto it = mover_list.begin(); it != mover_list.end(); it++) 102 | wf_list.push_back(&(*it)->wavefunction); 103 | return wf_list; 104 | } 105 | 106 | const std::vector*> extract_nlpp_list(const std::vector& mover_list) 107 | { 108 | std::vector*> nlpp_list; 109 | for (auto it = mover_list.begin(); it != mover_list.end(); it++) 110 | nlpp_list.push_back(&(*it)->nlpp); 111 | return nlpp_list; 112 | } 113 | 114 | } // namespace qmcplusplus 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /src/Drivers/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #////////////////////////////////////////////////////////////////////////////////////// 2 | #// This file is distributed under the University of Illinois/NCSA Open Source License. 3 | #// See LICENSE file in top directory for details. 4 | #// 5 | #// Copyright (c) 2020 QMCPACK developers. 6 | #// 7 | #// File developed by: 8 | #// Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 9 | #// Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | #// 11 | #// File created by: 12 | #// Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 13 | #//////////////////////////////////////////////////////////////////////////////// 14 | 15 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QMCPACK_UNIT_TEST_DIR}) 16 | 17 | SET(SRC_DIR Drivers) 18 | SET(UTEST_EXE test_${SRC_DIR}) 19 | SET(UTEST_NAME unit_test_${SRC_DIR}) 20 | 21 | 22 | ADD_EXECUTABLE(${UTEST_EXE} ../MiniQMCOptions.cpp test_MiniQMCOptions.cpp) 23 | TARGET_LINK_LIBRARIES(${UTEST_EXE} catch_main qmcutil) 24 | 25 | ADD_UNIT_TEST(${UTEST_NAME} "${QMCPACK_UNIT_TEST_DIR}/${UTEST_EXE}") 26 | 27 | RUN_APP(miniqmc-g111-r1-t16 miniqmc 1 16 miniqmc TEST_ADDED) 28 | RUN_APP(miniqmc_sync_move-g111-r1-t16 miniqmc_sync_move 1 16 miniqmc TEST_ADDED) 29 | RUN_APP(check_spo-g111-r1-t16 check_spo 1 16 check TEST_ADDED) 30 | RUN_APP(check_wfc-g111-r1-t16 check_wfc 1 16 check TEST_ADDED) 31 | -------------------------------------------------------------------------------- /src/Drivers/tests/test_MiniQMCOptions.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 9 | // 10 | // File created by: 11 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include 15 | #include 16 | #include "catch.hpp" 17 | #include "Drivers/MiniQMCOptions.h" 18 | 19 | /** @file 20 | * 21 | * For now we omit testing help and version output 22 | */ 23 | 24 | namespace qmcplusplus 25 | { 26 | 27 | TEST_CASE("MiniQMCOptions Read", "[Application]") { 28 | int argc = 28; 29 | std::vector opt_strs = {"dummy_progname", 30 | "-a","256", 31 | "-b", 32 | "-c","8", 33 | "-g","2 1 3", 34 | "-j", 35 | "-m","256", 36 | "-n","10", 37 | "-N","1", 38 | "-r","0.75", 39 | "-s","140", 40 | "-t","fine", 41 | "-v", 42 | "-w","200", 43 | "-C","10", 44 | "-x","1.7" 45 | }; 46 | 47 | std::vector option_ptrs; 48 | option_ptrs.reserve(argc + 1); 49 | std::transform(begin(opt_strs), end(opt_strs), 50 | std::back_inserter(option_ptrs), 51 | [](std::string& s) { char * ptr = new char[s.length() + 1]; 52 | std::strcpy(ptr, s.c_str() ); 53 | return ptr;}); 54 | option_ptrs.push_back(nullptr); 55 | MiniQMCOptions mq_opt = readOptions(argc, option_ptrs.data()); 56 | REQUIRE(mq_opt.valid); 57 | std::for_each(begin(option_ptrs), end(option_ptrs), 58 | [](char* c) { delete[] c; }); 59 | REQUIRE(mq_opt.splines_per_block == 256); 60 | REQUIRE(mq_opt.useRef); 61 | REQUIRE(mq_opt.crowd_size == 8); 62 | REQUIRE(mq_opt.num_crowds == 10); 63 | REQUIRE(mq_opt.na == 2); 64 | REQUIRE(mq_opt.nb == 1); 65 | REQUIRE(mq_opt.nc == 3); 66 | REQUIRE(mq_opt.enableJ3); 67 | REQUIRE(mq_opt.nx == 256 * 37); // PD: yes this 37 is hard coded into the options 68 | REQUIRE(mq_opt.ny == 256 * 37); // I carried it over from miniqmc_sync_move.cpp 69 | REQUIRE(mq_opt.nz == 256 * 37); 70 | REQUIRE(mq_opt.nsteps == 10); 71 | REQUIRE(mq_opt.nsubsteps == 1); 72 | REQUIRE(mq_opt.accept_ratio == 0.75); 73 | REQUIRE(mq_opt.iseed == 140); 74 | REQUIRE(mq_opt.timer_level_name == "fine"); 75 | REQUIRE(mq_opt.verbose); 76 | REQUIRE(mq_opt.walkers_per_rank == 200); 77 | REQUIRE(mq_opt.Rmax == ValueApprox(1.7)); 78 | 79 | 80 | } 81 | 82 | } 83 | 84 | -------------------------------------------------------------------------------- /src/Input/Input.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Ye Luo, yeluo@anl.gov, Argonne National Laboratory 9 | // 10 | // File created by: 11 | // Ye Luo, yeluo@anl.gov, Argonne National Laboratory 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef QMCPLUSPLUS_SIMULATION_HPP 15 | #define QMCPLUSPLUS_SIMULATION_HPP 16 | 17 | #include 18 | //#include 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/Numerics/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -2 4 | AlignAfterOpenBracket: Align 5 | AlignConsecutiveAssignments: true 6 | AlignConsecutiveDeclarations: false 7 | AlignEscapedNewlines: Left 8 | AlignOperands: false 9 | AlignTrailingComments: true 10 | AllowAllParametersOfDeclarationOnNextLine: true 11 | AllowShortBlocksOnASingleLine: true 12 | AllowShortCaseLabelsOnASingleLine: false 13 | AllowShortFunctionsOnASingleLine: All 14 | AllowShortIfStatementsOnASingleLine: true 15 | AllowShortLoopsOnASingleLine: false 16 | AlwaysBreakAfterDefinitionReturnType: None 17 | AlwaysBreakAfterReturnType: None 18 | AlwaysBreakBeforeMultilineStrings: false 19 | AlwaysBreakTemplateDeclarations: true 20 | BinPackArguments: true 21 | BinPackParameters: true 22 | BreakBeforeBraces: Custom 23 | BraceWrapping: 24 | AfterClass: true 25 | AfterControlStatement: true 26 | AfterEnum: true 27 | AfterFunction: true 28 | AfterNamespace: true 29 | AfterObjCDeclaration: true 30 | AfterStruct: true 31 | AfterUnion: true 32 | AfterExternBlock: true 33 | BeforeCatch: true 34 | BeforeElse: true 35 | IndentBraces: false 36 | SplitEmptyFunction: false 37 | SplitEmptyRecord: false 38 | SplitEmptyNamespace: false 39 | BreakBeforeBinaryOperators: None 40 | BreakBeforeInheritanceComma: false 41 | BreakBeforeTernaryOperators: true 42 | BreakConstructorInitializersBeforeComma: false 43 | BreakConstructorInitializers: BeforeColon 44 | BreakAfterJavaFieldAnnotations: false 45 | BreakStringLiterals: true 46 | ColumnLimit: 100 47 | CommentPragmas: '^ IWYU pragma:' 48 | CompactNamespaces: false 49 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 50 | ConstructorInitializerIndentWidth: 4 51 | ContinuationIndentWidth: 4 52 | Cpp11BracedListStyle: true 53 | DerivePointerAlignment: false 54 | DisableFormat: false 55 | ExperimentalAutoDetectBinPacking: true 56 | FixNamespaceComments: true 57 | ForEachMacros: 58 | - foreach 59 | - Q_FOREACH 60 | - BOOST_FOREACH 61 | IncludeBlocks: Preserve 62 | IncludeCategories: 63 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 64 | Priority: 2 65 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 66 | Priority: 3 67 | - Regex: '.*' 68 | Priority: 1 69 | IncludeIsMainRegex: '(Test)?$' 70 | IndentCaseLabels: false 71 | # @future IndentPPDirectives: BeforeHash 72 | IndentWidth: 2 73 | IndentWrappedFunctionNames: false 74 | JavaScriptQuotes: Leave 75 | JavaScriptWrapImports: true 76 | KeepEmptyLinesAtTheStartOfBlocks: false 77 | MacroBlockBegin: '' 78 | MacroBlockEnd: '' 79 | MaxEmptyLinesToKeep: 2 80 | NamespaceIndentation: None 81 | ObjCBlockIndentWidth: 2 82 | ObjCSpaceAfterProperty: false 83 | ObjCSpaceBeforeProtocolList: true 84 | PenaltyBreakAssignment: 1 85 | PenaltyBreakBeforeFirstCallParameter: 100000 86 | PenaltyBreakComment: 20 87 | PenaltyBreakFirstLessLess: 120 88 | PenaltyBreakString: 1000 89 | PenaltyExcessCharacter: 9 90 | PenaltyReturnTypeOnItsOwnLine: 8 91 | PointerAlignment: Left 92 | ReflowComments: false 93 | SortIncludes: false 94 | SortUsingDeclarations: false 95 | SpaceAfterCStyleCast: false 96 | SpaceAfterTemplateKeyword: false 97 | SpaceBeforeAssignmentOperators: true 98 | SpaceBeforeParens: ControlStatements 99 | SpaceInEmptyParentheses: false 100 | SpacesBeforeTrailingComments: 1 101 | SpacesInAngles: false 102 | SpacesInContainerLiterals: true 103 | SpaceBeforeCtorInitializerColon: true 104 | SpaceBeforeInheritanceColon: true 105 | SpaceBeforeRangeBasedForLoopColon: true 106 | SpaceInEmptyParentheses: false 107 | SpacesInCStyleCastParentheses: false 108 | SpacesInParentheses: false 109 | SpacesInSquareBrackets: false 110 | Standard: Cpp11 111 | TabWidth: 8 112 | UseTab: Never 113 | -------------------------------------------------------------------------------- /src/Numerics/BlasThreadingEnv.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | // 11 | ////////////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef QMCPLUSPLUS_BLAS_THREADING_ENV_H 14 | #define QMCPLUSPLUS_BLAS_THREADING_ENV_H 15 | 16 | #include "config.h" 17 | #include "Utilities/Configuration.h" 18 | #ifdef HAVE_MKL 19 | #include 20 | #endif 21 | 22 | namespace qmcplusplus 23 | { 24 | /** service class for explicitly managing the threading of BLAS/LAPACK calls from OpenMP parallel region 25 | * 26 | * intended to use only locally around heavy calls. 27 | */ 28 | class BlasThreadingEnv 29 | { 30 | int old_state; 31 | 32 | public: 33 | /// Constructor, obtains the number of threads at the next level 34 | BlasThreadingEnv(int num_threads) 35 | { 36 | #ifdef HAVE_MKL 37 | old_state = mkl_set_num_threads_local(num_threads); 38 | #endif 39 | } 40 | 41 | ~BlasThreadingEnv() 42 | { 43 | #ifdef HAVE_MKL 44 | mkl_set_num_threads_local(old_state); 45 | #endif 46 | } 47 | 48 | static bool NestedThreadingSupported() 49 | { 50 | #ifdef HAVE_MKL 51 | return true; 52 | #else 53 | return false; 54 | #endif 55 | } 56 | }; 57 | 58 | } // namespace qmcplusplus 59 | #endif 60 | -------------------------------------------------------------------------------- /src/Numerics/Containers.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // 9 | // File created by: 10 | // Jeongnim Kim, jeongnim.kim@intel.com, 11 | // Intel Corp. 12 | //////////////////////////////////////////////////////////////////////////////// 13 | // -*- C++ -*- 14 | /** @file Containers.h 15 | * 16 | * Master header to support SoA containers 17 | */ 18 | #ifndef QMCPLUSPLUS_SOA_CONTAINER_H 19 | #define QMCPLUSPLUS_SOA_CONTAINER_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #endif 29 | -------------------------------------------------------------------------------- /src/Numerics/Einspline/bspline.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // einspline: a library for creating and evaluating B-splines // 3 | // Copyright (C) 2007 Kenneth P. Esler, Jr. // 4 | // // 5 | // This program is free software; you can redistribute it and/or modify // 6 | // it under the terms of the GNU General Public License as published by // 7 | // the Free Software Foundation; either version 2 of the License, or // 8 | // (at your option) any later version. // 9 | // // 10 | // This program is distributed in the hope that it will be useful, // 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 13 | // GNU General Public License for more details. // 14 | // // 15 | // You should have received a copy of the GNU General Public License // 16 | // along with this program; if not, write to the Free Software // 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, // 18 | // Boston, MA 02110-1301 USA // 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 21 | #ifndef BSPLINE_H 22 | #define BSPLINE_H 23 | 24 | #include "bspline_base.h" 25 | //////////////////////////////////////////////////////////// 26 | //////////////////////////////////////////////////////////// 27 | //// Bspline structure definitions //// 28 | //////////////////////////////////////////////////////////// 29 | //////////////////////////////////////////////////////////// 30 | #include "bspline_structs.h" 31 | #include "multi_bspline_structs.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/Numerics/Einspline/bspline_base.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // einspline: a library for creating and evaluating B-splines // 3 | // Copyright (C) 2007 Kenneth P. Esler, Jr. // 4 | // // 5 | // This program is free software; you can redistribute it and/or modify // 6 | // it under the terms of the GNU General Public License as published by // 7 | // the Free Software Foundation; either version 2 of the License, or // 8 | // (at your option) any later version. // 9 | // // 10 | // This program is distributed in the hope that it will be useful, // 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 13 | // GNU General Public License for more details. // 14 | // // 15 | // You should have received a copy of the GNU General Public License // 16 | // along with this program; if not, write to the Free Software // 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, // 18 | // Boston, MA 02110-1301 USA // 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 21 | #ifndef BSPLINE_BASE_H 22 | #define BSPLINE_BASE_H 23 | 24 | #include "config.h" 25 | 26 | #include 27 | typedef std::complex complex_float; 28 | typedef std::complex complex_double; 29 | 30 | // Conventions: 31 | // Postfixes: 32 | // s: single precision real 33 | // d: double precision real 34 | // c: single precision complex 35 | // z: double precision complex 36 | 37 | //////////////////////////////////////////////////////////// 38 | //////////////////////////////////////////////////////////// 39 | //// Basic type declarations //// 40 | //////////////////////////////////////////////////////////// 41 | //////////////////////////////////////////////////////////// 42 | 43 | typedef enum 44 | { 45 | PERIODIC, 46 | DERIV1, 47 | DERIV2, 48 | FLAT, 49 | NATURAL, 50 | ANTIPERIODIC 51 | } bc_code; 52 | // clang-format off 53 | typedef enum { U1D , U2D , U3D , 54 | NU1D , NU2D , NU3D , 55 | MULTI_U1D , MULTI_U2D , MULTI_U3D, 56 | MULTI_NU1D, MULTI_NU2D, MULTI_NU3D 57 | } spline_code; 58 | typedef enum { SINGLE_REAL, DOUBLE_REAL, SINGLE_COMPLEX, DOUBLE_COMPLEX } 59 | type_code; 60 | // clang-format on 61 | 62 | typedef struct 63 | { 64 | bc_code lCode, rCode; 65 | float lVal, rVal; 66 | } BCtype_s; 67 | 68 | typedef struct 69 | { 70 | bc_code lCode, rCode; 71 | double lVal, rVal; 72 | } BCtype_d; 73 | 74 | typedef struct 75 | { 76 | bc_code lCode, rCode; 77 | float lVal_r, lVal_i, rVal_r, rVal_i; 78 | } BCtype_c; 79 | 80 | typedef struct 81 | { 82 | bc_code lCode, rCode; 83 | double lVal_r, lVal_i, rVal_r, rVal_i; 84 | } BCtype_z; 85 | 86 | typedef struct 87 | { 88 | double start, end; 89 | int num; 90 | 91 | // private 92 | double delta, delta_inv; 93 | } Ugrid; 94 | 95 | typedef struct 96 | { 97 | spline_code sp_code; 98 | type_code t_code; 99 | void* restrict coefs; 100 | } Bspline; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /src/Numerics/Einspline/bspline_structs.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // einspline: a library for creating and evaluating B-splines // 3 | // Copyright (C) 2007 Kenneth P. Esler, Jr. // 4 | // // 5 | // This program is free software; you can redistribute it and/or modify // 6 | // it under the terms of the GNU General Public License as published by // 7 | // the Free Software Foundation; either version 2 of the License, or // 8 | // (at your option) any later version. // 9 | // // 10 | // This program is distributed in the hope that it will be useful, // 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 13 | // GNU General Public License for more details. // 14 | // // 15 | // You should have received a copy of the GNU General Public License // 16 | // along with this program; if not, write to the Free Software // 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, // 18 | // Boston, MA 02110-1301 USA // 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 21 | #ifndef BSPLINE_STRUCTS_STD_H 22 | #define BSPLINE_STRUCTS_STD_H 23 | #include 24 | 25 | /////////////////////////// 26 | // Single precision real // 27 | /////////////////////////// 28 | struct UBspline_3d_s 29 | { 30 | spline_code spcode; 31 | type_code tcode; 32 | float* restrict coefs; 33 | int x_stride, y_stride; 34 | Ugrid x_grid, y_grid, z_grid; 35 | BCtype_s xBC, yBC, zBC; 36 | size_t coefs_size; 37 | }; 38 | 39 | /////////////////////////// 40 | // Double precision real // 41 | /////////////////////////// 42 | struct UBspline_3d_d 43 | { 44 | spline_code spcode; 45 | type_code tcode; 46 | double* restrict coefs; 47 | int x_stride, y_stride; 48 | Ugrid x_grid, y_grid, z_grid; 49 | BCtype_d xBC, yBC, zBC; 50 | size_t coefs_size; 51 | }; 52 | 53 | ////////////////////////////// 54 | // Single precision complex // 55 | ////////////////////////////// 56 | struct UBspline_3d_c 57 | { 58 | spline_code spcode; 59 | type_code tcode; 60 | complex_float* restrict coefs; 61 | int x_stride, y_stride; 62 | Ugrid x_grid, y_grid, z_grid; 63 | BCtype_c xBC, yBC, zBC; 64 | }; 65 | 66 | ////////////////////////////// 67 | // Double precision complex // 68 | ////////////////////////////// 69 | struct UBspline_3d_z 70 | { 71 | spline_code spcode; 72 | type_code tcode; 73 | complex_double* restrict coefs; 74 | int x_stride, y_stride; 75 | Ugrid x_grid, y_grid, z_grid; 76 | BCtype_z xBC, yBC, zBC; 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/Numerics/Einspline/multi_bspline_structs.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // einspline: a library for creating and evaluating B-splines // 3 | // Copyright (C) 2007 Kenneth P. Esler, Jr. // 4 | // // 5 | // This program is free software; you can redistribute it and/or modify // 6 | // it under the terms of the GNU General Public License as published by // 7 | // the Free Software Foundation; either version 2 of the License, or // 8 | // (at your option) any later version. // 9 | // // 10 | // This program is distributed in the hope that it will be useful, // 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 13 | // GNU General Public License for more details. // 14 | // // 15 | // You should have received a copy of the GNU General Public License // 16 | // along with this program; if not, write to the Free Software // 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, // 18 | // Boston, MA 02110-1301 USA // 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 21 | #ifndef MULTI_BSPLINE_STRUCTS_STD_H 22 | #define MULTI_BSPLINE_STRUCTS_STD_H 23 | 24 | #include 25 | #include 26 | 27 | /////////////////////////// 28 | // Single precision real // 29 | /////////////////////////// 30 | struct multi_UBspline_3d_s 31 | { 32 | spline_code spcode; 33 | type_code tcode; 34 | float* restrict coefs; 35 | intptr_t x_stride, y_stride, z_stride; 36 | Ugrid x_grid, y_grid, z_grid; 37 | BCtype_s xBC, yBC, zBC; 38 | int num_splines; 39 | size_t coefs_size; 40 | }; 41 | 42 | /////////////////////////// 43 | // Double precision real // 44 | /////////////////////////// 45 | struct multi_UBspline_3d_d 46 | { 47 | spline_code spcode; 48 | type_code tcode; 49 | double* restrict coefs; 50 | intptr_t x_stride, y_stride, z_stride; 51 | Ugrid x_grid, y_grid, z_grid; 52 | BCtype_d xBC, yBC, zBC; 53 | int num_splines; 54 | size_t coefs_size; 55 | }; 56 | 57 | ////////////////////////////// 58 | // Single precision complex // 59 | ////////////////////////////// 60 | struct multi_UBspline_3d_c 61 | { 62 | spline_code spcode; 63 | type_code tcode; 64 | complex_float* restrict coefs; 65 | intptr_t x_stride, y_stride, z_stride; 66 | Ugrid x_grid, y_grid, z_grid; 67 | BCtype_c xBC, yBC, zBC; 68 | int num_splines; 69 | size_t coefs_size; 70 | // temporary storage for laplacian components 71 | complex_float* restrict lapl3; 72 | }; 73 | 74 | ////////////////////////////// 75 | // Double precision complex // 76 | ////////////////////////////// 77 | struct multi_UBspline_3d_z 78 | { 79 | spline_code spcode; 80 | type_code tcode; 81 | complex_double* restrict coefs; 82 | intptr_t x_stride, y_stride, z_stride; 83 | Ugrid x_grid, y_grid, z_grid; 84 | BCtype_z xBC, yBC, zBC; 85 | int num_splines; 86 | size_t coefs_size; 87 | // temporary storage for laplacian components 88 | complex_double* restrict lapl3; 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/Numerics/OhmmsPETE/OhmmsMatrixOperators.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeremy McMinnis, jmcminis@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // 11 | // File created by: 12 | // Jeongnim Kim, jeongnim.kim@gmail.com, 13 | // University of Illinois at Urbana-Champaign 14 | //////////////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef OHMMS_MATRIXOPERATOR_H 17 | #define OHMMS_MATRIXOPERATOR_H 18 | 19 | 20 | namespace qmcplusplus 21 | { 22 | template 23 | inline Matrix& assign(Matrix& lhs, const RHS& rhs) 24 | { 25 | typedef typename CreateLeaf::Leaf_t Leaf_t; 26 | evaluate(lhs, OpAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 27 | return lhs; 28 | } 29 | 30 | template 31 | inline Matrix& operator+=(Matrix& lhs, const RHS& rhs) 32 | { 33 | typedef typename CreateLeaf::Leaf_t Leaf_t; 34 | evaluate(lhs, OpAddAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 35 | return lhs; 36 | } 37 | 38 | template 39 | inline Matrix& operator-=(Matrix& lhs, const RHS& rhs) 40 | { 41 | typedef typename CreateLeaf::Leaf_t Leaf_t; 42 | evaluate(lhs, OpSubtractAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 43 | return lhs; 44 | } 45 | 46 | template 47 | inline Matrix& operator*=(Matrix& lhs, const RHS& rhs) 48 | { 49 | typedef typename CreateLeaf::Leaf_t Leaf_t; 50 | evaluate(lhs, OpMultiplyAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 51 | return lhs; 52 | } 53 | 54 | } // namespace qmcplusplus 55 | 56 | #endif // OHMMS_MATRIXOPERATOR_H 57 | -------------------------------------------------------------------------------- /src/Numerics/OhmmsPETE/OhmmsVectorOperators.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeremy McMinnis, jmcminis@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // 11 | // File created by: 12 | // Jeongnim Kim, jeongnim.kim@gmail.com, 13 | // University of Illinois at Urbana-Champaign 14 | //////////////////////////////////////////////////////////////////////////////// 15 | 16 | #ifndef OHMMS_VECTOR_OPERATORS_H 17 | #define OHMMS_VECTOR_OPERATORS_H 18 | 19 | namespace qmcplusplus 20 | { 21 | template 22 | inline Vector& assign(Vector& lhs, const RHS& rhs) 23 | { 24 | typedef typename CreateLeaf::Leaf_t Leaf_t; 25 | evaluate(lhs, OpAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 26 | return lhs; 27 | } 28 | 29 | template 30 | inline Vector& operator+=(Vector& lhs, const RHS& rhs) 31 | { 32 | typedef typename CreateLeaf::Leaf_t Leaf_t; 33 | evaluate(lhs, OpAddAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 34 | return lhs; 35 | } 36 | 37 | template 38 | inline Vector& operator-=(Vector& lhs, const RHS& rhs) 39 | { 40 | typedef typename CreateLeaf::Leaf_t Leaf_t; 41 | evaluate(lhs, OpSubtractAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 42 | return lhs; 43 | } 44 | 45 | template 46 | inline Vector& operator*=(Vector& lhs, const RHS& rhs) 47 | { 48 | typedef typename CreateLeaf::Leaf_t Leaf_t; 49 | evaluate(lhs, OpMultiplyAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 50 | return lhs; 51 | } 52 | 53 | template 54 | inline Vector& operator/=(Vector& lhs, const RHS& rhs) 55 | { 56 | typedef typename CreateLeaf::Leaf_t Leaf_t; 57 | evaluate(lhs, OpDivideAssign(), MakeReturn::make(CreateLeaf::make(rhs))); 58 | return lhs; 59 | } 60 | 61 | } // namespace qmcplusplus 62 | 63 | #endif // GENERATED_OPERATORS_H 64 | -------------------------------------------------------------------------------- /src/Numerics/OhmmsPETE/PosTransformer.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // 9 | // File created by: 10 | // Jeongnim Kim, jeongnim.kim@intel.com, 11 | // Intel Corp. 12 | //////////////////////////////////////////////////////////////////////////////// 13 | // -*- C++ -*- 14 | /** @file PosTransformer.h 15 | * @brief Support funtions to handle position type data manged by soa 16 | */ 17 | #ifndef QMCPLUSPLUS_SOA_FAST_PARTICLE_OPERATORS_H 18 | #define QMCPLUSPLUS_SOA_FAST_PARTICLE_OPERATORS_H 19 | 20 | namespace qmcplusplus 21 | { 22 | /** General conversion function from AoS[nrows][ncols] to SoA[ncols][ldb] 23 | * @param nrows the first dimension 24 | * @param ncols the second dimension 25 | * @param iptr input pointer 26 | * @param lda stride of iptr 27 | * @param out output pointer 28 | * @param lda strided of out 29 | * 30 | * Modeled after blas/lapack for lda/ldb 31 | */ 32 | template 33 | void PosAoS2SoA(int nrows, int ncols, const T1* restrict iptr, int lda, T2* restrict out, int ldb) 34 | { 35 | T2* restrict x = out; 36 | T2* restrict y = out + ldb; 37 | T2* restrict z = out + 2 * ldb; 38 | #if !defined(__ibmxl__) 39 | #pragma omp simd aligned(x, y, z) 40 | #endif 41 | for (int i = 0; i < nrows; ++i) 42 | { 43 | x[i] = iptr[i * ncols]; // x[i]=in[i][0]; 44 | y[i] = iptr[i * ncols + 1]; // y[i]=in[i][1]; 45 | z[i] = iptr[i * ncols + 2]; // z[i]=in[i][2]; 46 | } 47 | } 48 | 49 | /** General conversion function from SoA[ncols][ldb] to AoS[nrows][ncols] 50 | * @param nrows the first dimension 51 | * @param ncols the second dimension 52 | * @param iptr input pointer 53 | * @param lda stride of iptr 54 | * @param out output pointer 55 | * @param lda strided of out 56 | * 57 | * Modeled after blas/lapack for lda/ldb 58 | */ 59 | template 60 | void PosSoA2AoS(int nrows, int ncols, const T1* restrict iptr, int lda, T2* restrict out, int ldb) 61 | { 62 | const T1* restrict x = iptr; 63 | const T1* restrict y = iptr + lda; 64 | const T1* restrict z = iptr + 2 * lda; 65 | #if !defined(__ibmxl__) 66 | #pragma omp simd aligned(x, y, z) 67 | #endif 68 | for (int i = 0; i < nrows; ++i) 69 | { 70 | out[i * ldb] = x[i]; // out[i][0]=x[i]; 71 | out[i * ldb + 1] = y[i]; // out[i][1]=y[i]; 72 | out[i * ldb + 2] = z[i]; // out[i][2]=z[i]; 73 | } 74 | } 75 | 76 | } // namespace qmcplusplus 77 | #endif 78 | -------------------------------------------------------------------------------- /src/Numerics/OptimizableFunctorBase.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Miguel Morales, moralessilva2@llnl.gov, 9 | // Lawrence Livermore National Laboratory 10 | // Jeremy McMinnis, jmcminis@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Jeongnim Kim, jeongnim.kim@gmail.com, 13 | // University of Illinois at Urbana-Champaign 14 | // 15 | // File created by: 16 | // Jeongnim Kim, jeongnim.kim@gmail.com, 17 | // University of Illinois at Urbana-Champaign 18 | //////////////////////////////////////////////////////////////////////////////// 19 | 20 | /** @file OptimizableFunctorBase.h 21 | * @brief Define a base class for one-dimensional functions with optimizable 22 | * variables 23 | */ 24 | #ifndef QMCPLUSPLUS_OPTIMIZABLEFUNCTORBASE_H 25 | #define QMCPLUSPLUS_OPTIMIZABLEFUNCTORBASE_H 26 | 27 | #include "config.h" 28 | 29 | /** Base class for any functor with optimizable parameters 30 | * 31 | * Derived classes from OptimizableFunctorBase are called "functor"s and 32 | * can be used as a template signature for Jastrow functions. 33 | * - OneBodyJastroOrbital 34 | * - TwoBodyJastroOrbital 35 | * Functor in qmcpack denotes any function which returns a value at a point, 36 | * e.g., 37 | * GTO, STO, one-dimensional splines etc. OptimizableFunctorBase is introduced 38 | * for 39 | * optimizations. The virtual functions are intended for non-critical operations 40 | * that 41 | * are executed infrequently during optimizations. 42 | * 43 | * This class handles myVars of opt_variables_type (Optimize/VariableSet.h). A 44 | * derived class 45 | * can insert any number of variables it handles during optimizations, by 46 | * calling 47 | * myVars.insert(name,value); 48 | * Unlike VarList which uses map, VariableSet is serialized in that the internal 49 | * order is according 50 | * to insert calls. 51 | */ 52 | struct OptimizableFunctorBase 53 | { 54 | /// typedef for real values 55 | typedef OHMMS_PRECISION real_type; 56 | /// maximum cutoff 57 | real_type cutoff_radius; 58 | /// default constructor 59 | inline OptimizableFunctorBase() {} 60 | /// virtual destrutor 61 | virtual ~OptimizableFunctorBase() {} 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/Numerics/PETE/PETE.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // ACL:license 3 | // ---------------------------------------------------------------------- 4 | // This software and ancillary information (herein called "SOFTWARE") 5 | // called PETE (Portable Expression Template Engine) is 6 | // made available under the terms described here. The SOFTWARE has been 7 | // approved for release with associated LA-CC Number LA-CC-99-5. 8 | // 9 | // Unless otherwise indicated, this SOFTWARE has been authored by an 10 | // employee or employees of the University of California, operator of the 11 | // Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with 12 | // the U.S. Department of Energy. The U.S. Government has rights to use, 13 | // reproduce, and distribute this SOFTWARE. The public may copy, distribute, 14 | // prepare derivative works and publicly display this SOFTWARE without 15 | // charge, provided that this Notice and any statement of authorship are 16 | // reproduced on all copies. Neither the Government nor the University 17 | // makes any warranty, express or implied, or assumes any liability or 18 | // responsibility for the use of this SOFTWARE. 19 | // 20 | // If SOFTWARE is modified to produce derivative works, such modified 21 | // SOFTWARE should be clearly marked, so as not to confuse it with the 22 | // version available from LANL. 23 | // 24 | // For more information about PETE, send e-mail to pete@acl.lanl.gov, 25 | // or visit the PETE web page at http://www.acl.lanl.gov/pete/. 26 | // ---------------------------------------------------------------------- 27 | // ACL:license 28 | 29 | #ifndef PETE_PETE_PETE_H 30 | #define PETE_PETE_PETE_H 31 | 32 | /////////////////////////////////////////////////////////////////////////////// 33 | // 34 | // This is the header file you should include if you want to use PETE, the 35 | // Portable Expression Template Engine. You don't need add any member 36 | // functions to make your container class PETE-aware, but you will need to 37 | // create some traits classes and use the MakeOperator tool to create 38 | // operator and math functions. 39 | // 40 | // See html/index.html for detailed instructions on using PETE. 41 | // 42 | /////////////////////////////////////////////////////////////////////////////// 43 | 44 | #if PETE_MAKE_EMPTY_CONSTRUCTORS 45 | 46 | #define PETE_EMPTY_CONSTRUCTORS(CLASS) \ 47 | CLASS() {} \ 48 | CLASS(const CLASS&) {} \ 49 | CLASS& operator=(const CLASS&) { return *this; } 50 | 51 | #define PETE_EMPTY_CONSTRUCTORS_TEMPLATE(CLASS, ARG) \ 52 | CLASS() {} \ 53 | CLASS(const CLASS&) {} \ 54 | CLASS& operator=(const CLASS&) { return *this; } 55 | 56 | #else 57 | 58 | #define PETE_EMPTY_CONSTRUCTORS(CLASS) 59 | #define PETE_EMPTY_CONSTRUCTORS_TEMPLATE(CLASS, ARG) 60 | 61 | #endif 62 | 63 | #include "Numerics/PETE/Scalar.h" 64 | #include "Numerics/PETE/TypeComputations.h" 65 | #include "Numerics/PETE/TreeNodes.h" 66 | #include "Numerics/PETE/OperatorTags.h" 67 | #include "Numerics/PETE/Functors.h" 68 | #include "Numerics/PETE/Combiners.h" 69 | #include "Numerics/PETE/ForEach.h" 70 | #include "Numerics/PETE/CreateLeaf.h" 71 | 72 | // Some useful PETE definitions. 73 | 74 | #define PETE_MAJOR_VERSION 2 75 | #define PETE_MINOR_VERSION 1 76 | #define PETE_PATCH_LEVEL 1 77 | #define PETE_VERSION_STRING "PETE 2.1.1" 78 | #define PETE_VERSION_NUM_STRING "2.1.1" 79 | 80 | #endif // PETE_PETE_PETE_H 81 | 82 | // ACL:rcsinfo 83 | -------------------------------------------------------------------------------- /src/Numerics/PETE/Scalar.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // ACL:license 3 | // ---------------------------------------------------------------------- 4 | // This software and ancillary information (herein called "SOFTWARE") 5 | // called PETE (Portable Expression Template Engine) is 6 | // made available under the terms described here. The SOFTWARE has been 7 | // approved for release with associated LA-CC Number LA-CC-99-5. 8 | // 9 | // Unless otherwise indicated, this SOFTWARE has been authored by an 10 | // employee or employees of the University of California, operator of the 11 | // Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with 12 | // the U.S. Department of Energy. The U.S. Government has rights to use, 13 | // reproduce, and distribute this SOFTWARE. The public may copy, distribute, 14 | // prepare derivative works and publicly display this SOFTWARE without 15 | // charge, provided that this Notice and any statement of authorship are 16 | // reproduced on all copies. Neither the Government nor the University 17 | // makes any warranty, express or implied, or assumes any liability or 18 | // responsibility for the use of this SOFTWARE. 19 | // 20 | // If SOFTWARE is modified to produce derivative works, such modified 21 | // SOFTWARE should be clearly marked, so as not to confuse it with the 22 | // version available from LANL. 23 | // 24 | // For more information about PETE, send e-mail to pete@acl.lanl.gov, 25 | // or visit the PETE web page at http://www.acl.lanl.gov/pete/. 26 | // ---------------------------------------------------------------------- 27 | // ACL:license 28 | 29 | #ifndef PETE_PETE_SCALAR_H 30 | #define PETE_PETE_SCALAR_H 31 | 32 | /////////////////////////////////////////////////////////////////////////////// 33 | // 34 | // WARNING: THIS FILE IS FOR INTERNAL PETE USE. DON'T INCLUDE IT YOURSELF 35 | // 36 | /////////////////////////////////////////////////////////////////////////////// 37 | 38 | //----------------------------------------------------------------------------- 39 | // 40 | // CLASS NAME 41 | // Scalar 42 | // 43 | // DESCRIPTION 44 | // A wrapper around a scalar to be used in PETE expressions. 45 | // 46 | //----------------------------------------------------------------------------- 47 | 48 | template 49 | class Scalar 50 | { 51 | public: 52 | //--------------------------------------------------------------------------- 53 | // Default constructor takes no action. 54 | 55 | inline Scalar() {} 56 | 57 | //--------------------------------------------------------------------------- 58 | // Constructor from a single value. 59 | 60 | inline Scalar(const T& t) : scalar_m(t) {} 61 | 62 | template 63 | inline explicit Scalar(const T1& t) : scalar_m(t) 64 | {} 65 | 66 | //--------------------------------------------------------------------------- 67 | // Constructor with arbitary second/third arguments, which is/are ignored. 68 | // Needed for compatibility with tree node constructors taking an 69 | // arbitrary argument. 70 | 71 | template 72 | inline Scalar(const Scalar& s, const Arg&) : scalar_m(s.scalar_m) 73 | {} 74 | 75 | template 76 | inline Scalar(const Scalar& s, const Arg1&, const Arg2&) : scalar_m(s.scalar_m) 77 | {} 78 | 79 | //--------------------------------------------------------------------------- 80 | // Copy constructor 81 | 82 | inline Scalar(const Scalar& s) : scalar_m(s.scalar_m) {} 83 | 84 | //--------------------------------------------------------------------------- 85 | // Return value. 86 | 87 | inline const T& value() const { return scalar_m; } 88 | 89 | //--------------------------------------------------------------------------- 90 | // Assignment operators. 91 | 92 | inline Scalar& operator=(const Scalar& rhs) 93 | { 94 | scalar_m = rhs.scalar_m; 95 | return *this; 96 | } 97 | 98 | inline Scalar& operator=(const T& rhs) 99 | { 100 | scalar_m = rhs; 101 | return *this; 102 | } 103 | 104 | private: 105 | //--------------------------------------------------------------------------- 106 | // The scalar value is stored here. 107 | 108 | T scalar_m; 109 | }; 110 | 111 | #endif // PETE_PETE_SCALAR_H 112 | 113 | // ACL:rcsinfo 114 | -------------------------------------------------------------------------------- /src/Numerics/Spline2/MultiBsplineEvalHelper.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | //////////////////////////////////////////////////////////////////////////////// 11 | // -*- C++ -*- 12 | /**@file MultiBsplineEvalHelper.hpp 13 | * 14 | * header file for helper functions 15 | */ 16 | #ifndef SPLINE2_MULTIEINSPLINE_EVAL_HELPER_HPP 17 | #define SPLINE2_MULTIEINSPLINE_EVAL_HELPER_HPP 18 | 19 | #include 20 | #include 21 | 22 | namespace qmcplusplus 23 | { 24 | namespace spline2 25 | { 26 | /** break x into the integer part and residual part and apply bounds 27 | * @param x input coordinate 28 | * @param dx fractional part 29 | * @param ind integer part 30 | * @param nmax upper bound of the integer part 31 | * 32 | * x in the range of [0, nmax+1) will be split correctly. 33 | * x < 0, ind = 0, dx = 0 34 | * x >= nmax+1, ind = nmax, dx = 1 - epsilon 35 | * 36 | * Attention: nmax is not the number grid points but the maximum allowed grid index 37 | * For example, ng is the number of grid point. 38 | * the actual grid points indices are 0, 1, ..., ng - 1. 39 | * In a periodic/anti periodic spline, set nmax = ng - 1 40 | * In a natural boundary spline, set nmax = ng - 2 41 | * because the end point should be excluded and the last grid point has an index ng - 2. 42 | */ 43 | template 44 | inline void getSplineBound(T x, TRESIDUAL& dx, int& ind, int nmax) 45 | { 46 | // lower bound 47 | if (x < 0) 48 | { 49 | ind = 0; 50 | dx = T(0); 51 | } 52 | else 53 | { 54 | T ipart; 55 | dx = std::modf(x, &ipart); 56 | ind = static_cast(ipart); 57 | // upper bound 58 | if (ind > nmax) 59 | { 60 | ind = nmax; 61 | dx = T(1) - std::numeric_limits::epsilon(); 62 | } 63 | } 64 | } 65 | 66 | /** define computeLocationAndFractional: common to any implementation 67 | * compute the location of the spline grid point and residual coordinates 68 | * also it precomputes auxilary array a, b and c 69 | */ 70 | template 71 | inline void computeLocationAndFractional( 72 | const typename qmcplusplus::bspline_traits::SplineType* restrict spline_m, T x, T y, T z, 73 | int& ix, int& iy, int& iz, T a[4], T b[4], T c[4]) 74 | { 75 | x -= spline_m->x_grid.start; 76 | y -= spline_m->y_grid.start; 77 | z -= spline_m->z_grid.start; 78 | 79 | T tx, ty, tz; 80 | 81 | getSplineBound(x * spline_m->x_grid.delta_inv, tx, ix, spline_m->x_grid.num - 1); 82 | getSplineBound(y * spline_m->y_grid.delta_inv, ty, iy, spline_m->y_grid.num - 1); 83 | getSplineBound(z * spline_m->z_grid.delta_inv, tz, iz, spline_m->z_grid.num - 1); 84 | 85 | MultiBsplineData::compute_prefactors(a, tx); 86 | MultiBsplineData::compute_prefactors(b, ty); 87 | MultiBsplineData::compute_prefactors(c, tz); 88 | } 89 | 90 | /** define computeLocationAndFractional: common to any implementation 91 | * compute the location of the spline grid point and residual coordinates 92 | * also it precomputes auxilary array (a,b,c) (da,db,dc) (d2a,d2b,d2c) 93 | */ 94 | template 95 | inline void computeLocationAndFractional( 96 | const typename qmcplusplus::bspline_traits::SplineType* restrict spline_m, T x, T y, T z, 97 | int& ix, int& iy, int& iz, T a[4], T b[4], T c[4], T da[4], T db[4], T dc[4], T d2a[4], 98 | T d2b[4], T d2c[4]) 99 | { 100 | x -= spline_m->x_grid.start; 101 | y -= spline_m->y_grid.start; 102 | z -= spline_m->z_grid.start; 103 | 104 | T tx, ty, tz; 105 | 106 | getSplineBound(x * spline_m->x_grid.delta_inv, tx, ix, spline_m->x_grid.num - 1); 107 | getSplineBound(y * spline_m->y_grid.delta_inv, ty, iy, spline_m->y_grid.num - 1); 108 | getSplineBound(z * spline_m->z_grid.delta_inv, tz, iz, spline_m->z_grid.num - 1); 109 | 110 | MultiBsplineData::compute_prefactors(a, da, d2a, tx); 111 | MultiBsplineData::compute_prefactors(b, db, d2b, ty); 112 | MultiBsplineData::compute_prefactors(c, dc, d2c, tz); 113 | } 114 | 115 | } // namespace spline2 116 | } // namespace qmcplusplus 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /src/Numerics/Spline2/bspline_traits.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // 9 | // File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp. 10 | //////////////////////////////////////////////////////////////////////////////// 11 | // -*- C++ -*- 12 | /** @file bspline_traits.hpp 13 | * 14 | * extend spline/bspline_traints by introducing 15 | * bspline_traits with only speciliazation with 3D 16 | */ 17 | #ifndef QMCPLUSPLUS_BSPLINE_SPLINE2_TRAITS_H 18 | #define QMCPLUSPLUS_BSPLINE_SPLINE2_TRAITS_H 19 | 20 | #include 21 | 22 | namespace qmcplusplus 23 | { 24 | /** trait class to map (datatype,D) to Einspline engine type */ 25 | template 26 | struct bspline_traits 27 | {}; 28 | 29 | template<> 30 | struct bspline_traits 31 | { 32 | typedef multi_UBspline_3d_s SplineType; 33 | typedef UBspline_3d_s SingleSplineType; 34 | typedef BCtype_s BCType; 35 | typedef float real_type; 36 | typedef float value_type; 37 | }; 38 | 39 | template<> 40 | struct bspline_traits 41 | { 42 | typedef multi_UBspline_3d_d SplineType; 43 | typedef UBspline_3d_d SingleSplineType; 44 | typedef BCtype_d BCType; 45 | typedef double real_type; 46 | typedef double value_type; 47 | }; 48 | 49 | /** helper class to determine the value_type of einspline objects 50 | */ 51 | template 52 | struct bspline_type 53 | {}; 54 | 55 | template<> 56 | struct bspline_type 57 | { 58 | typedef float value_type; 59 | }; 60 | 61 | template<> 62 | struct bspline_type 63 | { 64 | typedef double value_type; 65 | }; 66 | 67 | template<> 68 | struct bspline_type 69 | { 70 | typedef float value_type; 71 | }; 72 | 73 | template<> 74 | struct bspline_type 75 | { 76 | typedef double value_type; 77 | }; 78 | } // namespace qmcplusplus 79 | #endif 80 | -------------------------------------------------------------------------------- /src/Numerics/readme_soa.md: -------------------------------------------------------------------------------- 1 | There is some "structure of array" specific support here as well 2 | 3 | ParticleAttribSoA 4 | ================= 5 | Experimental pacakage implements classes to facilitate SIMD algorithms. 6 | * SoaContainer.h 7 | * Container.h : replacing container> 8 | * TensorSoaContainer.h : replacing container> 9 | 10 | Container 11 | --------------- 12 | \code 13 | Container R; 14 | auto r=R[i]; //get the value of the i-th position 15 | R(i)=0; //assign to the i-th position 16 | R(i)=TinyVector(-1,2,3); //assign to the i-th position 17 | \endcode 18 | 19 | Access operators to each compoenent are provided. 20 | 21 | \code 22 | R.data(0); //return the starting address of X component 23 | R.data(1); //return the starting address of Y component 24 | R.data(2); //return the starting address of Z component 25 | \endode 26 | 27 | TensorSoaContainer 28 | ------------------ 29 | \code 30 | TensorSoaContainer H; 31 | auto h=H[i]; //get the value of the i-th hessian as Tensor 32 | H(i)=0; //assign to the i-th hessian 33 | H(i)=Tensor(0,1,2,1,3,4,2,4,5);//assign to the i-th hessian 34 | \endcode 35 | 36 | Access operators to each compoenent are provided. 37 | 38 | \code 39 | H.data(int i, int j); //return the starting address of (i,j) component 40 | \endcode 41 | 42 | -------------------------------------------------------------------------------- /src/Particle/DistanceTable.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeremy McMinnis, jmcminis@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeongnim Kim, jeongnim.kim@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // 13 | // File created by: 14 | // Jeongnim Kim, jeongnim.kim@gmail.com, 15 | // University of Illinois at Urbana-Champaign 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | #ifndef QMCPLUSPLUS_DISTANCETABLE_H 19 | #define QMCPLUSPLUS_DISTANCETABLE_H 20 | 21 | #include "Particle/ParticleSet.h" 22 | #include "Utilities/PooledData.h" 23 | 24 | namespace qmcplusplus 25 | { 26 | /** Class to manage multiple DistanceTableData objects. 27 | * 28 | * \date 2008-09-19 29 | * DistanceTable::add functions 30 | * are kept for compatibility only. New codes should use a member function 31 | * of ParticleSet to add a distance table 32 | * int ParticleSet::addTable(const ParticleSet& source) 33 | * 34 | *\todo DistanceTable should work as a factory, as well, to instantiate 35 | *DistanceTableData 36 | * subject to different boundary conditions. 37 | * Lattice/CrystalLattice.h and Lattice/CrystalLattice.cpp can be owned by 38 | *DistanceTable 39 | * to generically control the crystalline structure. 40 | */ 41 | 42 | /// free function to create a distable table of s-s 43 | DistanceTableData* createDistanceTable(ParticleSet& s, int dt_type); 44 | 45 | /// free function create a distable table of s-t 46 | DistanceTableData* createDistanceTable(const ParticleSet& s, ParticleSet& t, int dt_type); 47 | } // namespace qmcplusplus 48 | #endif 49 | -------------------------------------------------------------------------------- /src/Particle/DistanceTableAA.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Ken Esler, kpesler@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeremy McMinnis, jmcminis@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Jeongnim Kim, jeongnim.kim@gmail.com, 13 | // University of Illinois at Urbana-Champaign 14 | // Jaron T. Krogel, krogeljt@ornl.gov, 15 | // Oak Ridge National Laboratory 16 | // Mark A. Berrill, berrillma@ornl.gov, 17 | // Oak Ridge National Laboratory 18 | // 19 | // File created by: 20 | // Jeongnim Kim, jeongnim.kim@gmail.com, 21 | // University of Illinois at Urbana-Champaign 22 | //////////////////////////////////////////////////////////////////////////////// 23 | 24 | #include "Particle/DistanceTable.h" 25 | #include "Particle/DistanceTableData.h" 26 | #include "Particle/Lattice/ParticleBConds.h" 27 | #include "Particle/DistanceTableAA.h" 28 | 29 | namespace qmcplusplus 30 | { 31 | /** Adding SymmetricDTD to the list, e.g., el-el distance table 32 | *\param s source/target particle set 33 | *\return index of the distance table with the name 34 | */ 35 | DistanceTableData* createDistanceTable(ParticleSet& s, int dt_type) 36 | { 37 | typedef OHMMS_PRECISION RealType; 38 | enum 39 | { 40 | DIM = OHMMS_DIM 41 | }; 42 | int sc = s.Lattice.SuperCellEnum; 43 | DistanceTableData* dt = 0; 44 | std::ostringstream o; 45 | bool useSoA = (dt_type == DT_SOA || dt_type == DT_SOA_PREFERRED); 46 | o << " Distance table for AA: source/target = " << s.getName() << " useSoA =" << useSoA << "\n"; 47 | if (sc == SUPERCELL_BULK) 48 | { 49 | o << " Using SoaDistanceTableAA of SoA layout " << PPPG << std::endl; 50 | dt = new DistanceTableAA(s); 51 | o << "\n Setting Rmax = " << s.Lattice.SimulationCellRadius; 52 | } 53 | else 54 | { 55 | APP_ABORT("DistanceTableData::createDistanceTable Slab/Wire/Open boundary " 56 | "conditions are disabled in miniQMC!\n"); 57 | } 58 | 59 | // set dt properties 60 | dt->CellType = sc; 61 | dt->DTType = DT_SOA; 62 | std::ostringstream p; 63 | p << s.getName() << "_" << s.getName(); 64 | dt->Name = p.str(); // assign the table name 65 | 66 | o << " using Cartesian coordinates"; 67 | if (omp_get_thread_num() == 0) 68 | { 69 | app_log() << o.str() << std::endl; 70 | app_log().flush(); 71 | } 72 | 73 | return dt; 74 | } 75 | 76 | } // namespace qmcplusplus 77 | /*************************************************************************** 78 | * $RCSfile$ $Author$ 79 | * $Revision$ $Date$ 80 | * $Id$ 81 | ***************************************************************************/ 82 | -------------------------------------------------------------------------------- /src/Particle/DistanceTableAA.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeongnim Kim, jeongnim.kim@intel.com, 9 | // Intel Corp. 10 | // Amrita Mathuriya, amrita.mathuriya@intel.com, 11 | // Intel Corp. 12 | // 13 | // File created by: 14 | // Jeongnim Kim, jeongnim.kim@intel.com, 15 | // Intel Corp. 16 | //////////////////////////////////////////////////////////////////////////////// 17 | // -*- C++ -*- 18 | #ifndef QMCPLUSPLUS_DTDIMPL_AA_H 19 | #define QMCPLUSPLUS_DTDIMPL_AA_H 20 | #include "Utilities/SIMD/algorithm.hpp" 21 | 22 | namespace qmcplusplus 23 | { 24 | /**@ingroup nnlist 25 | * @brief A derived classe from DistacneTableData, specialized for dense case 26 | */ 27 | template 28 | struct DistanceTableAA : public DTD_BConds, public DistanceTableData 29 | { 30 | int Ntargets; 31 | int Ntargets_padded; 32 | int BlockSize; 33 | 34 | DistanceTableAA(ParticleSet& target) 35 | : DTD_BConds(target.Lattice), DistanceTableData(target, target) 36 | { 37 | resize(target.getTotalNum()); 38 | } 39 | 40 | DistanceTableAA() = delete; 41 | DistanceTableAA(const DistanceTableAA&) = delete; 42 | ~DistanceTableAA() {} 43 | 44 | size_t compute_size(int N) 45 | { 46 | const size_t N_padded = getAlignedSize(N); 47 | const size_t Alignment = getAlignment(); 48 | return (N_padded * (2 * N - N_padded + 1) + (Alignment - 1) * N_padded) / 2; 49 | } 50 | 51 | void resize(int n) 52 | { 53 | N[SourceIndex] = n; 54 | N[VisitorIndex] = n; 55 | Ntargets = n; 56 | Ntargets_padded = getAlignedSize(n); 57 | Distances.resize(Ntargets, Ntargets_padded); 58 | const size_t total_size = compute_size(Ntargets); 59 | memoryPool.resize(total_size * D); 60 | Displacements.resize(Ntargets); 61 | for (int i = 0; i < Ntargets; ++i) 62 | Displacements[i].attachReference(i, total_size, memoryPool.data() + compute_size(i)); 63 | 64 | Temp_r.resize(Ntargets); 65 | Temp_dr.resize(Ntargets); 66 | } 67 | 68 | inline void evaluate(ParticleSet& P) 69 | { 70 | constexpr T BigR = std::numeric_limits::max(); 71 | // P.RSoA.copyIn(P.R); 72 | for (int iat = 0; iat < Ntargets; ++iat) 73 | { 74 | DTD_BConds::computeDistances(P.R[iat], 75 | P.RSoA, 76 | Distances[iat], 77 | Displacements[iat], 78 | 0, 79 | Ntargets, 80 | iat); 81 | Distances[iat][iat] = BigR; // assign big distance 82 | } 83 | } 84 | 85 | inline void evaluate(ParticleSet& P, IndexType jat) 86 | { 87 | DTD_BConds::computeDistances(P.R[jat], 88 | P.RSoA, 89 | Distances[jat], 90 | Displacements[jat], 91 | 0, 92 | Ntargets, 93 | jat); 94 | Distances[jat][jat] = std::numeric_limits::max(); // assign a big number 95 | } 96 | 97 | /// evaluate the temporary pair relations 98 | inline void move(const ParticleSet& P, const PosType& rnew) 99 | { 100 | DTD_BConds::computeDistances(rnew, P.RSoA, Temp_r.data(), Temp_dr, 0, Ntargets, P.activePtcl); 101 | } 102 | 103 | /// update the iat-th row for iat=[0,iat-1) 104 | inline void update(IndexType iat) 105 | { 106 | if (iat == 0) 107 | return; 108 | // update by a cache line 109 | const int nupdate = getAlignedSize(iat); 110 | std::copy_n(Temp_r.data(), nupdate, Distances[iat]); 111 | for (int idim = 0; idim < D; ++idim) 112 | std::copy_n(Temp_dr.data(idim), nupdate, Displacements[iat].data(idim)); 113 | } 114 | }; 115 | } // namespace qmcplusplus 116 | #endif 117 | -------------------------------------------------------------------------------- /src/Particle/DistanceTableAB.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Ken Esler, kpesler@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeremy McMinnis, jmcminis@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Jeongnim Kim, jeongnim.kim@gmail.com, 13 | // University of Illinois at Urbana-Champaign 14 | // Jaron T. Krogel, krogeljt@ornl.gov, 15 | // Oak Ridge National Laboratory 16 | // Mark A. Berrill, berrillma@ornl.gov, 17 | // Oak Ridge National Laboratory 18 | // 19 | // File created by: 20 | // Jeongnim Kim, jeongnim.kim@gmail.com, 21 | // University of Illinois at Urbana-Champaign 22 | //////////////////////////////////////////////////////////////////////////////// 23 | 24 | #include "Particle/DistanceTable.h" 25 | #include "Particle/DistanceTableData.h" 26 | #include "Particle/Lattice/ParticleBConds.h" 27 | #include "Utilities/SIMD/algorithm.hpp" 28 | #include "Particle/DistanceTableBA.h" 29 | 30 | namespace qmcplusplus 31 | { 32 | /** Adding AsymmetricDTD to the list, e.g., el-el distance table 33 | *\param s source/target particle set 34 | *\return index of the distance table with the name 35 | */ 36 | DistanceTableData* createDistanceTable(const ParticleSet& s, ParticleSet& t, int dt_type) 37 | { 38 | typedef OHMMS_PRECISION RealType; 39 | enum 40 | { 41 | DIM = OHMMS_DIM 42 | }; 43 | DistanceTableData* dt = 0; 44 | int sc = t.Lattice.SuperCellEnum; 45 | std::ostringstream o; 46 | o << " Distance table for AB: source = " << s.getName() << " target = " << t.getName() << "\n"; 47 | if (sc == SUPERCELL_BULK) 48 | { 49 | o << " Using SoaDistanceTableBA of SoA layout " << PPPG << std::endl; 50 | dt = new DistanceTableBA(s, t); 51 | o << " Setting Rmax = " << s.Lattice.SimulationCellRadius; 52 | } 53 | else 54 | { 55 | APP_ABORT("DistanceTableData::createDistanceTable Slab/Wire/Open boundary " 56 | "conditions are disabled in miniQMC!\n"); 57 | } 58 | 59 | // set dt properties 60 | dt->CellType = sc; 61 | dt->DTType = DT_SOA; 62 | std::ostringstream p; 63 | p << s.getName() << "_" << t.getName(); 64 | dt->Name = p.str(); // assign the table name 65 | 66 | o << " using Cartesian coordinates"; 67 | if (omp_get_thread_num() == 0) 68 | { 69 | app_log() << o.str() << std::endl; 70 | app_log().flush(); 71 | } 72 | return dt; 73 | } 74 | 75 | } // namespace qmcplusplus 76 | /*************************************************************************** 77 | * $RCSfile$ $Author$ 78 | * $Revision$ $Date$ 79 | * $Id$ 80 | ***************************************************************************/ 81 | -------------------------------------------------------------------------------- /src/Particle/DistanceTableBA.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeongnim Kim, jeongnim.kim@intel.com, 9 | // Intel Corp. 10 | // Amrita Mathuriya, amrita.mathuriya@intel.com, 11 | // Intel Corp. 12 | // 13 | // File created by: 14 | // Jeongnim Kim, jeongnim.kim@intel.com, 15 | // Intel Corp. 16 | //////////////////////////////////////////////////////////////////////////////// 17 | // -*- C++ -*- 18 | #ifndef QMCPLUSPLUS_DTDIMPL_BA_H 19 | #define QMCPLUSPLUS_DTDIMPL_BA_H 20 | 21 | namespace qmcplusplus 22 | { 23 | /**@ingroup nnlist 24 | * @brief A derived classe from DistacneTableData, specialized for AB using a 25 | * transposed form 26 | */ 27 | template 28 | struct DistanceTableBA : public DTD_BConds, public DistanceTableData 29 | { 30 | int Nsources; 31 | int Ntargets; 32 | int BlockSize; 33 | 34 | DistanceTableBA(const ParticleSet& source, ParticleSet& target) 35 | : DTD_BConds(source.Lattice), DistanceTableData(source, target) 36 | { 37 | resize(source.getTotalNum(), target.getTotalNum()); 38 | } 39 | 40 | void resize(int ns, int nt) 41 | { 42 | N[SourceIndex] = Nsources = ns; 43 | N[VisitorIndex] = Ntargets = nt; 44 | if (Nsources * Ntargets == 0) 45 | return; 46 | 47 | int Ntargets_padded = getAlignedSize(Ntargets); 48 | int Nsources_padded = getAlignedSize(Nsources); 49 | 50 | Distances.resize(Ntargets, Nsources_padded); 51 | 52 | BlockSize = Nsources_padded * D; 53 | memoryPool.resize(Ntargets * BlockSize); 54 | Displacements.resize(Ntargets); 55 | for (int i = 0; i < Ntargets; ++i) 56 | Displacements[i].attachReference(Nsources, Nsources_padded, memoryPool.data() + i * BlockSize); 57 | 58 | Temp_r.resize(Nsources); 59 | Temp_dr.resize(Nsources); 60 | } 61 | 62 | DistanceTableBA() = delete; 63 | DistanceTableBA(const DistanceTableBA&) = delete; 64 | ~DistanceTableBA() {} 65 | 66 | /** evaluate the full table */ 67 | inline void evaluate(ParticleSet& P) 68 | { 69 | // be aware of the sign of Displacement 70 | for (int iat = 0; iat < Ntargets; ++iat) 71 | DTD_BConds::computeDistances(P.R[iat], 72 | Origin->RSoA, 73 | Distances[iat], 74 | Displacements[iat], 75 | 0, 76 | Nsources); 77 | } 78 | 79 | /** evaluate the iat-row with the current position 80 | * 81 | * Fill Temp_r and Temp_dr and copy them Distances & Displacements 82 | */ 83 | inline void evaluate(ParticleSet& P, IndexType iat) 84 | { 85 | DTD_BConds::computeDistances(P.R[iat], 86 | Origin->RSoA, 87 | Distances[iat], 88 | Displacements[iat], 89 | 0, 90 | Nsources); 91 | } 92 | 93 | /// evaluate the temporary pair relations 94 | inline void move(const ParticleSet& P, const PosType& rnew) 95 | { 96 | DTD_BConds::computeDistances(rnew, Origin->RSoA, Temp_r.data(), Temp_dr, 0, Nsources); 97 | } 98 | 99 | /// update the stripe for jat-th particle 100 | inline void update(IndexType iat) 101 | { 102 | std::copy_n(Temp_r.data(), Nsources, Distances[iat]); 103 | for (int idim = 0; idim < D; ++idim) 104 | std::copy_n(Temp_dr.data(idim), Nsources, Displacements[iat].data(idim)); 105 | } 106 | }; 107 | } // namespace qmcplusplus 108 | #endif 109 | -------------------------------------------------------------------------------- /src/Particle/FastParticleOperators.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeongnim Kim, jeongnim.kim@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeremy McMinnis, jmcminis@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Mark A. Berrill, berrillma@ornl.gov, 13 | // Oak Ridge National Laboratory 14 | // 15 | // File created by: 16 | // Jeongnim Kim, jeongnim.kim@gmail.com, 17 | // University of Illinois at Urbana-Champaign 18 | //////////////////////////////////////////////////////////////////////////////// 19 | 20 | /** @file FastParticleOperators.h 21 | * @brief template functions to support conversion and handling of boundary 22 | * conditions. 23 | */ 24 | #ifndef OHMMS_FAST_PARTICLE_OPERATORS_H 25 | #define OHMMS_FAST_PARTICLE_OPERATORS_H 26 | 27 | namespace qmcplusplus 28 | { 29 | /** Dummy template class to be specialized 30 | * 31 | * - T1 the datatype to be transformed 32 | * - T2 the transformation matrix 33 | * - ORTHO true, if only Diagonal Elements are used 34 | */ 35 | template 36 | struct ConvertPosUnit 37 | {}; 38 | 39 | template 40 | struct ConvertPosUnit>, Tensor, 3, false> 41 | { 42 | typedef ParticleAttrib> Array_t; 43 | typedef Tensor Transformer_t; 44 | 45 | inline static void 46 | apply(const Array_t& pin, const Transformer_t& X, Array_t& pout, int first, int last) 47 | { 48 | T x00 = X[0], x01 = X[1], x02 = X[2], x10 = X[3], x11 = X[4], x12 = X[5], x20 = X[6], 49 | x21 = X[7], x22 = X[8]; 50 | #pragma ivdep 51 | for (int i = first; i < last; i++) 52 | { 53 | pout[i][0] = pin[i][0] * x00 + pin[i][1] * x10 + pin[i][2] * x20; 54 | pout[i][1] = pin[i][0] * x01 + pin[i][1] * x11 + pin[i][2] * x21; 55 | pout[i][2] = pin[i][0] * x02 + pin[i][1] * x12 + pin[i][2] * x22; 56 | } 57 | } 58 | 59 | inline static void 60 | apply(const Transformer_t& X, const Array_t& pin, Array_t& pout, int first, int last) 61 | { 62 | T x00 = X[0], x01 = X[1], x02 = X[2], x10 = X[3], x11 = X[4], x12 = X[5], x20 = X[6], 63 | x21 = X[7], x22 = X[8]; 64 | #pragma ivdep 65 | for (int i = first; i < last; i++) 66 | { 67 | pout[i][0] = pin[i][0] * x00 + pin[i][1] * x01 + pin[i][2] * x02; 68 | pout[i][1] = pin[i][0] * x10 + pin[i][1] * x11 + pin[i][2] * x12; 69 | pout[i][2] = pin[i][0] * x20 + pin[i][1] * x21 + pin[i][2] * x22; 70 | } 71 | } 72 | 73 | inline static void apply(Array_t& pinout, const Transformer_t& X, int first, int last) 74 | { 75 | T x00 = X[0], x01 = X[1], x02 = X[2], x10 = X[3], x11 = X[4], x12 = X[5], x20 = X[6], 76 | x21 = X[7], x22 = X[8]; 77 | #pragma ivdep 78 | for (int i = first; i < last; i++) 79 | { 80 | T _x(pinout[i][0]), _y(pinout[i][1]), _z(pinout[i][2]); 81 | pinout[i][0] = _x * x00 + _y * x10 + _z * x20; 82 | pinout[i][1] = _x * x01 + _y * x11 + _z * x21; 83 | pinout[i][2] = _x * x02 + _y * x12 + _z * x22; 84 | } 85 | } 86 | 87 | inline static void apply(const Transformer_t& X, Array_t& pinout, int first, int last) 88 | { 89 | T x00 = X[0], x01 = X[1], x02 = X[2], x10 = X[3], x11 = X[4], x12 = X[5], x20 = X[6], 90 | x21 = X[7], x22 = X[8]; 91 | #pragma ivdep 92 | for (int i = first; i < last; i++) 93 | { 94 | T _x(pinout[i][0]), _y(pinout[i][1]), _z(pinout[i][2]); 95 | pinout[i][0] = _x * x00 + _y * x01 + _z * x02; 96 | pinout[i][1] = _x * x10 + _y * x11 + _z * x12; 97 | pinout[i][2] = _x * x20 + _y * x21 + _z * x22; 98 | } 99 | } 100 | }; 101 | } // namespace qmcplusplus 102 | #endif 103 | -------------------------------------------------------------------------------- /src/Particle/Lattice/LatticeOperations.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeremy McMinnis, jmcminis@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeongnim Kim, jeongnim.kim@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // 13 | // File created by: 14 | // Jeongnim Kim, jeongnim.kim@gmail.com, 15 | // University of Illinois at Urbana-Champaign 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | #ifndef OHMMS_LATTICEOPERATIONS_H 19 | #define OHMMS_LATTICEOPERATIONS_H 20 | #include "Numerics/OhmmsPETE/TinyVector.h" 21 | 22 | namespace qmcplusplus 23 | { 24 | template 25 | struct CheckBoxConds 26 | { 27 | inline static bool inside(const TinyVector& u) 28 | { 29 | bool yes = (u[0] > 0.0 && u[0] < 1.0); 30 | for (int i = 1; i < D; ++i) 31 | yes &= (u[i] > 0.0 && u[i] < 1.0); 32 | return yes; 33 | } 34 | 35 | inline static bool inside(const TinyVector& u, TinyVector& ubox) 36 | { 37 | for (int i = 0; i < D; ++i) 38 | ubox[i] = u[i] - std::floor(u[i]); 39 | return true; 40 | } 41 | }; 42 | 43 | template 44 | struct CheckBoxConds 45 | { 46 | inline static bool inside(const TinyVector& u) 47 | { 48 | return (u[0] > 0.0 && u[0] < 1.0) && (u[1] > 0.0 && u[1] < 1.0) && (u[2] > 0.0 && u[2] < 1.0); 49 | } 50 | 51 | inline static bool inside(const TinyVector& u, const TinyVector& bc) 52 | { 53 | return (bc[0] || (u[0] > 0.0 && u[0] < 1.0)) && (bc[1] || (u[1] > 0.0 && u[1] < 1.0)) && 54 | (bc[2] || (u[2] > 0.0 && u[2] < 1.0)); 55 | } 56 | 57 | inline static bool inside(const TinyVector& u, TinyVector& ubox) 58 | { 59 | ubox[0] = u[0] - std::floor(u[0]); 60 | ubox[1] = u[1] - std::floor(u[1]); 61 | ubox[2] = u[2] - std::floor(u[2]); 62 | return true; 63 | } 64 | }; 65 | } // namespace qmcplusplus 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/Particle/ParticleAttrib.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // 9 | // File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp. 10 | //////////////////////////////////////////////////////////////////////////////// 11 | 12 | /**@file ParticleAttrib.h 13 | * 14 | * Declaraton of ParticleAttrib derived from Vector 15 | */ 16 | 17 | #ifndef OHMMS_NEW_PARTICLEATTRIB_PEPE_H 18 | #define OHMMS_NEW_PARTICLEATTRIB_PEPE_H 19 | 20 | #include 21 | 22 | namespace qmcplusplus 23 | { 24 | template> 25 | class ParticleAttrib : public Vector 26 | { 27 | typedef Vector __my_base; 28 | 29 | public: 30 | /// The unit type 31 | int InUnit; 32 | 33 | /** constructor with size n*/ 34 | explicit inline ParticleAttrib(size_t n = 0) : __my_base(n), InUnit(0) {} 35 | 36 | /** constructor with an initialized ref */ 37 | explicit inline ParticleAttrib(T* ref, size_t n) : __my_base(ref, n), InUnit(0) {} 38 | 39 | ParticleAttrib(const ParticleAttrib& rhs) = default; 40 | inline ParticleAttrib& operator=(const ParticleAttrib& rhs) = default; 41 | 42 | /** assignment operator to enable PETE */ 43 | template 44 | inline ParticleAttrib& operator=(const RHS& rhs) 45 | { 46 | assign(*this, rhs); 47 | return *this; 48 | } 49 | 50 | //@{set/set the unit 51 | inline void setUnit(int i) { InUnit = i; } 52 | inline int getUnit() const { return InUnit; } 53 | //@} 54 | }; 55 | } // namespace qmcplusplus 56 | 57 | #endif // OHMMS_PARTICLEATTRIB_PEPE_H 58 | -------------------------------------------------------------------------------- /src/Particle/ParticleIOUtility.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeongnim Kim, jeongnim.kim@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeremy McMinnis, jmcminis@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Mark A. Berrill, berrillma@ornl.gov, 13 | // Oak Ridge National Laboratory 14 | // 15 | // File created by: 16 | // Jeongnim Kim, jeongnim.kim@gmail.com, 17 | // University of Illinois at Urbana-Champaign 18 | //////////////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef OHMMS_PARTICLE_INPUTOUTPUT_UTILITY_H 21 | #define OHMMS_PARTICLE_INPUTOUTPUT_UTILITY_H 22 | 23 | namespace qmcplusplus 24 | { 25 | /** expand the particle set to the supercell size 26 | * @param ref_ initial particle set in primitive cell 27 | * @param tmat tiling matrix 28 | */ 29 | template 30 | void expandSuperCell(PS& ref_, const Tensor& tmat) 31 | { 32 | typedef typename PS::SingleParticlePos_t SingleParticlePos_t; 33 | 34 | Tensor I(1, 0, 0, 0, 1, 0, 0, 0, 1); 35 | bool identity = true; 36 | int ij = 0; 37 | while (identity && ij < 9) 38 | { 39 | identity = (I[ij] == tmat[ij]); 40 | ++ij; 41 | } 42 | if (identity) 43 | return; 44 | app_log() << " TileMatrix != Identity. Expanding a simulation cell for " << ref_.getName() 45 | << std::endl; 46 | { 47 | char buff[500]; 48 | snprintf(buff, 49 | 500, 50 | " tilematrix= %4d %4d %4d %4d %4d %4d %4d %4d %4d\n", 51 | tmat[0], 52 | tmat[1], 53 | tmat[2], 54 | tmat[3], 55 | tmat[4], 56 | tmat[5], 57 | tmat[6], 58 | tmat[7], 59 | tmat[8]); 60 | app_log() << buff << std::endl; 61 | } 62 | // convert2unit 63 | ref_.convert2Unit(ref_.R); 64 | ParticleSet::ParticleLayout_t PrimCell(ref_.Lattice); 65 | ref_.Lattice.set(dot(tmat, PrimCell.R)); 66 | int natoms = ref_.getTotalNum(); 67 | int numCopies = std::abs(det(tmat)); 68 | ParticleSet::ParticlePos_t primPos(ref_.R); 69 | ParticleSet::ParticleIndex_t primTypes(ref_.GroupID); 70 | ref_.resize(natoms * numCopies); 71 | int maxCopies = 10; 72 | int index = 0; 73 | // set the unit to the Cartesian 74 | ref_.R.InUnit = PosUnit::CartesianUnit; 75 | app_log() << " Reduced coord Cartesion coord species.\n"; 76 | for (int ns = 0; ns < ref_.getSpeciesSet().getTotalNum(); ++ns) 77 | { 78 | for (int i0 = -maxCopies; i0 <= maxCopies; i0++) 79 | for (int i1 = -maxCopies; i1 <= maxCopies; i1++) 80 | for (int i2 = -maxCopies; i2 <= maxCopies; i2++) 81 | for (int iat = 0; iat < primPos.size(); iat++) 82 | { 83 | if (primTypes[iat] != ns) 84 | continue; 85 | SingleParticlePos_t uPrim = primPos[iat]; 86 | for (int i = 0; i < 3; i++) 87 | uPrim[i] -= std::floor(uPrim[i]); 88 | SingleParticlePos_t r = PrimCell.toCart(uPrim) + (double)i0 * PrimCell.a(0) + 89 | (double)i1 * PrimCell.a(1) + (double)i2 * PrimCell.a(2); 90 | SingleParticlePos_t uSuper = ref_.Lattice.toUnit(r); 91 | if ((uSuper[0] >= -1.0e-6) && (uSuper[0] < 0.9999) && (uSuper[1] >= -1.0e-6) && 92 | (uSuper[1] < 0.9999) && (uSuper[2] >= -1.0e-6) && (uSuper[2] < 0.9999)) 93 | { 94 | char buff[500]; 95 | snprintf(buff, 96 | 500, 97 | " %10.4f %10.4f %10.4f %12.6f %12.6f %12.6f %d\n", 98 | uSuper[0], 99 | uSuper[1], 100 | uSuper[2], 101 | r[0], 102 | r[1], 103 | r[2], 104 | ns); 105 | app_log() << buff; 106 | ref_.R[index] = r; 107 | ref_.GroupID[index] = ns; // primTypes[iat]; 108 | ref_.ID[index] = index; 109 | ref_.PCID[index] = iat; 110 | index++; 111 | } 112 | } 113 | } 114 | app_log() << " Simulationcell after tiling" << std::endl; 115 | ref_.Lattice.print(app_log()); 116 | app_log() << std::endl; 117 | } 118 | } // namespace qmcplusplus 119 | #endif 120 | -------------------------------------------------------------------------------- /src/Particle/ParticleSet.BC.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeremy McMinnis, jmcminis@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeongnim Kim, jeongnim.kim@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Mark A. Berrill, berrillma@ornl.gov, 13 | // Oak Ridge National Laboratory 14 | // 15 | // File created by: 16 | // Jeongnim Kim, jeongnim.kim@gmail.com, 17 | // University of Illinois at Urbana-Champaign 18 | //////////////////////////////////////////////////////////////////////////////// 19 | 20 | /**@file ParticleSet.BC.cpp 21 | * @brief definition of functions controlling Boundary Conditions 22 | */ 23 | #include "Particle/ParticleSet.h" 24 | #include "Particle/FastParticleOperators.h" 25 | 26 | namespace qmcplusplus 27 | { 28 | void ParticleSet::convert2Unit(ParticlePos_t& pinout) 29 | { 30 | if (pinout.getUnit() == PosUnit::LatticeUnit) 31 | return; 32 | else 33 | { 34 | pinout.setUnit(PosUnit::LatticeUnit); 35 | ConvertPosUnit::apply(pinout, 36 | Lattice.G, 37 | 0, 38 | pinout.size()); 39 | } 40 | } 41 | 42 | void ParticleSet::convert2Cart(ParticlePos_t& pinout) 43 | { 44 | if (pinout.getUnit() == PosUnit::CartesianUnit) 45 | return; 46 | else 47 | { 48 | pinout.setUnit(PosUnit::CartesianUnit); 49 | ConvertPosUnit::apply(pinout, 50 | Lattice.R, 51 | 0, 52 | pinout.size()); 53 | } 54 | } 55 | } // namespace qmcplusplus 56 | -------------------------------------------------------------------------------- /src/Particle/ParticleSet_builder.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Ye Luo, yeluo@anl.gov, 9 | // Argonne National Laboratory 10 | // 11 | // File created by: 12 | // Ye Luo, yeluo@anl.gov, 13 | // Argonne National Laboratory 14 | //////////////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace qmcplusplus 22 | { 23 | int build_ions(ParticleSet& ions, const Tensor& tmat, Tensor& lattice) 24 | { 25 | ions.setName("ion"); 26 | ions.Lattice.BoxBConds = 1; 27 | lattice = tile_cell(ions, tmat, static_cast(1.0)); 28 | ions.RSoA = ions.R; // fill the SoA 29 | 30 | return ions.getTotalNum(); 31 | } 32 | 33 | int build_els(ParticleSet& els, const ParticleSet& ions, RandomGenerator& rng) 34 | { 35 | els.setName("e"); 36 | const int nels = count_electrons(ions, 1); 37 | const int nels3 = 3 * nels; 38 | 39 | { // create up/down electrons 40 | els.Lattice.BoxBConds = 1; 41 | els.Lattice.set(ions.Lattice); 42 | std::vector ud(2); 43 | ud[0] = nels / 2; 44 | ud[1] = nels - ud[0]; 45 | els.create(ud); 46 | els.R.InUnit = 1; 47 | rng.generate_uniform(&els.R[0][0], nels3); 48 | els.convert2Cart(els.R); // convert to Cartiesian 49 | els.RSoA = els.R; 50 | } 51 | 52 | return nels; 53 | } 54 | 55 | } // namespace qmcplusplus 56 | -------------------------------------------------------------------------------- /src/Particle/ParticleSet_builder.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Ye Luo, yeluo@anl.gov, Argonne National Laboratory 9 | // 10 | // File created by: 11 | // Ye Luo, yeluo@anl.gov, Argonne National Laboratory 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef QMCPLUSPLUS_PARTICLESET_BUILDER_HPP 15 | #define QMCPLUSPLUS_PARTICLESET_BUILDER_HPP 16 | 17 | #include 18 | #include 19 | 20 | namespace qmcplusplus 21 | { 22 | /// build the ParticleSet of ions 23 | int build_ions(ParticleSet& ions, const Tensor& tmat, Tensor& lattice); 24 | 25 | /// build the ParticleSet of electrons 26 | int build_els(ParticleSet& els, const ParticleSet& ions, RandomGenerator& rng); 27 | } // namespace qmcplusplus 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/Particle/VirtualParticleSet.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign 9 | // 10 | // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign 11 | ////////////////////////////////////////////////////////////////////////////////////// 12 | 13 | 14 | /** @file VirtualParticleSet.cpp 15 | * A proxy class to the quantum ParticleSet 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | namespace qmcplusplus 23 | { 24 | VirtualParticleSet::VirtualParticleSet(const ParticleSet& p, int nptcl) : refPS(p) 25 | { 26 | setName("virtual"); 27 | 28 | //initialize local data structure 29 | Lattice = p.Lattice; 30 | TotalNum = nptcl; 31 | R.resize(nptcl); 32 | RSoA.resize(nptcl); 33 | 34 | //create distancetables 35 | if (refPS.DistTables.size()) 36 | { 37 | DistTables.resize(refPS.DistTables.size()); 38 | for (int i = 0; i < DistTables.size(); ++i) 39 | DistTables[i] = createDistanceTable(refPS.DistTables[i]->origin(), *this, refPS.DistTables[0]->DTType); 40 | } 41 | } 42 | 43 | /// move virtual particles to new postions and update distance tables 44 | void VirtualParticleSet::makeMoves(int jel, const ParticlePos_t& vitualPos, bool sphere, int iat) 45 | { 46 | ScopedTimer local_timer(timers[Timer_makeMove]); 47 | 48 | if (sphere && iat < 0) 49 | APP_ABORT("VirtualParticleSet::makeMoves is invoked incorrectly, the flag sphere=true requires iat specified!"); 50 | onSphere = sphere; 51 | refPtcl = jel; 52 | refSourcePtcl = iat; 53 | R = vitualPos; 54 | RSoA.copyIn(R); 55 | for (int i = 0; i < DistTables.size(); i++) 56 | DistTables[i]->evaluate(*this); 57 | } 58 | 59 | } // namespace qmcplusplus 60 | -------------------------------------------------------------------------------- /src/Particle/VirtualParticleSet.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign 9 | // 10 | // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign 11 | ////////////////////////////////////////////////////////////////////////////////////// 12 | 13 | 14 | /** @file VirtualParticleSet.h 15 | * A proxy class to the quantum ParticleSet 16 | */ 17 | #ifndef QMCPLUSPLUS_VIRTUAL_PARTICLESET_H 18 | #define QMCPLUSPLUS_VIRTUAL_PARTICLESET_H 19 | 20 | #include 21 | #include 22 | 23 | namespace qmcplusplus 24 | { 25 | /** Introduced to handle virtual moves and ratio computations, e.g. for non-local PP evaluations. 26 | */ 27 | class VirtualParticleSet : public ParticleSet 28 | { 29 | private: 30 | /// true, if virtual particles are on a sphere for NLPP 31 | bool onSphere; 32 | 33 | public: 34 | /// Reference particle 35 | int refPtcl; 36 | /// Reference source particle, used when onSphere=true 37 | int refSourcePtcl; 38 | 39 | /// ParticleSet this object refers to 40 | const ParticleSet& refPS; 41 | 42 | inline bool isOnSphere() const { return onSphere; } 43 | 44 | /** constructor 45 | * @param p ParticleSet whose virtual moves are handled by this object 46 | * @param nptcl number of virtual particles 47 | */ 48 | VirtualParticleSet(const ParticleSet& p, int nptcl); 49 | 50 | /** move virtual particles to new postions and update distance tables 51 | * @param jel reference particle that all the VP moves from 52 | * @param vitualPos new positions 53 | * @param sphere set true if VP are on a sphere around the reference source particle 54 | * @param iat reference source particle 55 | */ 56 | void makeMoves(int jel, const ParticlePos_t& vitualPos, bool sphere = false, int iat = -1); 57 | }; 58 | } // namespace qmcplusplus 59 | #endif 60 | -------------------------------------------------------------------------------- /src/Particle/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #////////////////////////////////////////////////////////////////////////////////////// 2 | #// This file is distributed under the University of Illinois/NCSA Open Source License. 3 | #// See LICENSE file in top directory for details. 4 | #// 5 | #// Copyright (c) 2020 QMCPACK developers. 6 | #// 7 | #// File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | #// 9 | #// File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign 10 | #////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QMCPACK_UNIT_TEST_DIR}) 13 | 14 | SET(SRC_DIR particle) 15 | SET(UTEST_EXE test_${SRC_DIR}) 16 | SET(UTEST_NAME unit_test_${SRC_DIR}) 17 | 18 | 19 | ADD_EXECUTABLE(${UTEST_EXE} test_particle.cpp) 20 | TARGET_LINK_LIBRARIES(${UTEST_EXE} catch_main qmcbase qmcutil ${QMC_UTIL_LIBS}) 21 | 22 | ADD_UNIT_TEST(${UTEST_NAME} "${QMCPACK_UNIT_TEST_DIR}/${UTEST_EXE}") 23 | -------------------------------------------------------------------------------- /src/Particle/tests/test_particle.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign 8 | // 9 | // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | #include 14 | #include 15 | 16 | #include "catch.hpp" 17 | 18 | #include "Utilities/Configuration.h" 19 | #include "Numerics/OhmmsPETE/OhmmsMatrix.h" 20 | #include "Numerics/OhmmsPETE/TinyVector.h" 21 | #include "Particle/Lattice/CrystalLattice.h" 22 | #include "Particle/Lattice/ParticleBConds.h" 23 | #include "Particle/ParticleSet.h" 24 | #include "Particle/DistanceTable.h" 25 | #include "Particle/DistanceTableData.h" 26 | 27 | using std::string; 28 | 29 | namespace qmcplusplus 30 | { 31 | TEST_CASE("symmetric_distance_table PBC", "[particle]") 32 | { 33 | ParticleSet source; 34 | 35 | CrystalLattice grid; 36 | grid.BoxBConds = true; // periodic 37 | grid.R = ParticleSet::Tensor_t(6.74632230, 6.74632230, 0.00000000, 0.00000000, 3.37316115, 3.37316115, 3.37316115, 38 | 0.00000000, 3.37316115); 39 | grid.reset(); 40 | 41 | source.setName("electrons"); 42 | source.Lattice.set(grid); 43 | 44 | source.create(4); 45 | source.R[0] = ParticleSet::PosType(0.00000000, 0.00000000, 0.00000000); 46 | source.R[1] = ParticleSet::PosType(1.68658058, 1.68658058, 1.68658058); 47 | source.R[2] = ParticleSet::PosType(3.37316115, 3.37316115, 0.00000000); 48 | source.R[3] = ParticleSet::PosType(5.05974172, 5.05974172, 1.68658058); 49 | 50 | int TableID = source.addTable(source, DT_SOA); 51 | source.update(); 52 | 53 | REQUIRE(source.DistTables[TableID]->Distances[1][2] == Approx(2.9212432441)); 54 | REQUIRE(source.DistTables[TableID]->Distances[2][1] == Approx(2.9212432441)); 55 | REQUIRE(source.DistTables[TableID]->Displacements[1][2][0] == Approx(1.68658057)); 56 | REQUIRE(source.DistTables[TableID]->Displacements[1][2][1] == Approx(1.68658057)); 57 | REQUIRE(source.DistTables[TableID]->Displacements[1][2][2] == Approx(-1.68658058)); 58 | REQUIRE(source.DistTables[TableID]->Displacements[2][1][0] == Approx(-1.68658057)); 59 | REQUIRE(source.DistTables[TableID]->Displacements[2][1][1] == Approx(-1.68658057)); 60 | REQUIRE(source.DistTables[TableID]->Displacements[2][1][2] == Approx(1.68658057)); 61 | } 62 | 63 | } // namespace qmcplusplus 64 | -------------------------------------------------------------------------------- /src/QMCWaveFunctions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #////////////////////////////////////////////////////////////////////////////////////// 2 | #// This file is distributed under the University of Illinois/NCSA Open Source License. 3 | #// See LICENSE file in top directory for details. 4 | #// 5 | #// Copyright (c) 2019 QMCPACK developers. 6 | #// 7 | #// File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | #// 9 | #// File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | #////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | ADD_LIBRARY(qmcwfs 13 | ../QMCWaveFunctions/WaveFunction.cpp ../QMCWaveFunctions/SPOSet_builder.cpp 14 | ../QMCWaveFunctions/DiracDeterminant.cpp ../QMCWaveFunctions/DiracDeterminantRef.cpp) 15 | 16 | TARGET_LINK_LIBRARIES(qmcwfs PRIVATE Math::BLAS_LAPACK) 17 | 18 | SUBDIRS(tests) 19 | -------------------------------------------------------------------------------- /src/QMCWaveFunctions/DeterminantHelper.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | #ifndef QMCPLUSPLUS_DETERMINANT_HELPER_H 14 | #define QMCPLUSPLUS_DETERMINANT_HELPER_H 15 | 16 | #include 17 | 18 | namespace qmcplusplus 19 | { 20 | template 21 | inline T evaluatePhase(T sign_v) 22 | { 23 | return T((sign_v > 0) ? 0.0 : M_PI); 24 | } 25 | 26 | template 27 | inline T evaluatePhase(const std::complex& psi) 28 | { 29 | return T(std::arg(psi)); 30 | } 31 | 32 | /** evaluate the log(|psi|) and phase 33 | * @param psi real/complex value 34 | * @param phase phase of psi 35 | * @return log(|psi|) 36 | */ 37 | template 38 | inline T evaluateLogAndPhase(const T psi, T& phase) 39 | { 40 | if (psi < 0.0) 41 | { 42 | phase = M_PI; 43 | return std::log(-psi); 44 | } 45 | else 46 | { 47 | phase = 0.0; 48 | return std::log(psi); 49 | } 50 | } 51 | 52 | template 53 | inline T evaluateLogAndPhase(const std::complex& psi, T& phase) 54 | { 55 | phase = std::arg(psi); 56 | if (phase < 0.0) 57 | phase += 2.0 * M_PI; 58 | return std::log(std::abs(psi)); 59 | } 60 | 61 | /** generic conversion from type T1 to type T2 using implicit conversion 62 | */ 63 | template 64 | inline void convert(const T1& in, T2& out) 65 | { 66 | out = static_cast(in); 67 | } 68 | 69 | /** specialization of conversion from complex to real 70 | */ 71 | template 72 | inline void convert(const std::complex& in, T2& out) 73 | { 74 | out = static_cast(in.real()); 75 | } 76 | 77 | } // namespace qmcplusplus 78 | 79 | #endif // QMCPLUSPLUS_DETERMINANT_HELPER_H 80 | -------------------------------------------------------------------------------- /src/QMCWaveFunctions/DiracMatrix.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp. 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | #ifndef QMCPLUSPLUS_DIRAC_MATRIX_H 13 | #define QMCPLUSPLUS_DIRAC_MATRIX_H 14 | 15 | #include "Numerics/Blasf.h" 16 | #include "Numerics/OhmmsBlas.h" 17 | #include "Numerics/OhmmsPETE/OhmmsMatrix.h" 18 | #include "Numerics/BlasThreadingEnv.h" 19 | #include "Utilities/scalar_traits.h" 20 | #include "Utilities/SIMD/algorithm.hpp" 21 | #include "QMCWaveFunctions/DeterminantHelper.h" 22 | 23 | namespace qmcplusplus 24 | { 25 | template 26 | inline T computeLogDet(const T* restrict diag, int n, const int* restrict pivot, T& phase) 27 | { 28 | T logdet(0); 29 | int sign_det = 1; 30 | for (size_t i = 0; i < n; i++) 31 | { 32 | sign_det *= (pivot[i] == i + 1) ? 1 : -1; 33 | sign_det *= (diag[i] > 0) ? 1 : -1; 34 | logdet += std::log(std::abs(diag[i])); 35 | } 36 | phase = (sign_det > 0) ? T(0) : M_PI; 37 | return logdet; 38 | } 39 | 40 | template 41 | inline T computeLogDet(const std::complex* restrict diag, int n, const int* restrict pivot, T& phase) 42 | { 43 | T logdet(0); 44 | phase = T(0); 45 | for (size_t i = 0; i < n; i++) 46 | { 47 | phase += std::arg(diag[i]); 48 | if (pivot[i] != i + 1) 49 | phase += M_PI; 50 | logdet += std::log(diag[i].real() * diag[i].real() + diag[i].imag() * diag[i].imag()); 51 | //slightly smaller error with the following 52 | // logdet+=2.0*std::log(std::abs(x[ii]); 53 | } 54 | constexpr T one_over_2pi = T(1) / TWOPI; 55 | phase -= std::floor(phase * one_over_2pi) * TWOPI; 56 | return 0.5 * logdet; 57 | } 58 | 59 | template 60 | class DiracMatrix 61 | { 62 | typedef typename scalar_traits::real_type real_type; 63 | typedef typename scalar_traits::real_type real_type_fp; 64 | aligned_vector m_work; 65 | aligned_vector m_pivot; 66 | int Lwork; 67 | /// scratch space used for mixed precision 68 | Matrix psiM_fp; 69 | /// LU diagonal elements 70 | aligned_vector LU_diag; 71 | 72 | /// reset internal work space 73 | inline void reset(T_FP* invMat_ptr, const int lda) 74 | { 75 | m_pivot.resize(lda); 76 | Lwork = -1; 77 | T_FP tmp; 78 | real_type_fp lw; 79 | int status; 80 | LAPACK::getri(lda, invMat_ptr, lda, m_pivot.data(), &tmp, Lwork, status); 81 | convert(tmp, lw); 82 | Lwork = static_cast(lw); 83 | m_work.resize(Lwork); 84 | LU_diag.resize(lda); 85 | } 86 | 87 | public: 88 | DiracMatrix() : Lwork(0) {} 89 | 90 | /** compute the inverse of the transpose of matrix A 91 | * assume precision T_FP >= T, do the inversion always with T_FP 92 | */ 93 | inline void invert_transpose(const Matrix& amat, Matrix& invMat, real_type& LogDet, real_type& Phase) 94 | { 95 | BlasThreadingEnv knob(getNextLevelNumThreads()); 96 | const int n = invMat.rows(); 97 | const int lda = invMat.cols(); 98 | T_FP* invMat_ptr(nullptr); 99 | #if !defined(MIXED_PRECISION) 100 | simd::transpose(amat.data(), n, amat.cols(), invMat.data(), n, invMat.cols()); 101 | invMat_ptr = invMat.data(); 102 | #else 103 | psiM_fp.resize(n, lda); 104 | simd::transpose(amat.data(), n, amat.cols(), psiM_fp.data(), n, psiM_fp.cols()); 105 | invMat_ptr = psiM_fp.data(); 106 | #endif 107 | if (Lwork < lda) 108 | reset(invMat_ptr, lda); 109 | int status; 110 | LAPACK::getrf(n, n, invMat_ptr, lda, m_pivot.data(), status); 111 | for (int i = 0; i < n; i++) 112 | LU_diag[i] = invMat_ptr[i * lda + i]; 113 | real_type_fp Phase_tmp; 114 | LogDet = computeLogDet(LU_diag.data(), n, m_pivot.data(), Phase_tmp); 115 | Phase = Phase_tmp; 116 | LAPACK::getri(n, invMat_ptr, lda, m_pivot.data(), m_work.data(), Lwork, status); 117 | #if defined(MIXED_PRECISION) 118 | invMat = psiM_fp; 119 | #endif 120 | } 121 | }; 122 | } // namespace qmcplusplus 123 | 124 | #endif // QMCPLUSPLUS_DIRAC_MATRIX_H 125 | -------------------------------------------------------------------------------- /src/QMCWaveFunctions/SPOSet_builder.cpp: -------------------------------------------------------------------------------- 1 | // This file is distributed under the University of Illinois/NCSA Open Source 2 | // License. See LICENSE file in top directory for details. 3 | // 4 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 5 | // 6 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 7 | // 8 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 9 | ////////////////////////////////////////////////////////////////////////////////////// 10 | 11 | 12 | #include "QMCWaveFunctions/SPOSet_builder.h" 13 | #include 14 | #include "QMCWaveFunctions/einspline_spo.hpp" 15 | #include "QMCWaveFunctions/einspline_spo_ref.hpp" 16 | 17 | namespace qmcplusplus 18 | { 19 | SPOSet* build_SPOSet(bool useRef, 20 | int nx, 21 | int ny, 22 | int nz, 23 | int num_splines, 24 | int nblocks, 25 | const Tensor& lattice_b, 26 | bool init_random) 27 | { 28 | if (useRef) 29 | { 30 | auto* spo_main = new miniqmcreference::einspline_spo_ref; 31 | spo_main->set(nx, ny, nz, num_splines, nblocks); 32 | spo_main->Lattice.set(lattice_b); 33 | return dynamic_cast(spo_main); 34 | } 35 | else 36 | { 37 | auto* spo_main = new einspline_spo; 38 | spo_main->set(nx, ny, nz, num_splines, nblocks); 39 | spo_main->Lattice.set(lattice_b); 40 | return dynamic_cast(spo_main); 41 | } 42 | } 43 | 44 | SPOSet* build_SPOSet_view(bool useRef, const SPOSet* SPOSet_main, int team_size, int member_id) 45 | { 46 | if (useRef) 47 | { 48 | auto* temp_ptr = 49 | dynamic_cast*>(SPOSet_main); 50 | auto* spo_view = 51 | new miniqmcreference::einspline_spo_ref(*temp_ptr, team_size, member_id); 52 | return dynamic_cast(spo_view); 53 | } 54 | else 55 | { 56 | auto* temp_ptr = dynamic_cast*>(SPOSet_main); 57 | auto* spo_view = new einspline_spo(*temp_ptr, team_size, member_id); 58 | return dynamic_cast(spo_view); 59 | } 60 | } 61 | 62 | } // namespace qmcplusplus 63 | -------------------------------------------------------------------------------- /src/QMCWaveFunctions/SPOSet_builder.h: -------------------------------------------------------------------------------- 1 | // This file is distributed under the University of Illinois/NCSA Open Source 2 | // License. See LICENSE file in top directory for details. 3 | // 4 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 5 | // 6 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 7 | // 8 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 9 | ////////////////////////////////////////////////////////////////////////////////////// 10 | 11 | 12 | #ifndef QMCPLUSPLUS_SINGLEPARTICLEORBITALSET_BUILDER_H 13 | #define QMCPLUSPLUS_SINGLEPARTICLEORBITALSET_BUILDER_H 14 | 15 | #include "QMCWaveFunctions/SPOSet.h" 16 | 17 | namespace qmcplusplus 18 | { 19 | /// build the einspline SPOSet. 20 | SPOSet* build_SPOSet(bool useRef, 21 | int nx, 22 | int ny, 23 | int nz, 24 | int num_splines, 25 | int nblocks, 26 | const Tensor& lattice_b, 27 | bool init_random = true); 28 | 29 | /// build the einspline SPOSet as a view of the main one. 30 | SPOSet* build_SPOSet_view(bool useRef, const SPOSet* SPOSet_main, int team_size, int member_id); 31 | 32 | } // namespace qmcplusplus 33 | #endif 34 | -------------------------------------------------------------------------------- /src/QMCWaveFunctions/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #////////////////////////////////////////////////////////////////////////////////////// 2 | #// This file is distributed under the University of Illinois/NCSA Open Source License. 3 | #// See LICENSE file in top directory for details. 4 | #// 5 | #// Copyright (c) 2020 QMCPACK developers. 6 | #// 7 | #// File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | #// 9 | #// File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | #////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QMCPACK_UNIT_TEST_DIR}) 13 | 14 | SET(SRC_DIR wavefunction) 15 | SET(UTEST_EXE test_${SRC_DIR}) 16 | SET(UTEST_NAME unit_test_${SRC_DIR}) 17 | 18 | ADD_EXECUTABLE(${UTEST_EXE} test_dirac_det.cpp test_dirac_matrix.cpp) 19 | TARGET_LINK_LIBRARIES(${UTEST_EXE} catch_main qmcwfs qmcbase qmcutil ${QMC_UTIL_LIBS}) 20 | 21 | ADD_UNIT_TEST(${UTEST_NAME} "${QMCPACK_UNIT_TEST_DIR}/${UTEST_EXE}") 22 | -------------------------------------------------------------------------------- /src/QMCWaveFunctions/tests/test_dirac_matrix.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | #include "catch.hpp" 14 | 15 | #include 16 | #include 17 | 18 | #include "Numerics/OhmmsPETE/OhmmsMatrix.h" 19 | #include "QMCWaveFunctions/WaveFunctionComponent.h" 20 | #include "QMCWaveFunctions/DiracMatrix.h" 21 | #include "QMCWaveFunctions/DelayedUpdate.h" 22 | 23 | using std::string; 24 | 25 | namespace qmcplusplus 26 | { 27 | 28 | typedef QMCTraits::RealType RealType; 29 | typedef QMCTraits::ValueType ValueType; 30 | 31 | template 32 | void check_matrix(Matrix& a, Matrix& b) 33 | { 34 | REQUIRE(a.size() == b.size()); 35 | for (int i = 0; i < a.rows(); i++) 36 | { 37 | for (int j = 0; j < a.cols(); j++) 38 | { 39 | REQUIRE(a(i, j) == ValueApprox(b(i, j))); 40 | } 41 | } 42 | } 43 | 44 | TEST_CASE("DiracMatrix_identity", "[wavefunction][fermion]") 45 | { 46 | DiracMatrix dm; 47 | 48 | Matrix m, m_invT; 49 | RealType LogValue, PhaseValue; 50 | m.resize(3, 3); 51 | m_invT.resize(3, 3); 52 | 53 | m(0, 0) = 1.0; 54 | m(1, 1) = 1.0; 55 | m(2, 2) = 1.0; 56 | 57 | dm.invert_transpose(m, m_invT, LogValue, PhaseValue); 58 | REQUIRE(LogValue == ValueApprox(0.0)); 59 | 60 | Matrix eye; 61 | eye.resize(3, 3); 62 | eye(0, 0) = 1.0; 63 | eye(1, 1) = 1.0; 64 | eye(2, 2) = 1.0; 65 | 66 | check_matrix(m_invT, eye); 67 | } 68 | 69 | TEST_CASE("DiracMatrix_inverse", "[wavefunction][fermion]") 70 | { 71 | DiracMatrix dm; 72 | 73 | Matrix a, a_T, a_inv; 74 | RealType LogValue, PhaseValue; 75 | a.resize(3, 3); 76 | a_T.resize(3, 3); 77 | a_inv.resize(3, 3); 78 | 79 | a(0, 0) = 2.3; 80 | a(0, 1) = 4.5; 81 | a(0, 2) = 2.6; 82 | a(1, 0) = 0.5; 83 | a(1, 1) = 8.5; 84 | a(1, 2) = 3.3; 85 | a(2, 0) = 1.8; 86 | a(2, 1) = 4.4; 87 | a(2, 2) = 4.9; 88 | 89 | simd::transpose(a.data(), a.rows(), a.cols(), a_T.data(), a_T.rows(), a_T.cols()); 90 | dm.invert_transpose(a_T, a_inv, LogValue, PhaseValue); 91 | REQUIRE(LogValue == ValueApprox(3.78518913425)); 92 | 93 | Matrix b; 94 | b.resize(3, 3); 95 | 96 | b(0, 0) = 0.6159749342; 97 | b(0, 1) = -0.2408954682; 98 | b(0, 2) = -0.1646081192; 99 | b(1, 0) = 0.07923894288; 100 | b(1, 1) = 0.1496231042; 101 | b(1, 2) = -0.1428117337; 102 | b(2, 0) = -0.2974298429; 103 | b(2, 1) = -0.04586322768; 104 | b(2, 2) = 0.3927890292; 105 | 106 | check_matrix(a_inv, b); 107 | } 108 | 109 | 110 | TEST_CASE("DiracMatrix_update_row", "[wavefunction][fermion]") 111 | { 112 | DiracMatrix dm; 113 | DelayedUpdate updateEng; 114 | updateEng.resize(3, 1); 115 | 116 | Matrix a, a_T, a_inv; 117 | RealType LogValue, PhaseValue; 118 | a.resize(3, 3); 119 | a_T.resize(3, 3); 120 | a_inv.resize(3, 3); 121 | 122 | a(0, 0) = 2.3; 123 | a(0, 1) = 4.5; 124 | a(0, 2) = 2.6; 125 | a(1, 0) = 0.5; 126 | a(1, 1) = 8.5; 127 | a(1, 2) = 3.3; 128 | a(2, 0) = 1.8; 129 | a(2, 1) = 4.4; 130 | a(2, 2) = 4.9; 131 | 132 | simd::transpose(a.data(), a.rows(), a.cols(), a_T.data(), a_T.rows(), a_T.cols()); 133 | dm.invert_transpose(a_T, a_inv, LogValue, PhaseValue); 134 | 135 | // new row 136 | Vector v(3), invRow(3); 137 | v[0] = 1.9; 138 | v[1] = 2.0; 139 | v[2] = 3.1; 140 | 141 | updateEng.getInvRow(a_inv, 0, invRow); 142 | ValueType det_ratio1 = simd::dot(v.data(), invRow.data(), invRow.size()); 143 | 144 | ValueType det_ratio = 0.178276269185; 145 | REQUIRE(det_ratio1 == ValueApprox(det_ratio)); 146 | updateEng.acceptRow(a_inv, 0, v); 147 | 148 | Matrix b; 149 | b.resize(3, 3); 150 | 151 | b(0, 0) = 3.455170657; 152 | b(0, 1) = -1.35124809; 153 | b(0, 2) = -0.9233316353; 154 | b(1, 0) = 0.05476311768; 155 | b(1, 1) = 0.1591951095; 156 | b(1, 2) = -0.1362710138; 157 | b(2, 0) = -2.235099338; 158 | b(2, 1) = 0.7119205298; 159 | b(2, 2) = 0.9105960265; 160 | 161 | check_matrix(a_inv, b); 162 | } 163 | 164 | 165 | } // namespace qmcplusplus 166 | -------------------------------------------------------------------------------- /src/Utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #////////////////////////////////////////////////////////////////////////////////////// 2 | #// This file is distributed under the University of Illinois/NCSA Open Source License. 3 | #// See LICENSE file in top directory for details. 4 | #// 5 | #// Copyright (c) 2020 QMCPACK developers. 6 | #// 7 | #// File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | #// 9 | #// File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | #////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | ADD_LIBRARY(catch_main catch_main.cpp) 13 | TARGET_INCLUDE_DIRECTORIES(catch_main PUBLIC "${PROJECT_SOURCE_DIR}/external_codes/catch") 14 | 15 | SUBDIRS(tests) 16 | -------------------------------------------------------------------------------- /src/Utilities/Clock.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeongnim Kim, jeongnim.kim@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeremy McMinnis, jmcminis@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Mark A. Berrill, berrillma@ornl.gov, 13 | // Oak Ridge National Laboratory 14 | // 15 | // File created by: 16 | // Jeongnim Kim, jeongnim.kim@gmail.com, 17 | // University of Illinois at Urbana-Champaign 18 | //////////////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef QMCPLUSPLUS_CLOCK_H 21 | #define QMCPLUSPLUS_CLOCK_H 22 | 23 | #include 24 | #include 25 | #include "Utilities/Configuration.h" 26 | 27 | namespace qmcplusplus 28 | { 29 | #if defined(USE_FAKE_CLOCK) 30 | extern double fake_cpu_clock_value; 31 | extern double fake_cpu_clock_increment; 32 | double fake_cpu_clock() 33 | { 34 | fake_cpu_clock_value += fake_cpu_clock_increment; 35 | return fake_cpu_clock_value; 36 | } 37 | #define cpu_clock fake_cpu_clock 38 | #else 39 | #if defined(__bgq__) 40 | __inline__ unsigned long long getticks(void) 41 | { 42 | unsigned long long int result = 0; 43 | __asm__ volatile("\tmfspr %0,268 \n" : "=r"(result)); 44 | return result; 45 | } 46 | 47 | inline double cpu_clock() 48 | { 49 | // BG/Q node - using 1.6e9 ticks per second 50 | const double SEC_PER_TICKS = 6.25e-10; 51 | return static_cast(getticks()) * SEC_PER_TICKS; 52 | } 53 | 54 | #else 55 | #if defined(ENABLE_OPENMP) 56 | inline double cpu_clock() { return omp_get_wtime(); } 57 | #else 58 | inline double cpu_clock() 59 | { 60 | struct timeval tv; 61 | gettimeofday(&tv, NULL); 62 | return (double)tv.tv_sec + (1.e-6) * tv.tv_usec; 63 | } 64 | #endif // 65 | #endif 66 | #endif 67 | } // namespace qmcplusplus 68 | #endif 69 | -------------------------------------------------------------------------------- /src/Utilities/Communicate.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2018 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory 8 | // 9 | // File created by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | /** @file Communicate.cpp 14 | * @brief Defintion of Communicate and CommunicateMPI classes. 15 | */ 16 | #include 17 | #include 18 | 19 | Communicate::Communicate(int argc, char** argv) 20 | { 21 | #ifdef HAVE_MPI 22 | MPI_Init(&argc, &argv); 23 | m_world = MPI_COMM_WORLD; 24 | MPI_Comm_rank(m_world, &m_rank); 25 | MPI_Comm_size(m_world, &m_size); 26 | #else 27 | m_rank = 0; 28 | m_size = 1; 29 | #endif 30 | } 31 | 32 | Communicate::~Communicate() 33 | { 34 | #ifdef HAVE_MPI 35 | MPI_Finalize(); 36 | #endif 37 | } 38 | 39 | void Communicate::reduce(int& value) 40 | { 41 | #ifdef HAVE_MPI 42 | int local_value = value; 43 | MPI_Reduce(&local_value, &value, 1, MPI_INT, MPI_SUM, 0, m_world); 44 | #endif 45 | } 46 | 47 | void Communicate::reduce(float& value) 48 | { 49 | #ifdef HAVE_MPI 50 | float local_value = value; 51 | MPI_Reduce(&local_value, &value, 1, MPI_FLOAT, MPI_SUM, 0, m_world); 52 | #endif 53 | } 54 | 55 | void Communicate::reduce(double& value) 56 | { 57 | #ifdef HAVE_MPI 58 | double local_value = value; 59 | MPI_Reduce(&local_value, &value, 1, MPI_DOUBLE, MPI_SUM, 0, m_world); 60 | #endif 61 | } 62 | -------------------------------------------------------------------------------- /src/Utilities/Communicate.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2018 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory 8 | // 9 | // File created by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | /** @file Communicate.h 14 | * @brief Declaration of Communicate and CommunicateMPI classes. 15 | */ 16 | #ifndef COMMUNICATE_H 17 | #define COMMUNICATE_H 18 | 19 | #include 20 | 21 | #ifdef HAVE_MPI 22 | #include 23 | #endif 24 | 25 | class Communicate 26 | { 27 | public: 28 | Communicate(int argc, char** argv); 29 | 30 | virtual ~Communicate(); 31 | 32 | int rank() { return m_rank; } 33 | int size() { return m_size; } 34 | bool root() { return m_rank == 0; } 35 | #ifdef HAVE_MPI 36 | MPI_Comm world() { return m_world; } 37 | #endif 38 | void reduce(int& value); 39 | void reduce(float& value); 40 | void reduce(double& value); 41 | 42 | protected: 43 | int m_rank; 44 | int m_size; 45 | #ifdef HAVE_MPI 46 | MPI_Comm m_world; 47 | #endif 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/Utilities/Constants.h: -------------------------------------------------------------------------------- 1 | // This file is distributed under the University of Illinois/NCSA Open Source 2 | // License. See LICENSE file in top directory for details. 3 | // 4 | // Copyright (c) 2019 QMCPACK developers. 5 | // 6 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 7 | // 8 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 9 | ////////////////////////////////////////////////////////////////////////////////////// 10 | 11 | #ifndef CONSTANTS_H 12 | #define CONSTANTS_H 13 | 14 | #ifndef M_PI 15 | #define M_PI 3.14159265358979323846 16 | #endif 17 | 18 | #ifndef TWOPI 19 | #define TWOPI (2 * M_PI) 20 | #endif /* TWOPI */ 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/Utilities/InfoStream.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | #include 14 | #include 15 | 16 | InfoStream::~InfoStream() 17 | { 18 | if (currStream != nullStream) 19 | { 20 | delete nullStream; 21 | } 22 | if (ownStream && currStream) 23 | { 24 | delete (currStream); 25 | } 26 | } 27 | 28 | void InfoStream::pause() 29 | { 30 | if (currStream != nullStream) 31 | { 32 | prevStream = currStream; 33 | currStream = nullStream; 34 | } 35 | } 36 | 37 | void InfoStream::resume() 38 | { 39 | if (prevStream) 40 | { 41 | currStream = prevStream; 42 | prevStream = NULL; 43 | } 44 | } 45 | 46 | void InfoStream::shutOff() 47 | { 48 | prevStream = NULL; 49 | currStream = nullStream; 50 | } 51 | 52 | void InfoStream::redirectToFile(const std::string& fname) 53 | { 54 | currStream = new std::ofstream(fname); 55 | ownStream = true; 56 | } 57 | 58 | void InfoStream::redirectToSameStream(InfoStream& info) 59 | { 60 | currStream = &info.getStream(); 61 | ownStream = false; 62 | } 63 | -------------------------------------------------------------------------------- /src/Utilities/InfoStream.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | /** @file InfoStream.h 14 | * @brief Declaration of InfoStream class. 15 | */ 16 | 17 | #ifndef INFOSTREAM_H 18 | #define INFOSTREAM_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /** 26 | * Interface to output streams. Can redirect output to stdout/stderr, a file, or a null stream. 27 | */ 28 | 29 | class InfoStream 30 | { 31 | public: 32 | InfoStream(std::ostream* output_stream) 33 | : prevStream(NULL), nullStream(new std::ostream(NULL)), ownStream(false) 34 | { 35 | currStream = output_stream; 36 | } 37 | 38 | InfoStream(InfoStream& in) 39 | : prevStream(NULL), nullStream(new std::ostream(NULL)), ownStream(false) 40 | { 41 | redirectToSameStream(in); 42 | } 43 | 44 | ~InfoStream(); 45 | 46 | std::ostream& getStream(const std::string& tag = "") { return *currStream; } 47 | 48 | void setStream(std::ostream* output_stream) { currStream = output_stream; } 49 | 50 | 51 | void flush() { currStream->flush(); } 52 | 53 | /// Stop output (redirect to a null stream) 54 | void pause(); 55 | 56 | /// Continue output on the stream used before pausing 57 | void resume(); 58 | 59 | /// Open a file and output to that file 60 | void redirectToFile(const std::string& fname); 61 | 62 | /// Copy a stream 63 | void redirectToSameStream(InfoStream& info); 64 | 65 | /// Permanently turn off the stream 66 | void shutOff(); 67 | 68 | private: 69 | // Keep track of whether we should delete the stream or not 70 | bool ownStream; 71 | 72 | std::ostream* currStream; 73 | 74 | // save stream during pause 75 | std::ostream* prevStream; 76 | 77 | // Created at construction. Used during pause 78 | std::ostream* nullStream; 79 | }; 80 | 81 | template 82 | inline InfoStream& operator<<(InfoStream& o, const T& val) 83 | { 84 | o.getStream() << val; 85 | return o; 86 | } 87 | 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/Utilities/OutputManager.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory 8 | // 9 | // File created by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | #include 14 | 15 | 16 | InfoStream infoSummary(&std::cout); 17 | InfoStream infoLog(&std::cout); 18 | InfoStream infoError(&std::cerr); 19 | InfoStream infoDebug(&std::cout); 20 | 21 | OutputManagerClass outputManager(Verbosity::LOW); 22 | 23 | 24 | void OutputManagerClass::setVerbosity(Verbosity level) 25 | { 26 | global_verbosity_level = level; 27 | if (isActive(Verbosity::DEBUG)) 28 | { 29 | infoSummary.resume(); 30 | infoLog.resume(); 31 | infoDebug.resume(); 32 | } 33 | else if (isActive(Verbosity::HIGH)) 34 | { 35 | infoSummary.resume(); 36 | infoLog.resume(); 37 | infoDebug.pause(); 38 | } 39 | else if (isActive(Verbosity::LOW)) 40 | { 41 | infoSummary.resume(); 42 | infoLog.pause(); 43 | infoDebug.pause(); 44 | } 45 | } 46 | 47 | bool OutputManagerClass::isActive(Verbosity level) { return level <= global_verbosity_level; } 48 | 49 | void OutputManagerClass::pause() 50 | { 51 | infoSummary.pause(); 52 | infoLog.pause(); 53 | } 54 | 55 | void OutputManagerClass::resume() 56 | { 57 | infoSummary.resume(); 58 | infoLog.resume(); 59 | } 60 | 61 | void OutputManagerClass::shutOff() 62 | { 63 | infoSummary.shutOff(); 64 | infoLog.shutOff(); 65 | infoError.shutOff(); 66 | infoDebug.shutOff(); 67 | } 68 | -------------------------------------------------------------------------------- /src/Utilities/OutputManager.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory 8 | // 9 | // File created by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | /** @file OutputManager.h 14 | * @brief Declaration of OutputManager class. 15 | */ 16 | #ifndef OUTPUTMANAGER_H 17 | #define OUTPUTMANAGER_H 18 | 19 | #include 20 | 21 | 22 | enum class Verbosity 23 | { 24 | LOW, 25 | HIGH, 26 | DEBUG 27 | }; 28 | enum class LogType 29 | { 30 | SUMMARY, 31 | APP, 32 | ERROR, 33 | DEBUG 34 | }; 35 | 36 | extern InfoStream infoSummary; 37 | extern InfoStream infoLog; 38 | extern InfoStream infoError; 39 | extern InfoStream infoDebug; 40 | 41 | class OutputManagerClass 42 | { 43 | Verbosity global_verbosity_level; 44 | 45 | public: 46 | OutputManagerClass(Verbosity level = Verbosity::LOW) { setVerbosity(level); } 47 | 48 | void setVerbosity(Verbosity level); 49 | 50 | bool isActive(Verbosity level); 51 | 52 | bool isDebugActive() { return isActive(Verbosity::DEBUG); } 53 | 54 | bool isHighActive() { return isActive(Verbosity::HIGH); } 55 | 56 | std::ostream& getStream(LogType log) 57 | { 58 | switch (log) 59 | { 60 | case LogType::SUMMARY: 61 | return infoSummary.getStream(); 62 | case LogType::APP: 63 | return infoLog.getStream(); 64 | case LogType::ERROR: 65 | return infoError.getStream(); 66 | case LogType::DEBUG: 67 | return infoDebug.getStream(); 68 | } 69 | return infoDebug.getStream(); 70 | } 71 | 72 | /// Pause the summary and log streams 73 | void pause(); 74 | 75 | /// Resume the summary and log streams 76 | void resume(); 77 | 78 | /// Permanently shut off all streams 79 | void shutOff(); 80 | }; 81 | 82 | extern OutputManagerClass outputManager; 83 | 84 | namespace qmcplusplus 85 | { 86 | inline std::ostream& app_summary() { return outputManager.getStream(LogType::SUMMARY); } 87 | 88 | inline std::ostream& app_log() { return outputManager.getStream(LogType::APP); } 89 | 90 | inline std::ostream& app_error() 91 | { 92 | outputManager.getStream(LogType::ERROR) << "ERROR "; 93 | return outputManager.getStream(LogType::ERROR); 94 | } 95 | 96 | inline std::ostream& app_warning() 97 | { 98 | outputManager.getStream(LogType::ERROR) << "WARNING "; 99 | return outputManager.getStream(LogType::ERROR); 100 | } 101 | 102 | inline std::ostream& app_debug_stream() { return outputManager.getStream(LogType::DEBUG); } 103 | 104 | // From https://stackoverflow.com/questions/11826554/standard-no-op-output-stream 105 | // If debugging is not active, this skips evaluation of the arguments 106 | #define app_debug \ 107 | if (!outputManager.isDebugActive()) {} \ 108 | else \ 109 | app_debug_stream 110 | 111 | }; // namespace qmcplusplus 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /src/Utilities/ParallelBlock.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 9 | // 10 | // File created by: 11 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef QMCPLUSPLUS_PARALLELBLOCK_HPP 15 | #define QMCPLUSPLUS_PARALLELBLOCK_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace qmcplusplus 23 | { 24 | 25 | enum class ParallelBlockThreading 26 | { 27 | OPENMP, 28 | STD 29 | // Planned 30 | // Boost 31 | // hpx 32 | }; 33 | 34 | /** Blocks until entire parallel block is done 35 | * 36 | * Required to prevent end of QMC block synchronization occuring 37 | * before all crowds are complete. For Devices with global or partially global 38 | * synchronization on memory management operations. RAII deallocation 39 | * badly damage performance. 40 | */ 41 | template 42 | class ParallelBlockBarrier 43 | { 44 | public: 45 | ParallelBlockBarrier(unsigned int num_threads) : num_threads_(num_threads) {} 46 | void wait(); 47 | 48 | private: 49 | unsigned int num_threads_; 50 | }; 51 | 52 | template 53 | inline void ParallelBlockBarrier::wait() 54 | { 55 | #pragma omp barrier 56 | } 57 | 58 | template<> 59 | inline void ParallelBlockBarrier::wait() 60 | { 61 | std::cout << "Barrier not supported by std threading. Implementation needed to avoid performance hit at end of QMCBlock.\n"; 62 | } 63 | 64 | 65 | /** Simple abstraction to launch num_threads running the same task 66 | * 67 | * All run the same task and get the same arg set plus an "id" from 0 to num_threads - 1 68 | */ 69 | template 70 | class ParallelBlock 71 | { 72 | public: 73 | ParallelBlock(unsigned int num_threads) : num_threads_(num_threads) {} 74 | template 75 | void operator()(F&& f, Args&&... args); 76 | template 77 | void operator()(F&& f, ParallelBlockBarrier& barrier, Args&&... args); 78 | 79 | private: 80 | unsigned int num_threads_; 81 | }; 82 | 83 | template 84 | template 85 | void ParallelBlock::operator()(F&& f, Args&&... args) 86 | 87 | { 88 | #pragma omp parallel for 89 | for (int task_id = 0; task_id < num_threads_; ++task_id) 90 | { 91 | f(task_id, std::forward(args)...); 92 | } 93 | } 94 | 95 | template<> 96 | template 97 | void ParallelBlock::operator()(F&& f, Args&&... args) 98 | 99 | { 100 | std::vector threads(num_threads_); 101 | 102 | for (int task_id = 0; task_id < num_threads_; ++task_id) 103 | { 104 | threads[task_id] = std::thread(std::forward(f), task_id, std::forward(args)...); 105 | } 106 | 107 | for (int task_id = 0; task_id < num_threads_; ++task_id) 108 | { 109 | threads[task_id].join(); 110 | } 111 | } 112 | 113 | template 114 | template 115 | void ParallelBlock::operator()(F&& f, ParallelBlockBarrier& barrier, Args&&... args) 116 | 117 | { 118 | omp_set_num_threads(num_threads_); 119 | #pragma omp parallel for 120 | for (int task_id = 0; task_id < num_threads_; ++task_id) 121 | { 122 | f(task_id, barrier, std::forward(args)...); 123 | } 124 | } 125 | 126 | } // namespace qmcplusplus 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /src/Utilities/QMCTypes.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2018 QMCPACK developers 6 | // 7 | // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 8 | // Ye Luo, yeluo@anl.gov, Argonne National Lab 9 | // 10 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Lab 11 | ////////////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef QMCPLUSPLUS_QMC_TYPES_H 14 | #define QMCPLUSPLUS_QMC_TYPES_H 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace qmcplusplus 21 | { 22 | /* Facilitates use of full/mixed precision without rebuilding the code 23 | * 24 | * a template class may define its local types 25 | * template 26 | * class Foo 27 | * { 28 | * using FooTypes = QMCTypes; 29 | * ... 30 | * }; 31 | * 32 | */ 33 | template 34 | class QMCTypes final 35 | { 36 | public: 37 | using RealType = Precision; 38 | using ComplexType = std::complex; 39 | #ifdef QMC_COMPLEX 40 | using ValueType = ComplexType; 41 | #else 42 | using ValueType = RealType; 43 | #endif 44 | using GradType = TinyVector; 45 | using PosType = TinyVector; 46 | using TensorType = Tensor; 47 | }; 48 | 49 | } // namespace qmcplusplus 50 | #endif 51 | -------------------------------------------------------------------------------- /src/Utilities/RandomGenerator.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Ken Esler, kpesler@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeongnim Kim, jeongnim.kim@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Jeremy McMinnis, jmcminis@gmail.com, 13 | // University of Illinois at Urbana-Champaign 14 | // Mark Dewing, markdewing@gmail.com, 15 | // University of Illinois at Urbana-Champaign 16 | // 17 | // File created by: 18 | // Jeongnim Kim, jeongnim.kim@gmail.com, 19 | // University of Illinois at Urbana-Champaign 20 | //////////////////////////////////////////////////////////////////////////////// 21 | 22 | /** @file RandomGenerator.h 23 | * @brief Declare a global Random Number Generator 24 | * 25 | * Selected among 26 | * - C++11 std::random 27 | * - (other choices are in the QMCPACK distribution) 28 | * 29 | * qmcplusplus::Random() returns a random number [0,1) 30 | * 31 | * When OpenMP is enabled, it is important to make sure each thread has its 32 | * own random number generator with a unique seed. Using a global lock on 33 | * a single generator would slow down the applications significantly. 34 | * 35 | */ 36 | #ifndef OHMMS_RANDOMGENERATOR 37 | #define OHMMS_RANDOMGENERATOR 38 | #ifdef HAVE_CONFIG_H 39 | #include "config.h" 40 | #endif 41 | #include 42 | #include 43 | 44 | #include 45 | 46 | struct BoxMuller2 47 | { 48 | template 49 | static inline void generate(RNG& rng, double* restrict a, int n) 50 | { 51 | for (int i = 0; i + 1 < n; i += 2) 52 | { 53 | double temp1 = 1.0 - 0.9999999999 * rng(), temp2 = rng(); 54 | a[i] = sqrt(-2.0 * log(temp1)) * cos(6.283185306 * temp2); 55 | a[i + 1] = sqrt(-2.0 * log(temp1)) * sin(6.283185306 * temp2); 56 | } 57 | if (n % 2 == 1) 58 | { 59 | double temp1 = 1 - 0.9999999999 * rng(), temp2 = rng(); 60 | a[n - 1] = sqrt(-2.0 * log(temp1)) * cos(6.283185306 * temp2); 61 | } 62 | } 63 | 64 | template 65 | static inline void generate(RNG& rng, float* restrict a, int n) 66 | { 67 | for (int i = 0; i + 1 < n; i += 2) 68 | { 69 | float temp1 = 1.0f - 0.9999999999f * rng(), temp2 = rng(); 70 | a[i] = sqrtf(-2.0f * logf(temp1)) * cosf(6.283185306f * temp2); 71 | a[i + 1] = sqrtf(-2.0f * logf(temp1)) * sinf(6.283185306f * temp2); 72 | } 73 | if (n % 2 == 1) 74 | { 75 | float temp1 = 1.0f - 0.9999999999f * rng(), temp2 = rng(); 76 | a[n - 1] = sqrtf(-2.0f * logf(temp1)) * cosf(6.283185306f * temp2); 77 | } 78 | } 79 | }; 80 | 81 | inline uint32_t MakeSeed(int i, int n) 82 | { 83 | const uint32_t u = 1 << 10; 84 | return static_cast(std::time(nullptr)) % u + (i + 1) * n + i; 85 | } 86 | 87 | #include "Utilities/StdRandom.h" 88 | namespace qmcplusplus 89 | { 90 | template 91 | using RandomGenerator = StdRandom; 92 | } 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /src/Utilities/SIMD/Mallocator.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | // -*- C++ -*- 12 | /** @file Mallocator.hpp 13 | */ 14 | #ifndef QMCPLUSPLUS_ALIGNED_ALLOCATOR_H 15 | #define QMCPLUSPLUS_ALIGNED_ALLOCATOR_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace qmcplusplus 23 | { 24 | template 25 | struct Mallocator 26 | { 27 | typedef T value_type; 28 | typedef size_t size_type; 29 | typedef T* pointer; 30 | typedef const T* const_pointer; 31 | 32 | Mallocator() = default; 33 | template 34 | Mallocator(const Mallocator&) 35 | {} 36 | 37 | template 38 | struct rebind 39 | { 40 | typedef Mallocator other; 41 | }; 42 | 43 | T* allocate(std::size_t n) 44 | { 45 | void* pt(nullptr); 46 | std::size_t asize = n * sizeof(T); 47 | std::size_t amod = asize % ALIGN; 48 | if (amod != 0) 49 | asize += ALIGN - amod; 50 | 51 | #if __STDC_VERSION__ >= 201112L || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16) 52 | // as per C11 standard asize must be an integral multiple of ALIGN 53 | // or behavior is undefined. Some implementations support all positive 54 | // values of asize but the standard has not been amended 55 | // This is also not guaranteed threadsafe until it appeared in 56 | // the C++17 standard. 57 | pt = aligned_alloc(ALIGN, asize); 58 | #else 59 | // While posix memalign can deal with asize violating the C11 standard 60 | // assumptions made later by our simd code namely copyn require allocation 61 | // of the entire aligned block to avoid heap buffer read overflows later 62 | posix_memalign(&pt, ALIGN, asize); 63 | #endif 64 | if (pt == nullptr) 65 | throw std::runtime_error("Allocation failed in Mallocator, requested size in bytes = " + 66 | std::to_string(n * sizeof(T))); 67 | return static_cast(pt); 68 | } 69 | 70 | void deallocate(T* p, std::size_t) { free(p); } 71 | }; 72 | 73 | template 74 | bool operator==(const Mallocator&, const Mallocator&) 75 | { 76 | return ALIGN1 == ALIGN2; 77 | } 78 | template 79 | bool operator!=(const Mallocator&, const Mallocator&) 80 | { 81 | return ALIGN1 != ALIGN2; 82 | } 83 | } // namespace qmcplusplus 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/Utilities/SIMD/algorithm.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: 8 | // 9 | // File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp. 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | // -*- C++ -*- 12 | /** @file algorithm.hpp 13 | * 14 | * SIMD version of functions in algorithm 15 | */ 16 | #ifndef QMCPLUSPLUS_SIMD_ALGORITHM_HPP 17 | #define QMCPLUSPLUS_SIMD_ALGORITHM_HPP 18 | 19 | namespace qmcplusplus 20 | { 21 | namespace simd 22 | { 23 | template 24 | inline T2 accumulate_n(const T1* restrict in, size_t n, T2 res) 25 | { 26 | #pragma omp simd reduction(+ : res) 27 | for (int i = 0; i < n; ++i) 28 | res += in[i]; 29 | return res; 30 | } 31 | 32 | /** transpose of A(m,n) to B(n,m) 33 | * @param A starting address, A(m,lda) 34 | * @param m number of A rows 35 | * @param lda stride of A's row 36 | * @param B starting address B(n,ldb) 37 | * @param n number of B rows 38 | * @param ldb stride of B's row 39 | * 40 | * Blas-like interface 41 | */ 42 | template 43 | inline void transpose(const T* restrict A, size_t m, size_t lda, TO* restrict B, size_t n, size_t ldb) 44 | { 45 | for (size_t i = 0; i < n; ++i) 46 | for (size_t j = 0; j < m; ++j) 47 | B[i * ldb + j] = A[j * lda + i]; 48 | } 49 | 50 | /** dot product 51 | * @param a starting address of an array of type T 52 | * @param b starting address of an array of type T 53 | * @param n size 54 | * @param res initial value, default=0.0 55 | * @return \f$ res = \sum_i a[i] b[i]\f$ 56 | * 57 | * same as inner_product(a,a+n,b,0.0) 58 | * The arguments of this inline function are different from BLAS::dot 59 | * This is more efficient than BLAS::dot due to the function overhead, 60 | * if a compiler knows how to inline. 61 | */ 62 | template 63 | inline T dot(const T* restrict a, const T* restrict b, int n, T res = T()) 64 | { 65 | for (int i = 0; i < n; i++) 66 | res += a[i] * b[i]; 67 | return res; 68 | } 69 | 70 | template 71 | inline TinyVector dot(const T* a, const TinyVector* b, int n) 72 | { 73 | TinyVector res; 74 | for (int i = 0; i < n; i++) 75 | res += a[i] * b[i]; 76 | return res; 77 | } 78 | 79 | /** copy function using memcpy 80 | * @param target starting address of the target 81 | * @param source starting address of the source 82 | * @param n size of the data to copy 83 | */ 84 | template 85 | inline void copy(T* restrict target, const T* restrict source, size_t n) 86 | { 87 | memcpy(target, source, sizeof(T) * n); 88 | } 89 | 90 | } // namespace simd 91 | } // namespace qmcplusplus 92 | #endif 93 | -------------------------------------------------------------------------------- /src/Utilities/SIMD/allocator.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // 9 | // File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp. 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | // -*- C++ -*- 12 | /** @file allocator.hpp 13 | */ 14 | #ifndef QMCPLUSPLUS_ALLOCATOR_H 15 | #define QMCPLUSPLUS_ALLOCATOR_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include "Utilities/SIMD/Mallocator.hpp" 21 | 22 | namespace qmcplusplus 23 | { 24 | template 25 | using aligned_allocator = Mallocator; 26 | 27 | template 28 | using aligned_vector = std::vector>; 29 | 30 | } // namespace qmcplusplus 31 | 32 | /** return size in T's of allocated aligned memory 33 | */ 34 | template 35 | inline size_t getAlignedSize(size_t n) 36 | { 37 | constexpr size_t ND = ALIGN / sizeof(T); 38 | static_assert(ALIGN % sizeof(T) == 0, "getAlignedSize ALIGN must be a multiple of sizeof(T)"); 39 | return ((n + ND - 1) / ND) * ND; 40 | } 41 | 42 | template 43 | inline size_t getAlignment() 44 | { 45 | static_assert(ALIGN % sizeof(T) == 0, "getAlignedSize ALIGN must be a multiple of sizeof(T)"); 46 | return ALIGN / sizeof(T); 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/Utilities/SIMD/allocator_traits.hpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | // 9 | // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 10 | ////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | 13 | #ifndef QMCPLUSPLUS_ACCESS_TRAITS_H 14 | #define QMCPLUSPLUS_ACCESS_TRAITS_H 15 | 16 | namespace qmcplusplus 17 | { 18 | /** template class defines whether the memory allocated by the allocator is host accessible 19 | */ 20 | template 21 | struct allocator_traits 22 | { 23 | const static bool is_host_accessible = true; 24 | }; 25 | 26 | template 27 | using IsHostSafe = typename std::enable_if::is_host_accessible>::type; 28 | 29 | template 30 | using IsNotHostSafe = typename std::enable_if::is_host_accessible>::type; 31 | 32 | } // namespace qmcplusplus 33 | 34 | #endif // QMCPLUSPLUS_ACCESS_TRAITS_H 35 | -------------------------------------------------------------------------------- /src/Utilities/SpeciesSet.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeongnim Kim, jeongnim.kim@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeremy McMinnis, jmcminis@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Raymond Clay III, j.k.rofling@gmail.com, 13 | // Lawrence Livermore National Laboratory 14 | // Mark A. Berrill, berrillma@ornl.gov, 15 | // Oak Ridge National Laboratory 16 | // 17 | // File created by: 18 | // Jeongnim Kim, jeongnim.kim@gmail.com, 19 | // University of Illinois at Urbana-Champaign 20 | //////////////////////////////////////////////////////////////////////////////// 21 | 22 | #include "Utilities/SpeciesSet.h" 23 | 24 | SpeciesSet::SpeciesSet() 25 | { 26 | TotalNum = 0; 27 | speciesName.reserve(4); 28 | attribName.reserve(4); 29 | } 30 | 31 | SpeciesSet::~SpeciesSet() 32 | { 33 | AttribList_t::iterator it(d_attrib.begin()); 34 | AttribList_t::iterator it_end(d_attrib.end()); 35 | while (it != it_end) 36 | { 37 | delete *it; 38 | ++it; 39 | } 40 | } 41 | 42 | void SpeciesSet::create(unsigned m) 43 | { 44 | if (m > 0) 45 | { 46 | speciesName.insert(speciesName.end(), m, std::string("none")); 47 | AttribList_t::iterator dit = d_attrib.begin(); 48 | for (; dit != d_attrib.end(); ++dit) 49 | (*dit)->insert((*dit)->end(), m, 0); 50 | TotalNum += m; 51 | } 52 | } 53 | 54 | int SpeciesSet::addSpecies(const std::string& aname) 55 | { 56 | int i = findSpecies(aname); // check if the name is registered 57 | if (i == TotalNum) 58 | // if not found, add a new species 59 | { 60 | create(1); 61 | speciesName[i] = aname; 62 | } 63 | return i; // return an index for a species 64 | } 65 | 66 | int SpeciesSet::addAttribute(const std::string& aname) 67 | { 68 | int i = 0; 69 | while (i < attribName.size()) 70 | { 71 | if (attribName[i] == aname) 72 | return i; 73 | i++; 74 | } 75 | attribName.push_back(aname); 76 | int n = d_attrib.size(); 77 | d_attrib.push_back(new SpeciesAttrib_t(TotalNum)); 78 | return n; 79 | } 80 | 81 | int SpeciesSet::getAttribute(const std::string& aname) 82 | { 83 | for (int i = 0; i < attribName.size(); i++) 84 | { 85 | if (attribName[i] == aname) 86 | return i; 87 | } 88 | return attribName.size(); 89 | } 90 | 91 | SpeciesSet::SpeciesSet(const SpeciesSet& species) 92 | : TotalNum(species.TotalNum), speciesName(species.speciesName), attribName(species.attribName) 93 | { 94 | AttribList_t::const_iterator dit(species.d_attrib.begin()); 95 | AttribList_t::const_iterator dit_end(species.d_attrib.end()); 96 | while (dit != dit_end) 97 | { 98 | d_attrib.push_back(new SpeciesAttrib_t(**dit)); 99 | ++dit; 100 | } 101 | } 102 | 103 | SpeciesSet& SpeciesSet::operator=(const SpeciesSet& species) 104 | { 105 | if (this != &species) 106 | { 107 | TotalNum = species.TotalNum; 108 | speciesName = species.speciesName; 109 | attribName = species.attribName; 110 | AttribList_t::iterator it(d_attrib.begin()); 111 | AttribList_t::iterator it_end(d_attrib.end()); 112 | while (it != it_end) 113 | { 114 | delete *it; 115 | ++it; 116 | } 117 | d_attrib.clear(); 118 | AttribList_t::const_iterator dit(species.d_attrib.begin()); 119 | AttribList_t::const_iterator dit_end(species.d_attrib.end()); 120 | while (dit != dit_end) 121 | { 122 | d_attrib.push_back(new SpeciesAttrib_t(**dit)); 123 | ++dit; 124 | } 125 | } 126 | return *this; 127 | } 128 | -------------------------------------------------------------------------------- /src/Utilities/SpeciesSet.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Jeremy McMinnis, jmcminis@gmail.com, 9 | // University of Illinois at Urbana-Champaign 10 | // Jeongnim Kim, jeongnim.kim@gmail.com, 11 | // University of Illinois at Urbana-Champaign 12 | // Raymond Clay III, j.k.rofling@gmail.com, 13 | // Lawrence Livermore National Laboratory 14 | // 15 | // File created by: 16 | // Jeongnim Kim, jeongnim.kim@gmail.com, 17 | // University of Illinois at Urbana-Champaign 18 | //////////////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef OHMMS_SPECIES_SET_H 21 | #define OHMMS_SPECIES_SET_H 22 | 23 | #include 24 | #include 25 | 26 | /*! \class SpeciesSet 27 | * \brief A class containing a set of attributes for a set of species. 28 | */ 29 | class SpeciesSet 30 | { 31 | public: 32 | typedef double Scalar_t; 33 | typedef std::vector SpeciesAttrib_t; 34 | typedef std::vector AttribList_t; 35 | 36 | //! The number of species 37 | unsigned TotalNum; 38 | 39 | //! Species name list 40 | std::vector speciesName; 41 | 42 | //! attribute name list 43 | std::vector attribName; 44 | 45 | //! List of species attributes 46 | AttribList_t d_attrib; 47 | 48 | //! Constructor 49 | SpeciesSet(); 50 | 51 | SpeciesSet(const SpeciesSet& species); 52 | 53 | SpeciesSet& operator=(const SpeciesSet& species); 54 | 55 | //! Destructor 56 | virtual ~SpeciesSet(); 57 | 58 | /// return the number of species 59 | inline int size() const { return TotalNum; } 60 | /// return the number of species 61 | inline int getTotalNum() const { return TotalNum; } 62 | /// set the number of species 63 | inline void setTotalNum(const unsigned n) { TotalNum = n; } 64 | //! return the number of attributes in our list 65 | inline int numAttributes() const { return d_attrib.size(); } 66 | 67 | /** 68 | * @param aname Unique name of the species be added. 69 | * @return the index of the species 70 | * @brief When a name species does not exist, add a new species 71 | */ 72 | int addSpecies(const std::string& aname); 73 | 74 | /** 75 | * @param aname a unique name of an attribute 76 | * @return the index of a new attribute 77 | * @brief for a new attribute, allocate the data 78 | */ 79 | int addAttribute(const std::string& aname); 80 | 81 | /** 82 | * @param aname Unique name of the species to be looked up. 83 | * @return the index of the species 84 | * @brief When a name species does not exist, return attribute.size() 85 | */ 86 | int getAttribute(const std::string& aname); 87 | 88 | /** 89 | * @param i attribute index 90 | * @param j species index 91 | * @return the value of i-th attribute for the j-th species 92 | */ 93 | inline double operator()(int i, int j) const { return d_attrib[i]->operator[](j); } 94 | 95 | /** 96 | * assignment operator 97 | * @param i attribute index 98 | * @param j species index 99 | * @return the value of i-th attribute for the j-th species 100 | */ 101 | inline double& operator()(int i, int j) { return d_attrib[i]->operator[](j); } 102 | 103 | /** 104 | * @param m the number of species to be added 105 | */ 106 | void create(unsigned m); 107 | 108 | /** 109 | * @param name a name of species 110 | * @return an ID for the species with name. 111 | * @brief if the input species is not found, add a new species 112 | */ 113 | inline int findSpecies(const std::string& name) const 114 | { 115 | int i = 0; 116 | while (i < speciesName.size()) 117 | { 118 | if (speciesName[i] == name) 119 | return i; 120 | i++; 121 | } 122 | return i; 123 | } 124 | 125 | inline int findAttribute(const std::string& name) const { return findIndex(name, attribName); } 126 | 127 | inline int findIndex(const std::string& name, const std::vector& alist) const 128 | { 129 | int i = 0; 130 | while (i < alist.size()) 131 | { 132 | if (alist[i] == name) 133 | return i; 134 | i++; 135 | } 136 | return -1; 137 | } 138 | }; 139 | #endif 140 | -------------------------------------------------------------------------------- /src/Utilities/StdRandom.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // 9 | // File created by: Jeongnim Kim, jeongnim.kim@intel.com, Intel Corp. 10 | //////////////////////////////////////////////////////////////////////////////// 11 | 12 | #ifndef QMCPLUSPLUS_CPP11_STDRANDOM_H 13 | #define QMCPLUSPLUS_CPP11_STDRANDOM_H 14 | 15 | #include 16 | #include 17 | #include "Utilities/Configuration.h" 18 | 19 | template 20 | struct StdRandom 21 | { 22 | /// real result type 23 | typedef T result_type; 24 | /// randmon number generator [0,max) where max depends on the generator type 25 | typedef RNG generator_type; 26 | /// unsigned integer type 27 | typedef uint32_t uint_type; // typename generator_type::result_type uint_type; 28 | /// real random generator [0,1) 29 | typedef std::uniform_real_distribution uniform_distribution_type; 30 | /// normal real random generator [0,1) 31 | typedef std::normal_distribution normal_distribution_type; 32 | /// number of contexts 33 | int nContexts; 34 | /// context number 35 | int myContext; 36 | /// offset of the random seed 37 | int baseOffset; 38 | /// random number generator 39 | RNG myRNG; 40 | /// uniform generator 41 | uniform_distribution_type uniform; 42 | /// normal generator 43 | normal_distribution_type normal; 44 | 45 | StdRandom() : nContexts(1), myContext(0), baseOffset(0), uniform(T(0), T(1)), normal(T(0), T(1)) 46 | { 47 | myRNG.seed(MakeSeed(omp_get_thread_num(), omp_get_num_threads())); 48 | } 49 | 50 | explicit StdRandom(uint_type iseed) : nContexts(1), myContext(0), baseOffset(0) 51 | //, uniform(T(0),T(1)), normal(T(0),T(1)) 52 | { 53 | if (iseed == 0) 54 | iseed = MakeSeed(0, 1); 55 | myRNG.seed(iseed); 56 | } 57 | 58 | /** copy constructor 59 | */ 60 | template 61 | StdRandom(const StdRandom& rng) 62 | : nContexts(1), 63 | myContext(0), 64 | baseOffset(0), 65 | myRNG(rng.myRNG), 66 | uniform(T(0), T(1)), 67 | normal(T(0), T(1)) 68 | {} 69 | 70 | /** initialize the stream */ 71 | inline void init(int i, int nstr, int iseed_in, uint_type offset = 1) 72 | { 73 | uint_type baseSeed = iseed_in; 74 | myContext = i; 75 | nContexts = nstr; 76 | if (iseed_in <= 0) 77 | baseSeed = MakeSeed(i, nstr); 78 | baseOffset = offset; 79 | myRNG.seed(baseSeed); 80 | } 81 | 82 | template 83 | inline void reset(const StdRandom& rng) 84 | { 85 | myRNG = rng; // copy the state 86 | } 87 | 88 | /// get baseOffset 89 | inline int offset() const { return baseOffset; } 90 | /// assign baseOffset 91 | inline int& offset() { return baseOffset; } 92 | 93 | /// assign seed 94 | inline void seed(uint_type aseed) { myRNG.seed(aseed); } 95 | 96 | /** return a random number [0,1) 97 | */ 98 | inline result_type rand() { return uniform(myRNG); } 99 | /** return a random number [0,1) 100 | */ 101 | inline result_type operator()() { return uniform(myRNG); } 102 | 103 | /** generate a series of random numbers */ 104 | inline void generate_uniform(T* restrict d, int n) 105 | { 106 | for (int i = 0; i < n; ++i) 107 | d[i] = uniform(myRNG); 108 | } 109 | 110 | inline void generate_normal(T* restrict d, int n) { BoxMuller2::generate(*this, d, n); } 111 | 112 | /** return a random integer 113 | */ 114 | inline uint32_t irand() 115 | { 116 | std::uniform_int_distribution a; 117 | return a(myRNG); 118 | } 119 | }; 120 | #endif 121 | -------------------------------------------------------------------------------- /src/Utilities/XMLWriter.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2018 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Mark Dewing, mdewing@anl.gov, 9 | // Argonne National Laboratory 10 | // 11 | // File created by: 12 | // Mark Dewing, mdewing@anl.gov, 13 | // Argonne National Laboratory 14 | //////////////////////////////////////////////////////////////////////////////// 15 | 16 | /** @file XMLWriter.cpp 17 | * @brief Helper functions for tiny xml2 18 | */ 19 | #include "Utilities/XMLWriter.h" 20 | 21 | namespace qmcplusplus 22 | { 23 | XMLNode* MakeTextElement(XMLDocument& doc, const std::string& name, const std::string& value) 24 | { 25 | XMLNode* name_node = doc.NewElement(name.c_str()); 26 | XMLText* value_node = doc.NewText(""); 27 | value_node->SetValue(value.c_str()); 28 | name_node->InsertEndChild(value_node); 29 | return name_node; 30 | } 31 | } // namespace qmcplusplus 32 | -------------------------------------------------------------------------------- /src/Utilities/XMLWriter.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2018 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Mark Dewing, mdewing@anl.gov, 9 | // Argonne National Laboratory 10 | // 11 | // File created by: 12 | // Mark Dewing, mdewing@anl.gov, 13 | // Argonne National Laboratory 14 | //////////////////////////////////////////////////////////////////////////////// 15 | 16 | /** @file XMLWriter.h 17 | */ 18 | 19 | #ifndef QMCPLUSPLUS_XML_WRITER_H 20 | #define QMCPLUSPLUS_XML_WRITER_H 21 | 22 | #include 23 | #include 24 | 25 | namespace qmcplusplus 26 | { 27 | using tinyxml2::XMLNode; 28 | using tinyxml2::XMLDocument; 29 | using tinyxml2::XMLElement; 30 | using tinyxml2::XMLText; 31 | 32 | 33 | XMLNode* MakeTextElement(XMLDocument& doc, const std::string& name, const std::string& value); 34 | 35 | } // namespace qmcplusplus 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/Utilities/catch_main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | 3 | #include "catch.hpp" 4 | -------------------------------------------------------------------------------- /src/Utilities/qmcpack_version.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 9 | // 10 | // File created by: 11 | // Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include 15 | #include 16 | 17 | #define STR_EXPAND(x) #x 18 | #define STR(x) STR_EXPAND(x) 19 | 20 | // Wrapper around the auto-generated Git repository revision 21 | // information file (git-rev.h) 22 | // If not building from a git repository, the git-rev.h file is empty 23 | #include "git-rev.h" 24 | 25 | #ifdef GIT_BRANCH_RAW 26 | #define QMCPACK_GIT_BRANCH STR(GIT_BRANCH_RAW) 27 | #define QMCPACK_GIT_HASH STR(GIT_HASH_RAW) 28 | #define QMCPACK_GIT_COMMIT_LAST_CHANGED STR(GIT_COMMIT_LAST_CHANGED_RAW) 29 | #define QMCPACK_GIT_COMMIT_SUBJECT GIT_COMMIT_SUBJECT_RAW 30 | #endif 31 | 32 | using std::endl; 33 | using qmcplusplus::app_summary; 34 | 35 | void print_version(bool verbose) 36 | { 37 | #ifdef QMCPACK_GIT_BRANCH 38 | app_summary() << "miniqmc git branch: " << QMCPACK_GIT_BRANCH << endl; 39 | app_summary() << "miniqmc git commit: " << QMCPACK_GIT_HASH << endl; 40 | 41 | if (verbose) 42 | { 43 | app_summary() << "miniqmc git commit date: " << QMCPACK_GIT_COMMIT_LAST_CHANGED << endl; 44 | app_summary() << "miniqmc git commit subject: " << QMCPACK_GIT_COMMIT_SUBJECT << endl; 45 | } 46 | 47 | #else 48 | app_summary() << "miniqmc not built from git repository" << endl; 49 | #endif 50 | app_summary() << endl; 51 | } 52 | -------------------------------------------------------------------------------- /src/Utilities/qmcpack_version.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 9 | // 10 | // File created by: 11 | // Mark Dewing, mdewing@anl.gov, Argonne National Laboratory 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef QMCPACK_VERSION_INCLUDE 15 | #define QMCPACK_VERSION_INCLUDE 16 | 17 | void print_version(bool verbose); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/Utilities/scalar_traits.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source License. 3 | // See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers. 6 | // 7 | // File developed by: Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory 8 | // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign 9 | // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign 10 | // Jaron T. Krogel, krogeljt@ornl.gov, Oak Ridge National Laboratory 11 | // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory 12 | // 13 | // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign 14 | ////////////////////////////////////////////////////////////////////////////////////// 15 | 16 | 17 | #ifndef QMCPLUSPLUS_SCLAR_TRAITS_H 18 | #define QMCPLUSPLUS_SCLAR_TRAITS_H 19 | 20 | #include 21 | 22 | namespace qmcplusplus 23 | { 24 | 25 | template 26 | struct scalar_traits 27 | { 28 | enum 29 | { 30 | DIM = 1 31 | }; 32 | typedef T real_type; 33 | typedef T value_type; 34 | }; 35 | 36 | template 37 | struct scalar_traits> 38 | { 39 | enum 40 | { 41 | DIM = 2 42 | }; 43 | typedef T real_type; 44 | typedef std::complex value_type; 45 | }; 46 | 47 | } // namespace qmcplusplus 48 | #endif 49 | -------------------------------------------------------------------------------- /src/Utilities/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #////////////////////////////////////////////////////////////////////////////////////// 2 | #// This file is distributed under the University of Illinois/NCSA Open Source License. 3 | #// See LICENSE file in top directory for details. 4 | #// 5 | #// Copyright (c) 2020 QMCPACK developers. 6 | #// 7 | #// File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory 8 | #// 9 | #// File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign 10 | #////////////////////////////////////////////////////////////////////////////////////// 11 | 12 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QMCPACK_UNIT_TEST_DIR}) 13 | 14 | SET(SRC_DIR utilities) 15 | SET(UTEST_EXE test_${SRC_DIR}) 16 | SET(UTEST_NAME unit_test_${SRC_DIR}) 17 | 18 | ADD_EXECUTABLE(${UTEST_EXE} test_PrimeNumberSet.cpp test_ParallelBlock.cpp) 19 | TARGET_LINK_LIBRARIES(${UTEST_EXE} catch_main qmcutil ${QMC_UTIL_LIBS}) 20 | 21 | ADD_UNIT_TEST(${UTEST_NAME} "${QMCPACK_UNIT_TEST_DIR}/${UTEST_EXE}") 22 | -------------------------------------------------------------------------------- /src/Utilities/tests/test_ParallelBlock.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 9 | // 10 | // File created by: 11 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include 15 | #include 16 | #include "catch.hpp" 17 | #include "Utilities/ParallelBlock.hpp" 18 | 19 | /** @file 20 | * 21 | * We assume omp and std threading are always available. 22 | * Boost::HANA would simplify this... 23 | * i.e. one test could be written for all the implementations 24 | */ 25 | 26 | namespace qmcplusplus 27 | { 28 | 29 | 30 | template 31 | struct testTaskBarrier 32 | { 33 | static void test(const int ip, 34 | ParallelBlockBarrier& barrier, 35 | std::atomic& counter) 36 | { 37 | counter.fetch_add(1); 38 | } 39 | }; 40 | 41 | template 42 | struct testTask 43 | { 44 | static void test(const int ip, 45 | std::atomic& counter) 46 | { 47 | counter.fetch_add(1); 48 | } 49 | }; 50 | 51 | 52 | TEST_CASE("ParallelBlock OPENMP with Block Barrier", "[Utilities]") { 53 | int threads = 8; 54 | constexpr ParallelBlockThreading DT = ParallelBlockThreading::OPENMP; 55 | ParallelBlock
par_block(threads); 56 | ParallelBlockBarrier
barrier(threads); 57 | std::atomic counter; 58 | counter = 0; 59 | par_block(testTaskBarrier
::test, barrier, counter); 60 | REQUIRE(counter == 8); 61 | } 62 | 63 | TEST_CASE("ParallelBlock OPENMP", "[Utilities]") { 64 | int threads = 8; 65 | constexpr ParallelBlockThreading DT = ParallelBlockThreading::OPENMP; 66 | ParallelBlock
par_block(threads); 67 | std::atomic counter; 68 | counter = 0; 69 | par_block(testTask
::test, counter); 70 | REQUIRE(counter == 8); 71 | } 72 | 73 | TEST_CASE("ParallelBlock std::thread", "[Utilities]") { 74 | int threads = 8; 75 | constexpr ParallelBlockThreading DTS = ParallelBlockThreading::STD; 76 | ParallelBlock par_block(threads); 77 | std::atomic counter; 78 | counter = 0; 79 | par_block(testTask::test, std::ref(counter)); 80 | REQUIRE(counter == 8); 81 | } 82 | 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/Utilities/tests/test_PrimeNumberSet.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // This file is distributed under the University of Illinois/NCSA Open Source 3 | // License. See LICENSE file in top directory for details. 4 | // 5 | // Copyright (c) 2019 QMCPACK developers. 6 | // 7 | // File developed by: 8 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 9 | // 10 | // File created by: 11 | // Peter Doak, doakpw@ornl.gov, Oak Ridge National Lab 12 | //////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include "catch.hpp" 15 | #include "Utilities/PrimeNumberSet.h" 16 | 17 | TEST_CASE("PrimeNumberSet Basic", "[Utilities]") { 18 | PrimeNumberSet myPrimes; 19 | REQUIRE(myPrimes[0] == 3); 20 | REQUIRE(myPrimes[1] == 5); 21 | REQUIRE(myPrimes[7] == 23); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/Utilities/tinyxml/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | DisableFormat: true 4 | ... 5 | 6 | -------------------------------------------------------------------------------- /src/config.h.cmake.in: -------------------------------------------------------------------------------- 1 | /* src/ohmms-config.h.in. Generated from configure.in by autoheader. */ 2 | // -*- c++ -*- 3 | // 4 | //Ohmms Configuration Header. Automatically Generated 5 | // 6 | //See the LICENSE file in the top-level directory for copyright notices 7 | // 8 | #ifndef QMCPLUSPLUS_CONFIGURATION_H 9 | #define QMCPLUSPLUS_CONFIGURATION_H 10 | 11 | // clang-format off 12 | 13 | /* define the major version */ 14 | #define QMCPACK_VERSION_MAJOR @QMCPACK_VERSION_MAJOR@ 15 | 16 | /* define the minor version */ 17 | #define QMCPACK_VERSION_MINOR @QMCPACK_VERSION_MINOR@ 18 | 19 | /* define the patch version */ 20 | #define QMCPACK_VERSION_PATCH @QMCPACK_VERSION_PATCH@ 21 | 22 | /* define the release version */ 23 | #cmakedefine QMCPACK_RELEASE @QMCAPCK_RELEASE@ 24 | 25 | /* define the git last commit date */ 26 | // #cmakedefine QMCPLUSPLUS_LAST_CHANGED_DATE "@QMCPLUSPLUS_LAST_CHANGED_DATE@" 27 | 28 | /* Enable OpenMP parallelization. */ 29 | #cmakedefine ENABLE_OPENMP @ENABLE_OPENMP@ 30 | 31 | /* Define to 1 if you have the `hdf5' library (-lhdf5). */ 32 | #cmakedefine HAVE_LIBHDF5 @HAVE_LIBHDF5@ 33 | 34 | /* Define to 1 if you want to use parallel hdf5 for frequent output */ 35 | #cmakedefine ENABLE_PHDF5 @ENABLE_PHDF5@ 36 | 37 | /* Define to 1 if you have MPI library */ 38 | #cmakedefine HAVE_MPI @HAVE_MPI@ 39 | 40 | /* Define the physical dimension of appliation. */ 41 | #cmakedefine OHMMS_DIM @OHMMS_DIM@ 42 | 43 | /* Define the index type: int, long */ 44 | #cmakedefine OHMMS_INDEXTYPE @OHMMS_INDEXTYPE@ 45 | 46 | /* Define the base precision: float, double */ 47 | #cmakedefine OHMMS_PRECISION @OHMMS_PRECISION@ 48 | 49 | /* Define the full precision: double, long double */ 50 | #cmakedefine OHMMS_PRECISION_FULL @OHMMS_PRECISION_FULL@ 51 | 52 | /* Define to 1 if precision is mixed, only for the CPU code */ 53 | #cmakedefine MIXED_PRECISION @MIXED_PRECISION@ 54 | 55 | /* Define to 1 if complex wavefunctions are used */ 56 | #cmakedefine QMC_COMPLEX @QMC_COMPLEX@ 57 | 58 | /* Define if the code is specialized for orthorhombic supercell */ 59 | #define OHMMS_ORTHO @OHMMS_ORTHO@ 60 | 61 | /* Define if sincos function exists */ 62 | #cmakedefine HAVE_SINCOS @HAVE_SINCOS@ 63 | 64 | /* Define if posix_memalign function exists */ 65 | #cmakedefine HAVE_POSIX_MEMALIGN @HAVE_POSIX_MEMALIGN@ 66 | 67 | /* Find essl library */ 68 | #cmakedefine HAVE_ESSL @HAVE_ESSL@ 69 | 70 | /* Fund acml library */ 71 | #cmakedefine HAVE_ACML @HAVE_ACML@ 72 | 73 | /* For AFQMC compilation */ 74 | #cmakedefine BUILD_AFQMC @BUILD_AFQMC@ 75 | 76 | /* For FCIQMC compilation */ 77 | #cmakedefine BUILD_FCIQMC @BUILD_FCIQMC@ 78 | 79 | #if defined(__INTEL_COMPILER) 80 | #if defined(__AVX512F__) 81 | #define QMC_CLINE 64 82 | #define QMC_ALIGNAS alignas(64) 83 | #define ASSUME_ALIGNED(x) __assume_aligned(x,64) 84 | #else 85 | #define QMC_CLINE 32 86 | #define QMC_ALIGNAS alignas(32) 87 | #define ASSUME_ALIGNED(x) __assume_aligned(x,32) 88 | #endif 89 | #elif defined(__GNUC__) && !defined(__ibmxl__) 90 | #if defined(__AVX512F__) 91 | #define QMC_CLINE 64 92 | #define QMC_ALIGNAS alignas(64) 93 | #define ASSUME_ALIGNED(x) (x) = (__typeof__(x)) __builtin_assume_aligned(x,64) 94 | #else 95 | #define QMC_CLINE 32 96 | #define QMC_ALIGNAS alignas(32) 97 | #define ASSUME_ALIGNED(x) (x) = (__typeof__(x)) __builtin_assume_aligned(x,32) 98 | #endif 99 | #else 100 | #define QMC_CLINE 32 101 | #define QMC_ALIGNAS alignas(32) 102 | #define ASSUME_ALIGNED(x) 103 | #endif 104 | 105 | /* Internal timers */ 106 | #cmakedefine ENABLE_TIMERS @ENABLE_TIMERS@ 107 | 108 | /* Use VTune Task API with timers */ 109 | #cmakedefine USE_VTUNE_TASKS @USE_VTUNE_TASKS@ 110 | 111 | // clang-format on 112 | 113 | #endif // QMCPLUSPLUS_CONFIGURATION_H 114 | 115 | -------------------------------------------------------------------------------- /testing/miniqmc_openshift_rhea.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | BUILD_DIR=$(pwd) 4 | echo $BUILD_DIR 5 | 6 | cat > $BUILD_TAG.pbs << EOF 7 | #PBS -A MAT151ci 8 | #PBS -N $BUILD_TAG 9 | #PBS -j oe 10 | #PBS -l walltime=1:00:00,nodes=1 11 | #PBS -d $BUILD_DIR 12 | #PBS -l partition=rhea 13 | 14 | cd $BUILD_DIR 15 | 16 | source /sw/rhea/lmod/7.8.2/rhel7.5_4.8.5/lmod/7.8.2/init/bash 17 | 18 | module unload intel 19 | module load gcc/6.2.0 20 | module load openblas/0.3.5 21 | module load git/2.18.0 22 | module load cmake/3.13.4 23 | 24 | export OMP_NUM_THREADS=4 25 | 26 | env 27 | 28 | module list 29 | 30 | echo "" 31 | echo "" 32 | echo "starting new test for real full precision" 33 | echo "" 34 | echo "" 35 | 36 | cd build 37 | 38 | cmake -DCMAKE_CXX_COMPILER="mpicxx" .. 39 | 40 | make 41 | 42 | echo 43 | echo checking J1 full precision 44 | echo ---------------------------------------------------- 45 | echo 46 | 47 | ./bin/check_wfc -f J1 48 | 49 | echo 50 | echo checking J2 full precision 51 | echo ---------------------------------------------------- 52 | echo 53 | 54 | ./bin/check_wfc -f J2 55 | 56 | echo 57 | echo checking J3 full precision 58 | echo ---------------------------------------------------- 59 | echo 60 | 61 | ./bin/check_wfc -f J3 62 | 63 | echo 64 | echo checking Spline SPO full precision 65 | echo ---------------------------------------------------- 66 | echo 67 | 68 | ./bin/check_spo 69 | 70 | echo 71 | echo checking Determinant update full precision 72 | echo ---------------------------------------------------- 73 | echo 74 | 75 | ./bin/check_wfc -f Det 76 | 77 | echo "" 78 | echo "" 79 | echo "starting new test for real mixed precision" 80 | echo "" 81 | echo "" 82 | 83 | ctest -L unit --output-on-failure 84 | 85 | cd ../ 86 | rm -rf ./build 87 | mkdir -p build 88 | cd build 89 | 90 | cmake -DQMC_MIXED_PRECISION=1 -DCMAKE_CXX_COMPILER="mpicxx" .. 91 | 92 | make 93 | 94 | echo 95 | echo checking J1 mixed precision 96 | echo ---------------------------------------------------- 97 | echo 98 | 99 | ./bin/check_wfc -f J1 100 | 101 | echo 102 | echo checking J2 mixed precision 103 | echo ---------------------------------------------------- 104 | echo 105 | 106 | ./bin/check_wfc -f J2 107 | 108 | echo 109 | echo checking J3 mixed precision 110 | echo ---------------------------------------------------- 111 | echo 112 | 113 | ./bin/check_wfc -f J3 114 | 115 | echo 116 | echo checking Spline SPO mixed precision 117 | echo ---------------------------------------------------- 118 | echo 119 | 120 | ./bin/check_spo 121 | 122 | echo 123 | echo checking Determinant update mixed precision 124 | echo ---------------------------------------------------- 125 | echo 126 | 127 | # YL: commented out mixed precision check. Too unstable 128 | #./bin/check_wfc -f Det 129 | 130 | ctest -L unit --output-on-failure 131 | 132 | cd ../ 133 | EOF 134 | 135 | /home/mat151ci_auser/blocking_qsub $BUILD_DIR $BUILD_TAG.pbs 136 | 137 | cp $BUILD_DIR/$BUILD_TAG.o* ../ 138 | 139 | # get status from all checks 140 | 141 | CHECK_XXX_FAILED=0 142 | 143 | if [ $(grep -e 'All checks passed for J[123]' -e 'All checks passed for spo' -e 'All checks passed for Det' ../$BUILD_TAG.o* | wc -l) -ne 9 ] 144 | then 145 | echo; echo 146 | echo One or more build variants failed in check_XXX. Check the build log for details. 147 | echo; echo 148 | CHECK_XXX_FAILED=1 149 | fi 150 | 151 | UNIT_TESTS_FAILED=0 152 | 153 | if [ $(grep '100% tests passed, 0 tests failed out of [0-9]*' ../$BUILD_TAG.o* | wc -l) -ne 2 ] 154 | then 155 | echo; echo 156 | echo One or more build variants failed in unit tests. Check the build log for details. 157 | echo; echo 158 | UNIT_TESTS_FAILED=1 159 | fi 160 | 161 | [ $CHECK_XXX_FAILED -eq 0 -a $UNIT_TESTS_FAILED -eq 0 ] 162 | -------------------------------------------------------------------------------- /testing/nightly_scripts/nightly_anl_bora.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Setup for bora.alcf.anl.gov 4 | # 5 | # Run the nightlies 6 | # 7 | 8 | source /etc/profile.d/z00_lmod.sh 9 | if [ -d /scratch/packages/modulefiles ]; then 10 | module use /scratch/packages/modulefiles 11 | fi 12 | 13 | module purge 14 | module load cmake intel/18.3 intel-mkl llvm/dev-latest 15 | 16 | export TEST_SITE_NAME=bora.alcf.anl.gov 17 | export N_PROCS_BUILD=24 18 | export N_PROCS=32 19 | 20 | # run on the 1st socket 21 | NUMA_ID=0 22 | 23 | #Must be an absolute path 24 | place=/scratch/MINIQMC_CI_BUILDS_DO_NOT_REMOVE 25 | 26 | if [ ! -e $place ]; then 27 | mkdir $place 28 | fi 29 | 30 | if [ -e $place ]; then 31 | cd $place 32 | 33 | echo --- Hostname --- $HOSTNAME 34 | echo --- Checkout for $sys `date` 35 | 36 | branch=OMP_offload 37 | entry=miniqmc-${branch} 38 | 39 | if [ ! -e $entry ]; then 40 | echo --- Cloning miniQMC git `date` 41 | git clone https://github.com/QMCPACK/miniqmc.git $entry 42 | else 43 | echo --- Updating local miniQMC git `date` 44 | cd $entry 45 | git pull 46 | cd .. 47 | fi 48 | 49 | if [ -e $entry/CMakeLists.txt ]; then 50 | cd $entry 51 | 52 | git checkout $branch 53 | 54 | for sys in Clang-Real Clang-Real-Mixed Clang-Offload-Real Clang-Offload-Real-Mixed Intel-Real Intel-Real-Mixed Clang-Nightly-Offload-Real 55 | do 56 | 57 | folder=build_$sys 58 | 59 | if [ -e $folder ]; then 60 | rm -r $folder 61 | fi 62 | mkdir $folder 63 | cd $folder 64 | 65 | echo --- Building for $sys `date` 66 | 67 | # create log file folder if not exist 68 | mydate=`date +%y_%m_%d` 69 | if [ ! -e $place/log/$entry/$mydate ]; 70 | then 71 | mkdir -p $place/log/$entry/$mydate 72 | fi 73 | 74 | if [[ $sys == *"Intel"* ]]; then 75 | module load llvm/dev-latest 76 | CTEST_FLAGS="-DCMAKE_CXX_COMPILER=icpc;-DCMAKE_CXX_FLAGS=-xCOMMON-AVX512" 77 | elif [[ $sys == *"Clang"* ]]; then 78 | if [[ $sys == *"Nightly"* ]]; then 79 | module load llvm/dev-latest 80 | else 81 | module load llvm/master-nightly 82 | fi 83 | CTEST_FLAGS="-DCMAKE_CXX_COMPILER=clang++" 84 | fi 85 | 86 | if [[ $sys == *"Offload"* ]]; then 87 | CTEST_FLAGS="$CTEST_FLAGS;-DENABLE_OFFLOAD=1;-DUSE_OBJECT_TARGET=ON" 88 | fi 89 | 90 | if [[ $sys == *"Complex"* ]]; then 91 | CTEST_FLAGS="$CTEST_FLAGS;-DQMC_COMPLEX=1" 92 | fi 93 | 94 | if [[ $sys == *"-Mixed"* ]]; then 95 | CTEST_FLAGS="$CTEST_FLAGS;-DQMC_MIXED_PRECISION=1" 96 | fi 97 | 98 | export MINIQMC_TEST_SUBMIT_NAME=${sys}-Release 99 | 100 | numactl -N $NUMA_ID \ 101 | ctest -DCMAKE_CONFIGURE_OPTIONS=$CTEST_FLAGS -S $PWD/../CMake/ctest_script.cmake -VV --timeout 800 &> $place/log/$entry/$mydate/${MINIQMC_TEST_SUBMIT_NAME}.log 102 | 103 | cd .. 104 | echo --- Finished $sys `date` 105 | done 106 | 107 | else 108 | echo "ERROR: No CMakeLists. Bad git clone." 109 | exit 1 110 | fi 111 | 112 | else 113 | echo "ERROR: No directory $place" 114 | exit 1 115 | fi 116 | --------------------------------------------------------------------------------