mirror of https://github.com/QMCPACK/qmcpack.git
Remove ENABLE_OPENMP in favor of QMC_OMP
CMake configuration files Source code pre-processor
This commit is contained in:
parent
0b9f67b6fb
commit
8e55b9a442
|
@ -12,7 +12,6 @@ endif()
|
|||
|
||||
# Enable OpenMP
|
||||
if(QMC_OMP)
|
||||
set(ENABLE_OPENMP 1)
|
||||
if(ENABLE_OFFLOAD)
|
||||
if (QMC_CUDA2HIP)
|
||||
set(OFFLOAD_TARGET_DEFAULT "amdgcn-amd-amdhsa")
|
||||
|
|
|
@ -5,7 +5,6 @@ endif()
|
|||
|
||||
# Enable OpenMP
|
||||
if(QMC_OMP)
|
||||
set(ENABLE_OPENMP 1)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
|
||||
if(ENABLE_OFFLOAD)
|
||||
|
|
|
@ -23,7 +23,6 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le")
|
|||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3")
|
||||
|
||||
if(QMC_OMP)
|
||||
set(ENABLE_OPENMP 1)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qsmp=omp")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qsmp=omp")
|
||||
if(ENABLE_OFFLOAD)
|
||||
|
|
|
@ -17,7 +17,6 @@ endif()
|
|||
|
||||
# Enable OpenMP
|
||||
if(QMC_OMP)
|
||||
set(ENABLE_OPENMP 1)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM" OR INTEL_ONEAPI_COMPILER_FOUND)
|
||||
if(ENABLE_OFFLOAD)
|
||||
set(OFFLOAD_TARGET
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
# Specifying 'allcores' will run on all cores if OMP_NUM_THREADS is not set (which seems
|
||||
# to be the default for other OpenMP implementations)
|
||||
if(QMC_OMP)
|
||||
set(ENABLE_OPENMP 1)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mp=allcores")
|
||||
if(ENABLE_OFFLOAD)
|
||||
message(WARNING "QMCPACK OpenMP offload is not ready for NVIDIA HPC compiler.")
|
||||
|
|
|
@ -227,7 +227,6 @@ if(CMAKE_TOOLCHAIN_FILE)
|
|||
message(STATUS "Using ${CMAKE_TOOLCHAIN_FILE} toolchain ")
|
||||
else(CMAKE_TOOLCHAIN_FILE)
|
||||
message(STATUS "Trying to figure out compiler options ....")
|
||||
set(ENABLE_OPENMP 0)
|
||||
|
||||
#------------------------
|
||||
# On Cray's machine
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
/* src/ohmms-config.h.in. Generated from configure.in by autoheader. */
|
||||
// -*- c++ -*-
|
||||
//
|
||||
//Ohmms Configuration Header. Automatically Generated
|
||||
// Ohmms Configuration Header. Automatically Generated
|
||||
//
|
||||
//See the LICENSE file in the top-level directory for copyright notices
|
||||
// See the LICENSE file in the top-level directory for copyright notices
|
||||
//
|
||||
#ifndef QMCPLUSPLUS_CONFIGURATION_H
|
||||
#define QMCPLUSPLUS_CONFIGURATION_H
|
||||
|
||||
/* define the major version */
|
||||
#define QMCPLUSPLUS_VERSION_MAJOR 0
|
||||
#define QMCPLUSPLUS_VERSION_MAJOR 0
|
||||
|
||||
/* define the minor version */
|
||||
#define QMCPLUSPLUS_VERSION_MINOR 6
|
||||
#define QMCPLUSPLUS_VERSION_MINOR 6
|
||||
|
||||
/* define the patch version */
|
||||
#define QMCPLUSPLUS_VERSION_PATCH 1
|
||||
#define QMCPLUSPLUS_VERSION_PATCH 1
|
||||
|
||||
/* define the release version */
|
||||
/* #undef QMCPLUSPLUS_RELEASE */
|
||||
|
@ -24,16 +24,17 @@
|
|||
/* #undef QMCPLUSPLUS_LINEARSCALE */
|
||||
|
||||
/* define the subversion branch */
|
||||
#define QMCPLUSPLUS_BRANCH 5487
|
||||
#define QMCPLUSPLUS_BRANCH 5487
|
||||
|
||||
/* define the subversion last changed date */
|
||||
#define QMCPLUSPLUS_LAST_CHANGED_DATE "2012-04-22 10:24:14 -0400 (Sun, 22 Apr 2012)"
|
||||
#define QMCPLUSPLUS_LAST_CHANGED_DATE \
|
||||
"2012-04-22 10:24:14 -0400 (Sun, 22 Apr 2012)"
|
||||
|
||||
/* define PRINT_DEBUG */
|
||||
/* #undef PRINT_DEBUG */
|
||||
|
||||
/* Enable OpenMP parallelization. */
|
||||
#define ENABLE_OPENMP 1
|
||||
#define QMC_OMP 1
|
||||
|
||||
/* Define to 1 if you have the `hdf5' library (-lhdf5). */
|
||||
#define HAVE_LIBHDF5 1
|
||||
|
@ -165,4 +166,3 @@
|
|||
/* #undef DEBUG_PSIBUFFER_ON */
|
||||
|
||||
#endif // QMCPLUSPLUS_CONFIGURATION_H
|
||||
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
* @brief Abstraction of information on executor environments
|
||||
*/
|
||||
|
||||
#ifdef QMC_OMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#ifdef QMC_EXP_THREADING
|
||||
#include <thread>
|
||||
#endif
|
||||
|
@ -42,7 +45,11 @@ unsigned int maxCapacity();
|
|||
template<>
|
||||
inline unsigned int maxCapacity<Executor::OPENMP>()
|
||||
{
|
||||
#ifdef QMC_OMP
|
||||
return omp_get_max_threads();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<Executor TT = Executor::OPENMP>
|
||||
|
@ -51,10 +58,13 @@ unsigned int getWorkerId();
|
|||
template<>
|
||||
inline unsigned int getWorkerId<Executor::OPENMP>()
|
||||
{
|
||||
#ifdef QMC_OMP
|
||||
return omp_get_thread_num();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef QMC_EXP_THREADING
|
||||
template<>
|
||||
inline unsigned int maxCapacity<Executor::STD_THREADS>()
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <omp.h>
|
||||
|
||||
#include "Concurrency/ParallelExecutor.hpp"
|
||||
#include "Platforms/Host/OutputManager.h"
|
||||
#include "Message/OpenMP.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
* @brief utility functions for executors
|
||||
*/
|
||||
|
||||
#include <omp.h>
|
||||
#include "Concurrency/Info.hpp"
|
||||
#include "Message/OpenMP.h"
|
||||
|
||||
namespace qmcplusplus
|
||||
{
|
||||
namespace Concurrency
|
||||
{
|
||||
|
||||
template<Executor TT = Executor::OPENMP>
|
||||
class OverrideMaxCapacity;
|
||||
|
||||
|
@ -33,17 +32,15 @@ class OverrideMaxCapacity<Executor::OPENMP>
|
|||
{
|
||||
private:
|
||||
int original_max_threads_;
|
||||
|
||||
public:
|
||||
OverrideMaxCapacity(int max_threads)
|
||||
{
|
||||
original_max_threads_ = omp_get_max_threads();
|
||||
omp_set_num_threads(max_threads);
|
||||
}
|
||||
|
||||
~OverrideMaxCapacity()
|
||||
{
|
||||
omp_set_num_threads(original_max_threads_);
|
||||
}
|
||||
|
||||
~OverrideMaxCapacity() { omp_set_num_threads(original_max_threads_); }
|
||||
};
|
||||
|
||||
template<Executor TT>
|
||||
|
@ -52,7 +49,7 @@ class OverrideMaxCapacity
|
|||
OverrideMaxCapacity(int max_threads) {}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace Concurrency
|
||||
} // namespace qmcplusplus
|
||||
|
||||
#endif
|
||||
|
|
|
@ -57,8 +57,10 @@ TEST_CASE("ParallelExecutor<OPENMP> nested case", "[concurrency]")
|
|||
ParallelExecutor<Executor::OPENMP> test_block2;
|
||||
test_block2(num_threads, TestTaskOMP, std::ref(my_count));
|
||||
};
|
||||
#ifdef QMC_OMP
|
||||
REQUIRE_THROWS_WITH(test_block(num_threads, nested_tasks, std::ref(count)),
|
||||
Catch::Contains("ParallelExecutor should not be used for nested openmp threading"));
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace qmcplusplus
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_OPENMP)
|
||||
#if defined(QMC_OMP)
|
||||
#include <omp.h>
|
||||
#else
|
||||
#include "formic/utils/openmp.h"
|
||||
|
||||
typedef int omp_int_t;
|
||||
inline omp_int_t omp_get_thread_num() { return 0; }
|
||||
inline omp_int_t omp_get_max_threads() { return 1; }
|
||||
inline omp_int_t omp_get_num_threads() { return 1; }
|
||||
inline omp_int_t omp_get_level() { return 0; }
|
||||
inline omp_int_t omp_get_ancestor_thread_num(int level) { return 0; }
|
||||
inline void omp_set_num_threads(int num_threads) {}
|
||||
#endif
|
||||
|
||||
/// get the number of threads at the next parallel level
|
||||
|
|
|
@ -273,7 +273,7 @@ void output_hardware_info(Communicate* comm, Libxml2Document& doc, xmlNodePtr ro
|
|||
doc.addChild(hardware, "mpi", using_mpi);
|
||||
|
||||
bool using_openmp = false;
|
||||
#ifdef ENABLE_OPENMP
|
||||
#ifdef QMC_OMP
|
||||
using_openmp = true;
|
||||
doc.addChild(hardware, "openmp_threads", omp_get_max_threads());
|
||||
#endif
|
||||
|
|
|
@ -319,7 +319,7 @@ bool QMCFixedSampleLinearOptimize::run()
|
|||
app_log() << " Using XS:" << XS << " " << failedTries << " " << stability << std::endl;
|
||||
eigenvalue_timer_.start();
|
||||
getLowestEigenvector(Right, currentParameterDirections);
|
||||
Lambda = getNonLinearRescale(currentParameterDirections, S);
|
||||
Lambda = getNonLinearRescale(currentParameterDirections, S);
|
||||
eigenvalue_timer_.stop();
|
||||
// biggest gradient in the parameter direction vector
|
||||
RealType bigVec(0);
|
||||
|
@ -515,10 +515,10 @@ bool QMCFixedSampleLinearOptimize::processOptXML(xmlNodePtr opt_xml,
|
|||
{
|
||||
m_param.put(opt_xml);
|
||||
targetExcitedStr = lowerCase(targetExcitedStr);
|
||||
targetExcited = (targetExcitedStr == "yes");
|
||||
targetExcited = (targetExcitedStr == "yes");
|
||||
|
||||
block_lmStr = lowerCase(block_lmStr);
|
||||
block_lm = (block_lmStr == "yes");
|
||||
block_lm = (block_lmStr == "yes");
|
||||
|
||||
auto iter = OptimizerNames.find(MinMethod);
|
||||
if (iter == OptimizerNames.end())
|
||||
|
@ -545,7 +545,7 @@ bool QMCFixedSampleLinearOptimize::processOptXML(xmlNodePtr opt_xml,
|
|||
current_optimizer_type_ != OptimizerType::DESCENT)
|
||||
myComm->barrier_and_abort("targetExcited = \"yes\" requires that MinMethod = \"adaptive or descent");
|
||||
|
||||
#ifdef ENABLE_OPENMP
|
||||
#ifdef QMC_OMP
|
||||
if (current_optimizer_type_ == OptimizerType::ADAPTIVE && (omp_get_max_threads() > 1))
|
||||
{
|
||||
// throw std::runtime_error("OpenMP threading not enabled with AdaptiveThreeShift optimizer. Use MPI for parallelism instead, and set OMP_NUM_THREADS to 1.");
|
||||
|
|
|
@ -662,10 +662,10 @@ bool QMCFixedSampleLinearOptimizeBatched::processOptXML(xmlNodePtr opt_xml,
|
|||
{
|
||||
m_param.put(opt_xml);
|
||||
targetExcitedStr = lowerCase(targetExcitedStr);
|
||||
targetExcited = (targetExcitedStr == "yes");
|
||||
targetExcited = (targetExcitedStr == "yes");
|
||||
|
||||
block_lmStr = lowerCase(block_lmStr);
|
||||
block_lm = (block_lmStr == "yes");
|
||||
block_lm = (block_lmStr == "yes");
|
||||
|
||||
auto iter = OptimizerNames.find(MinMethod);
|
||||
if (iter == OptimizerNames.end())
|
||||
|
@ -680,7 +680,7 @@ bool QMCFixedSampleLinearOptimizeBatched::processOptXML(xmlNodePtr opt_xml,
|
|||
if (targetExcited && current_optimizer_type_ != OptimizerType::ADAPTIVE)
|
||||
APP_ABORT("targetExcited = \"yes\" requires that MinMethod = \"adaptive");
|
||||
|
||||
#ifdef ENABLE_OPENMP
|
||||
#ifdef QMC_OMP
|
||||
if (current_optimizer_type_ == OptimizerType::ADAPTIVE && (omp_get_max_threads() > 1))
|
||||
{
|
||||
// throw std::runtime_error("OpenMP threading not enabled with AdaptiveThreeShift optimizer. Use MPI for parallelism instead, and set OMP_NUM_THREADS to 1.");
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
#include "Particle/HDFWalkerIO.h"
|
||||
#include "OhmmsData/AttributeSet.h"
|
||||
#include "Message/CommOperators.h"
|
||||
//#if defined(ENABLE_OPENMP)
|
||||
|
||||
#include "QMCDrivers/VMC/VMC.h"
|
||||
#include "QMCDrivers/WFOpt/QMCCostFunction.h"
|
||||
//#endif
|
||||
|
||||
//#include "QMCDrivers/VMC/VMCSingle.h"
|
||||
//#include "QMCDrivers/QMCCostFunctionSingle.h"
|
||||
#include "QMCHamiltonians/HamiltonianPool.h"
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
/** Since we check the DMC only feature of reserve walkers perhaps this should be
|
||||
* a DMC integration test.
|
||||
*/
|
||||
#ifdef QMC_OMP
|
||||
TEST_CASE("DMCDriver+QMCDriverNew integration", "[drivers]")
|
||||
{
|
||||
using namespace testing;
|
||||
|
@ -95,6 +96,6 @@ TEST_CASE("DMCDriver+QMCDriverNew integration", "[drivers]")
|
|||
CHECK(reserved_walkers == 10);
|
||||
// What else should we expect after process
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace qmcplusplus
|
||||
|
|
|
@ -73,9 +73,11 @@ TEST_CASE("QMCDriverNew tiny case", "[drivers]")
|
|||
// What else should we expect after process
|
||||
}
|
||||
|
||||
#ifdef QMC_OMP
|
||||
TEST_CASE("QMCDriverNew more crowds than threads", "[drivers]")
|
||||
{
|
||||
using namespace testing;
|
||||
|
||||
Concurrency::OverrideMaxCapacity<> override(8);
|
||||
Communicate* comm;
|
||||
comm = OHMMS::Controller;
|
||||
|
@ -160,5 +162,6 @@ TEST_CASE("QMCDriverNew walker counts", "[drivers]")
|
|||
|
||||
qmc_batched.testAdjustGlobalWalkerCount();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace qmcplusplus
|
||||
|
|
|
@ -31,9 +31,11 @@ target_link_libraries(qmc-extract-eshdf-kvectors PUBLIC qmcio)
|
|||
|
||||
add_executable(qmc-get-supercell getSupercell.cpp)
|
||||
|
||||
add_executable(qmc-check-affinity check-affinity.cpp)
|
||||
if(HAVE_MPI)
|
||||
target_link_libraries(qmc-check-affinity MPI::MPI_CXX)
|
||||
if(QMC_OMP)
|
||||
add_executable(qmc-check-affinity check-affinity.cpp)
|
||||
if(HAVE_MPI)
|
||||
target_link_libraries(qmc-check-affinity MPI::MPI_CXX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(convertpw4qmc convertpw4qmc.cpp XmlRep.cpp WriteEshdf.cpp)
|
||||
|
@ -51,9 +53,15 @@ if(USE_OBJECT_TARGET)
|
|||
target_link_libraries(qmcfinitesize qmcparticle qmcutil)
|
||||
endif()
|
||||
|
||||
install(TARGETS convert4qmc qmc-extract-eshdf-kvectors qmc-get-supercell qmc-check-affinity convertpw4qmc qmcfinitesize
|
||||
install(TARGETS convert4qmc qmc-extract-eshdf-kvectors qmc-get-supercell convertpw4qmc qmcfinitesize
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
if(QMC_OMP)
|
||||
install(TARGETS qmc-check-affinity
|
||||
RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
|
||||
add_subdirectory(ppconvert)
|
||||
|
||||
if(BUILD_UNIT_TESTS)
|
||||
|
|
|
@ -31,26 +31,28 @@ add_unit_test(${UTEST_NAME} 1 1 $<TARGET_FILE:${UTEST_EXE}>)
|
|||
set_tests_properties(${UTEST_NAME} PROPERTIES WORKING_DIRECTORY ${UTEST_DIR})
|
||||
|
||||
# Minimal test for qmc-check-affinity. Check for "OpenMP" in output, no errorcodes.
|
||||
if(HAVE_MPI)
|
||||
add_test(NAME check-affinity_runs COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 1 ${MPIEXEC_PREFLAGS}
|
||||
$<TARGET_FILE:qmc-check-affinity>)
|
||||
else()
|
||||
add_test(NAME check-affinity_runs COMMAND $<TARGET_FILE:qmc-check-affinity>)
|
||||
if(QMC_OMP)
|
||||
if(HAVE_MPI)
|
||||
add_test(NAME check-affinity_runs COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 1 ${MPIEXEC_PREFLAGS}
|
||||
$<TARGET_FILE:qmc-check-affinity>)
|
||||
else()
|
||||
add_test(NAME check-affinity_runs COMMAND $<TARGET_FILE:qmc-check-affinity>)
|
||||
endif()
|
||||
set_tests_properties(
|
||||
check-affinity_runs
|
||||
PROPERTIES TIMEOUT
|
||||
120
|
||||
LABELS
|
||||
"deterministic"
|
||||
PASS_REGULAR_EXPRESSION
|
||||
"OpenMP"
|
||||
PROCESSORS
|
||||
1
|
||||
ENVIRONMENT
|
||||
OMP_NUM_THREADS=3
|
||||
PROCESSOR_AFFINITY
|
||||
TRUE)
|
||||
endif()
|
||||
set_tests_properties(
|
||||
check-affinity_runs
|
||||
PROPERTIES TIMEOUT
|
||||
120
|
||||
LABELS
|
||||
"deterministic"
|
||||
PASS_REGULAR_EXPRESSION
|
||||
"OpenMP"
|
||||
PROCESSORS
|
||||
1
|
||||
ENVIRONMENT
|
||||
OMP_NUM_THREADS=3
|
||||
PROCESSOR_AFFINITY
|
||||
TRUE)
|
||||
|
||||
# Basic test for qmc-get-supercell. Cubic primitive vectors, request what should optimally be a 2x2x2 tiling
|
||||
if(HAVE_MPI)
|
||||
|
|
|
@ -46,7 +46,7 @@ class CPUClock
|
|||
public:
|
||||
double operator()()
|
||||
{
|
||||
#if defined(ENABLE_OPENMP)
|
||||
#if defined(QMC_OMP)
|
||||
return omp_get_wtime();
|
||||
#else
|
||||
struct timeval tv;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#cmakedefine PRINT_DEBUG @PRINT_DEBUG@
|
||||
|
||||
/* Enable OpenMP parallelization. */
|
||||
#cmakedefine ENABLE_OPENMP @ENABLE_OPENMP@
|
||||
#cmakedefine QMC_OMP @QMC_OMP@
|
||||
|
||||
/* Enable OpenMP offload. */
|
||||
#cmakedefine ENABLE_OFFLOAD @ENABLE_OFFLOAD@
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
//
|
||||
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef FORMIC_OHMMS_OPENMP_H
|
||||
|
@ -22,21 +18,12 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_OPENMP)
|
||||
#if defined(QMC_OMP)
|
||||
#include <omp.h>
|
||||
#else
|
||||
typedef int omp_int_t;
|
||||
inline omp_int_t omp_get_thread_num()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
inline omp_int_t omp_get_max_threads()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
inline omp_int_t omp_get_num_threads()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
inline omp_int_t omp_get_thread_num() { return 0; }
|
||||
inline omp_int_t omp_get_max_threads() { return 1; }
|
||||
inline omp_int_t omp_get_num_threads() { return 1; }
|
||||
#endif
|
||||
#endif // FORMIC_OHMMS_OPENMP_H
|
||||
|
|
Loading…
Reference in New Issue