From 69b8228eb10c5f12ba7ba1ea5ad61e1addcb1a59 Mon Sep 17 00:00:00 2001 From: Ajay Panyala Date: Fri, 11 Oct 2024 14:14:55 -0700 Subject: [PATCH] initial attempt to enable all methods as a library --- exachem/CMakeLists.txt | 39 +++-- exachem/cc/cc2/cc2.cmake | 1 + exachem/cc/cc2/cc2_canonical.cpp | 4 +- exachem/cc/cc2/cd_cc2.cpp | 2 +- exachem/cc/cc2/cd_cc2.hpp | 15 ++ exachem/cc/cc2/cd_cc2_cs.cpp | 2 +- exachem/cc/cc2/cd_cc2_cs.hpp | 4 +- exachem/cc/cc2/cd_cc2_os.cpp | 2 +- exachem/cc/cc2/cd_cc2_os.hpp | 4 +- exachem/cc/ccsd/cd_ccsd_cs_ann.cpp | 2 +- exachem/cc/ccsd/cd_ccsd_os_ann.cpp | 2 +- exachem/cc/ccsd_t/ccsd_t.cpp | 6 +- exachem/cc/ccsd_t/ccsd_t_all_fused_gpu.cu | 4 +- exachem/cc/ducc/ducc-t_ccsd.cpp | 7 +- exachem/cc/ducc/ducc-t_ccsd.hpp | 21 +++ exachem/cc/ducc/ducc.cmake | 3 +- exachem/cc/ducc/ducc_driver.cpp | 9 +- exachem/cc/eom/eom.cmake | 7 +- exachem/cc/eom/eomccsd_driver.cpp | 4 +- exachem/cc/eom/eomccsd_opt.cpp | 2 +- exachem/cc/eom/eomccsd_opt.hpp | 2 +- exachem/cc/eom/eomguess_opt.hpp | 2 +- exachem/cc/gfcc/gfcc.cmake | 5 +- exachem/cc/gfcc/gfccsd.hpp | 14 ++ exachem/cc/gfcc/gfccsd_driver.cpp | 4 +- exachem/cc/lambda/ccsd_lambda.cpp | 2 +- exachem/cc/lambda/ccsd_lambda.hpp | 2 +- exachem/cc/lambda/ccsd_lambda_driver.cpp | 7 +- exachem/cc/lambda/ccsd_natural_orbitals.cpp | 4 +- exachem/cc/lambda/lambda.cmake | 6 +- exachem/cc/rteom/rt_eom_cd_ccsd.cpp | 5 +- exachem/cc/rteom/rt_eom_cd_ccsd.hpp | 14 ++ exachem/cc/rteom/rteom.cmake | 6 +- exachem/cholesky/cholesky_2e_driver.cpp | 2 +- exachem/common/common.cmake | 5 +- exachem/common/options/parse_options.cpp | 4 +- exachem/common/options/parse_options.hpp | 16 +- exachem/fci/fci.cmake | 12 ++ exachem/fci/fci.cpp | 156 ++++++++++++++++++++ exachem/fci/fci.hpp | 151 +------------------ exachem/mp2/cd_mp2.cpp | 4 +- exachem/mp2/cd_mp2.hpp | 4 +- exachem/task/ec_task.cpp | 57 +++++++ exachem/task/ec_task.hpp | 39 +++++ exachem/task/task.cmake | 13 ++ methods/CMakeLists.txt | 28 +--- methods/ExaChem.cpp | 67 +-------- 47 files changed, 464 insertions(+), 307 deletions(-) create mode 100644 exachem/cc/cc2/cd_cc2.hpp create mode 100644 exachem/cc/ducc/ducc-t_ccsd.hpp create mode 100644 exachem/cc/gfcc/gfccsd.hpp create mode 100644 exachem/cc/rteom/rt_eom_cd_ccsd.hpp create mode 100644 exachem/fci/fci.cmake create mode 100644 exachem/fci/fci.cpp create mode 100644 exachem/task/ec_task.cpp create mode 100644 exachem/task/ec_task.hpp create mode 100644 exachem/task/task.cmake diff --git a/exachem/CMakeLists.txt b/exachem/CMakeLists.txt index 2be33af..4bd196c 100644 --- a/exachem/CMakeLists.txt +++ b/exachem/CMakeLists.txt @@ -11,15 +11,36 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/scf/scf.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/common/common.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/mp2/mp2.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cholesky/cholesky.cmake) - -include(${CMAKE_CURRENT_SOURCE_DIR}/cc/cc.cmake) - -#Add the current directory's sources to the list -set(EXACHEM_SRCS ${SCF_SRCS} ${COMMON_SRCS} ${MP2_SRCS} ${CD_SRCS} ${CC2_SRCS} ${CCSD_SRCS} ${CCSD_T_SRCS}) - -#Add the current directory's header files to the list -set(EXACHEM_INCLUDES ${SCF_INCLUDES} ${COMMON_INCLUDES} ${CD_INCLUDES} ${MP2_INCLUDES} - ${CC_INCLUDES} ${CC2_INCLUDES} ${CCSD_INCLUDES} ${CCSD_T_INCLUDES}) +include(${CMAKE_CURRENT_SOURCE_DIR}/task/task.cmake) + +option(EC_COMPLEX "enable complex codes" ON) + +list(FIND MODULES "CC" _cc_index) + +if(NOT _cc_index EQUAL -1) + message(STATUS "Compiling CC modules") + + include(${CMAKE_CURRENT_SOURCE_DIR}/fci/fci.cmake) + include(${CMAKE_CURRENT_SOURCE_DIR}/cc/cc.cmake) + include(${CMAKE_CURRENT_SOURCE_DIR}/cc/eom/eom.cmake) + include(${CMAKE_CURRENT_SOURCE_DIR}/cc/lambda/lambda.cmake) + include(${CMAKE_CURRENT_SOURCE_DIR}/cc/ducc/ducc.cmake) + + if(NOT USE_UPCXX AND EC_COMPLEX) + include(${CMAKE_CURRENT_SOURCE_DIR}/cc/gfcc/gfcc.cmake) + include(${CMAKE_CURRENT_SOURCE_DIR}/cc/rteom/rteom.cmake) + endif() + +endif() + +#Add the various modules sources to the list +set(EXACHEM_SRCS ${SCF_SRCS} ${COMMON_SRCS} ${MP2_SRCS} ${CD_SRCS} ${CC2_SRCS} ${CCSD_SRCS} ${CCSD_T_SRCS} ${FCI_SRCS} +${CCSDT_SRCS} ${CC_LAMBDA_SRCS} ${DUCC_SRCS} ${CC_EOM_SRCS} ${RTEOM_SRCS} ${GFCC_SRCS} ${TASK_SRCS}) + +#Add the various modules header files to the list +set(EXACHEM_INCLUDES ${SCF_INCLUDES} ${COMMON_INCLUDES} ${CD_INCLUDES} ${MP2_INCLUDES} ${DUCC_INCLUDES} + ${CC_INCLUDES} ${CC2_INCLUDES} ${CCSD_INCLUDES} ${CCSD_T_INCLUDES} ${CC_EOM_INCLUDES} ${FCI_INCLUDES} + ${CC_LAMBDA_INCLUDES} ${RTEOM_INCLUDES} ${GFCC_INCLUDES} ${CCSDT_INCLUDES} ${TASK_INCLUDES}) cmsb_add_library(exachem EXACHEM_SRCS EXACHEM_INCLUDES EXACHEM_CFLAGS EXACHEM_LFLAGS) target_include_directories(exachem PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/exachem/cc/cc2/cc2.cmake b/exachem/cc/cc2/cc2.cmake index f978fff..6b8cbe1 100644 --- a/exachem/cc/cc2/cc2.cmake +++ b/exachem/cc/cc2/cc2.cmake @@ -10,6 +10,7 @@ set(CC2_SRCS ) set(CC2_INCLUDES + ${CC2_SRCDIR}/cd_cc2.hpp ${CC2_SRCDIR}/cd_cc2_cs.hpp ${CC2_SRCDIR}/cd_cc2_os.hpp ) diff --git a/exachem/cc/cc2/cc2_canonical.cpp b/exachem/cc/cc2/cc2_canonical.cpp index f3b8e74..b31228f 100644 --- a/exachem/cc/cc2/cc2_canonical.cpp +++ b/exachem/cc/cc2/cc2_canonical.cpp @@ -6,8 +6,8 @@ * See LICENSE.txt for details */ -#include "cc/ccsd/ccsd_util.hpp" -#include "cholesky/cholesky_2e_driver.hpp" +#include "exachem/cc/ccsd/ccsd_util.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" using namespace tamm; using namespace exachem::scf; diff --git a/exachem/cc/cc2/cd_cc2.cpp b/exachem/cc/cc2/cd_cc2.cpp index 47cd11d..b55b38c 100644 --- a/exachem/cc/cc2/cd_cc2.cpp +++ b/exachem/cc/cc2/cd_cc2.cpp @@ -6,7 +6,7 @@ * See LICENSE.txt for details */ -#include "cc/cc2/cd_cc2_os.hpp" +#include "exachem/cc/cc2/cd_cc2.hpp" #include namespace fs = std::filesystem; diff --git a/exachem/cc/cc2/cd_cc2.hpp b/exachem/cc/cc2/cd_cc2.hpp new file mode 100644 index 0000000..75094c9 --- /dev/null +++ b/exachem/cc/cc2/cd_cc2.hpp @@ -0,0 +1,15 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#pragma once + +#include "exachem/cc/cc2/cd_cc2_os.hpp" + +namespace exachem::cc2 { +void cd_cc2_driver(ExecutionContext& ec, ChemEnv& chem_env); +} // namespace exachem::cc2 diff --git a/exachem/cc/cc2/cd_cc2_cs.cpp b/exachem/cc/cc2/cd_cc2_cs.cpp index c24c55e..94790ed 100644 --- a/exachem/cc/cc2/cd_cc2_cs.cpp +++ b/exachem/cc/cc2/cd_cc2_cs.cpp @@ -6,7 +6,7 @@ * See LICENSE.txt for details */ -#include "cd_cc2_cs.hpp" +#include "exachem/cc/cc2/cd_cc2_cs.hpp" namespace cc2_cs { diff --git a/exachem/cc/cc2/cd_cc2_cs.hpp b/exachem/cc/cc2/cd_cc2_cs.hpp index 9e8a3a7..e1988f8 100644 --- a/exachem/cc/cc2/cd_cc2_cs.hpp +++ b/exachem/cc/cc2/cd_cc2_cs.hpp @@ -8,7 +8,7 @@ #pragma once -#include "cc/ccsd/ccsd_util.hpp" +#include "exachem/cc/ccsd/ccsd_util.hpp" using namespace tamm; @@ -38,4 +38,4 @@ std::tuple cd_cc2_cs_driver( std::vector>& d_t2s, std::vector& p_evl_sorted, Tensor& cv3d, Tensor dt1_full, Tensor dt2_full, bool cc2_restart = false, std::string out_fp = "", bool computeTData = false); -}; // namespace cc2_cs +}; // namespace cc2_cs \ No newline at end of file diff --git a/exachem/cc/cc2/cd_cc2_os.cpp b/exachem/cc/cc2/cd_cc2_os.cpp index 2696f15..002642a 100644 --- a/exachem/cc/cc2/cd_cc2_os.cpp +++ b/exachem/cc/cc2/cd_cc2_os.cpp @@ -6,7 +6,7 @@ * See LICENSE.txt for details */ -#include "cd_cc2_os.hpp" +#include "exachem/cc/cc2/cd_cc2_os.hpp" namespace cc2_os { diff --git a/exachem/cc/cc2/cd_cc2_os.hpp b/exachem/cc/cc2/cd_cc2_os.hpp index fa5cf22..409ba6f 100644 --- a/exachem/cc/cc2/cd_cc2_os.hpp +++ b/exachem/cc/cc2/cd_cc2_os.hpp @@ -8,7 +8,7 @@ #pragma once -#include "cd_cc2_cs.hpp" +#include "exachem/cc/cc2/cd_cc2_cs.hpp" namespace cc2_os { @@ -37,4 +37,4 @@ cd_cc2_os_driver(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpace& std::vector>& d_t2s, std::vector& p_evl_sorted, Tensor& cv3d, bool cc2_restart = false, std::string out_fp = "", bool computeTData = false); -}; // namespace cc2_os +}; // namespace cc2_os \ No newline at end of file diff --git a/exachem/cc/ccsd/cd_ccsd_cs_ann.cpp b/exachem/cc/ccsd/cd_ccsd_cs_ann.cpp index 04df974..95c2a76 100644 --- a/exachem/cc/ccsd/cd_ccsd_cs_ann.cpp +++ b/exachem/cc/ccsd/cd_ccsd_cs_ann.cpp @@ -7,7 +7,7 @@ * See LICENSE.txt for details */ -#include "cd_ccsd_cs_ann.hpp" +#include "exachem/cc/ccsd/cd_ccsd_cs_ann.hpp" using CCEType = double; CCSE_Tensors _a021; diff --git a/exachem/cc/ccsd/cd_ccsd_os_ann.cpp b/exachem/cc/ccsd/cd_ccsd_os_ann.cpp index e4ab7ea..270ee38 100644 --- a/exachem/cc/ccsd/cd_ccsd_os_ann.cpp +++ b/exachem/cc/ccsd/cd_ccsd_os_ann.cpp @@ -6,7 +6,7 @@ * See LICENSE.txt for details */ -#include "cd_ccsd_os_ann.hpp" +#include "exachem/cc/ccsd/cd_ccsd_os_ann.hpp" using CCEType = double; CCSE_Tensors _a021_os; diff --git a/exachem/cc/ccsd_t/ccsd_t.cpp b/exachem/cc/ccsd_t/ccsd_t.cpp index c750826..bd3664c 100644 --- a/exachem/cc/ccsd_t/ccsd_t.cpp +++ b/exachem/cc/ccsd_t/ccsd_t.cpp @@ -8,9 +8,9 @@ */ // clang-format off -#include "cc/ccsd/cd_ccsd_os_ann.hpp" -#include "cc/ccsd_t/ccsd_t_fused_driver.hpp" -#include "cholesky/cholesky_2e_driver.hpp" +#include "exachem/cc/ccsd/cd_ccsd_os_ann.hpp" +#include "exachem/cc/ccsd_t/ccsd_t_fused_driver.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" // clang-format on double ccsdt_s1_t1_GetTime = 0; diff --git a/exachem/cc/ccsd_t/ccsd_t_all_fused_gpu.cu b/exachem/cc/ccsd_t/ccsd_t_all_fused_gpu.cu index cb2e786..74e2214 100644 --- a/exachem/cc/ccsd_t/ccsd_t_all_fused_gpu.cu +++ b/exachem/cc/ccsd_t/ccsd_t_all_fused_gpu.cu @@ -12,7 +12,7 @@ 3rd. Generation Tensor Cores (FP64) */ // (1) Pure FP64 -#include "ccsd_t_common.hpp" +#include "exachem/cc/ccsd_t/ccsd_t_common.hpp" #include #include #include @@ -125,7 +125,7 @@ __device__ inline void rt_load_fixed(double* smem, const int idx_x_1, const int } } -#include "ccsd_t_g2s_device_functions.cu" +#include "exachem/cc/ccsd_t/ccsd_t_g2s_device_functions.cu" //------------------------------------------------------------------------------ // created by tc_gen_code_Kernel() diff --git a/exachem/cc/ducc/ducc-t_ccsd.cpp b/exachem/cc/ducc/ducc-t_ccsd.cpp index f3695a1..51bf86d 100644 --- a/exachem/cc/ducc/ducc-t_ccsd.cpp +++ b/exachem/cc/ducc/ducc-t_ccsd.cpp @@ -6,8 +6,8 @@ * See LICENSE.txt for details */ -#include "cc/ccsd/cd_ccsd_os_ann.hpp" -#include "cholesky/v2tensors.hpp" +#include "exachem/cc/ducc/ducc-t_ccsd.hpp" +#include "exachem/cc/ccsd/cd_ccsd_os_ann.hpp" #include using namespace tamm; @@ -539,8 +539,7 @@ namespace exachem::cc::ducc { template void DUCC_T_CCSD_Driver(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpace& MO, Tensor& t1, Tensor& t2, Tensor& f1, - cholesky_2e::V2Tensors& v2tensors, size_t nactv, - ExecutionHW ex_hw = ExecutionHW::CPU) { + cholesky_2e::V2Tensors& v2tensors, size_t nactv, ExecutionHW ex_hw) { Scheduler sch{ec}; SystemData& sys_data = chem_env.sys_data; diff --git a/exachem/cc/ducc/ducc-t_ccsd.hpp b/exachem/cc/ducc/ducc-t_ccsd.hpp new file mode 100644 index 0000000..8c6c170 --- /dev/null +++ b/exachem/cc/ducc/ducc-t_ccsd.hpp @@ -0,0 +1,21 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#pragma once + +#include "exachem/cholesky/v2tensors.hpp" + +namespace exachem::cc::ducc { +void ducc_driver(ExecutionContext& ec, ChemEnv& chem_env); + +template +void DUCC_T_CCSD_Driver(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpace& MO, + Tensor& t1, Tensor& t2, Tensor& f1, + cholesky_2e::V2Tensors& v2tensors, size_t nactv, + ExecutionHW ex_hw = ExecutionHW::CPU); +} // namespace exachem::cc::ducc diff --git a/exachem/cc/ducc/ducc.cmake b/exachem/cc/ducc/ducc.cmake index 9733f6b..8f098a5 100644 --- a/exachem/cc/ducc/ducc.cmake +++ b/exachem/cc/ducc/ducc.cmake @@ -1,9 +1,10 @@ include(TargetMacros) -set(DUCC_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/../exachem/cc/ducc) +set(DUCC_SRCDIR cc/ducc) set(DUCC_SRCS ${DUCC_SRCDIR}/ducc_driver.cpp ${DUCC_SRCDIR}/ducc-t_ccsd.cpp ) +set(DUCC_INCLUDES ${DUCC_SRCDIR}/ducc-t_ccsd.hpp) diff --git a/exachem/cc/ducc/ducc_driver.cpp b/exachem/cc/ducc/ducc_driver.cpp index 7475ea9..1e942c2 100644 --- a/exachem/cc/ducc/ducc_driver.cpp +++ b/exachem/cc/ducc/ducc_driver.cpp @@ -6,17 +6,14 @@ * See LICENSE.txt for details */ -#include "cc/ccsd/cd_ccsd_os_ann.hpp" -#include "cholesky/cholesky_2e_driver.hpp" +#include "exachem/cc/ccsd/cd_ccsd_os_ann.hpp" +#include "exachem/cc/ducc/ducc-t_ccsd.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" #include namespace fs = std::filesystem; namespace exachem::cc::ducc { -template -void DUCC_T_CCSD_Driver(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpace& MO, - Tensor& t1, Tensor& t2, Tensor& f1, - cholesky_2e::V2Tensors& v2tensors, size_t nactv, ExecutionHW ex_hw); void ducc_driver(ExecutionContext& ec, ChemEnv& chem_env) { using T = double; diff --git a/exachem/cc/eom/eom.cmake b/exachem/cc/eom/eom.cmake index 5507f46..e09223a 100644 --- a/exachem/cc/eom/eom.cmake +++ b/exachem/cc/eom/eom.cmake @@ -1,7 +1,7 @@ include(TargetMacros) -set(CC_EOM_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/../exachem/cc/eom) +set(CC_EOM_SRCDIR cc/eom) set(CC_EOM_SRCS ${CC_EOM_SRCDIR}/eomccsd_opt.cpp ${CC_EOM_SRCDIR}/eomccsd_driver.cpp @@ -9,3 +9,8 @@ set(CC_EOM_SRCS # ${CC_EOM_SRCDIR}/eom_gradients.cpp ) +set(CC_EOM_INCLUDES + ${CC_EOM_SRCDIR}/eomccsd_opt.hpp + ${CC_EOM_SRCDIR}/eomguess_opt.hpp + ) + diff --git a/exachem/cc/eom/eomccsd_driver.cpp b/exachem/cc/eom/eomccsd_driver.cpp index 5799d1f..415d0e2 100644 --- a/exachem/cc/eom/eomccsd_driver.cpp +++ b/exachem/cc/eom/eomccsd_driver.cpp @@ -6,8 +6,8 @@ * See LICENSE.txt for details */ -#include "cholesky/cholesky_2e_driver.hpp" -#include "eomccsd_opt.hpp" +#include "exachem/cc/eom/eomccsd_opt.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" void exachem::cc::eom::eom_ccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) { using T = double; diff --git a/exachem/cc/eom/eomccsd_opt.cpp b/exachem/cc/eom/eomccsd_opt.cpp index 66463c1..abcbf51 100644 --- a/exachem/cc/eom/eomccsd_opt.cpp +++ b/exachem/cc/eom/eomccsd_opt.cpp @@ -6,7 +6,7 @@ * See LICENSE.txt for details */ -#include "eomccsd_opt.hpp" +#include "exachem/cc/eom/eomccsd_opt.hpp" #include namespace fs = std::filesystem; diff --git a/exachem/cc/eom/eomccsd_opt.hpp b/exachem/cc/eom/eomccsd_opt.hpp index 66b1acc..e02ae2f 100644 --- a/exachem/cc/eom/eomccsd_opt.hpp +++ b/exachem/cc/eom/eomccsd_opt.hpp @@ -8,7 +8,7 @@ #pragma once -#include "eomguess_opt.hpp" +#include "exachem/cc/eom/eomguess_opt.hpp" using namespace tamm; diff --git a/exachem/cc/eom/eomguess_opt.hpp b/exachem/cc/eom/eomguess_opt.hpp index a06d434..06941e0 100644 --- a/exachem/cc/eom/eomguess_opt.hpp +++ b/exachem/cc/eom/eomguess_opt.hpp @@ -8,7 +8,7 @@ #pragma once -#include "cc/ccsd/cd_ccsd_os_ann.hpp" +#include "exachem/cc/ccsd/cd_ccsd_os_ann.hpp" #include #include using namespace tamm; diff --git a/exachem/cc/gfcc/gfcc.cmake b/exachem/cc/gfcc/gfcc.cmake index 3757be1..4a767b5 100644 --- a/exachem/cc/gfcc/gfcc.cmake +++ b/exachem/cc/gfcc/gfcc.cmake @@ -1,8 +1,11 @@ include(TargetMacros) -set(GFCC_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/../exachem/cc/gfcc) +set(GFCC_SRCDIR cc/gfcc) set(GFCC_SRCS ${GFCC_SRCDIR}/gfccsd_driver.cpp ) +set(GFCC_INCLUDES + ${GFCC_SRCDIR}/gfccsd.hpp + ) diff --git a/exachem/cc/gfcc/gfccsd.hpp b/exachem/cc/gfcc/gfccsd.hpp new file mode 100644 index 0000000..12c8b5e --- /dev/null +++ b/exachem/cc/gfcc/gfccsd.hpp @@ -0,0 +1,14 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#pragma once +#include "exachem/common/chemenv.hpp" + +namespace exachem::cc::gfcc { +void gfccsd_driver(ExecutionContext& ec, ChemEnv& chem_env); +}; \ No newline at end of file diff --git a/exachem/cc/gfcc/gfccsd_driver.cpp b/exachem/cc/gfcc/gfccsd_driver.cpp index 8c84828..26c6f58 100644 --- a/exachem/cc/gfcc/gfccsd_driver.cpp +++ b/exachem/cc/gfcc/gfccsd_driver.cpp @@ -6,8 +6,8 @@ * See LICENSE.txt for details */ -#include "cc/lambda/ccsd_lambda.hpp" -#include "cholesky/cholesky_2e_driver.hpp" +#include "exachem/cc/lambda/ccsd_lambda.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" #include "gf_diis.hpp" #include "gf_guess.hpp" #include "gfccsd_ea.hpp" diff --git a/exachem/cc/lambda/ccsd_lambda.cpp b/exachem/cc/lambda/ccsd_lambda.cpp index 5cf1bd6..0a0b47c 100644 --- a/exachem/cc/lambda/ccsd_lambda.cpp +++ b/exachem/cc/lambda/ccsd_lambda.cpp @@ -6,7 +6,7 @@ * See LICENSE.txt for details */ -#include "ccsd_lambda.hpp" +#include "exachem/cc/lambda/ccsd_lambda.hpp" void exachem::cc::ccsd_lambda::iteration_print_lambda(ChemEnv& chem_env, const ProcGroup& pg, int iter, double residual, double time) { diff --git a/exachem/cc/lambda/ccsd_lambda.hpp b/exachem/cc/lambda/ccsd_lambda.hpp index 9b8dea5..86b1e06 100644 --- a/exachem/cc/lambda/ccsd_lambda.hpp +++ b/exachem/cc/lambda/ccsd_lambda.hpp @@ -8,7 +8,7 @@ #pragma once -#include "cc/ccsd/cd_ccsd_os_ann.hpp" +#include "exachem/cc/ccsd/cd_ccsd_os_ann.hpp" #include "exachem/scf/scf_main.hpp" using namespace tamm; diff --git a/exachem/cc/lambda/ccsd_lambda_driver.cpp b/exachem/cc/lambda/ccsd_lambda_driver.cpp index 688c76f..6047b78 100644 --- a/exachem/cc/lambda/ccsd_lambda_driver.cpp +++ b/exachem/cc/lambda/ccsd_lambda_driver.cpp @@ -5,8 +5,9 @@ * * See LICENSE.txt for details */ -#include "ccsd_lambda.hpp" -#include "exachem/common/termcolor.hpp" + +#include "exachem/cc/lambda/ccsd_lambda.hpp" +// #include "exachem/common/termcolor.hpp" #include "exachem/scf/scf_guess.hpp" #include @@ -27,7 +28,7 @@ Tensor compute_2rdm(std::vector&, std::string, Scheduler&, TiledIndexSpa void exachem::cc::ccsd_lambda::ccsd_lambda_driver(ExecutionContext& ec, ChemEnv& chem_env) { using T = double; - using namespace termcolor; + // using namespace termcolor; auto rank = ec.pg().rank(); scf::scf_driver(ec, chem_env); diff --git a/exachem/cc/lambda/ccsd_natural_orbitals.cpp b/exachem/cc/lambda/ccsd_natural_orbitals.cpp index f845d5c..fc8418f 100644 --- a/exachem/cc/lambda/ccsd_natural_orbitals.cpp +++ b/exachem/cc/lambda/ccsd_natural_orbitals.cpp @@ -6,8 +6,8 @@ * See LICENSE.txt for details */ -#include "cc/ccsd/ccsd_util.hpp" -// #include "cc/ducc/ducc_driver.cpp" +#include "exachem/cc/ccsd/ccsd_util.hpp" +// #include "exachem/cc/ducc/ducc_driver.cpp" #include using namespace tamm; diff --git a/exachem/cc/lambda/lambda.cmake b/exachem/cc/lambda/lambda.cmake index 5c4c973..f0409a8 100644 --- a/exachem/cc/lambda/lambda.cmake +++ b/exachem/cc/lambda/lambda.cmake @@ -1,7 +1,7 @@ include(TargetMacros) -set(CC_LAMBDA_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/../exachem/cc/lambda) +set(CC_LAMBDA_SRCDIR cc/lambda) set(CC_LAMBDA_SRCS ${CC_LAMBDA_SRCDIR}/ccsd_rdm.cpp ${CC_LAMBDA_SRCDIR}/ccsd_lambda.cpp @@ -9,3 +9,7 @@ set(CC_LAMBDA_SRCS ${CC_LAMBDA_SRCDIR}/ccsd_natural_orbitals.cpp ) +set(CC_LAMBDA_INCLUDES + ${CC_LAMBDA_SRCDIR}/ccsd_lambda.hpp + ) + diff --git a/exachem/cc/rteom/rt_eom_cd_ccsd.cpp b/exachem/cc/rteom/rt_eom_cd_ccsd.cpp index 1d66d71..85aaa18 100644 --- a/exachem/cc/rteom/rt_eom_cd_ccsd.cpp +++ b/exachem/cc/rteom/rt_eom_cd_ccsd.cpp @@ -6,8 +6,9 @@ * See LICENSE.txt for details */ -#include "cc/ccsd/ccsd_util.hpp" -#include "cholesky/cholesky_2e_driver.hpp" +#include "exachem/cc/rteom/rt_eom_cd_ccsd.hpp" +#include "exachem/cc/ccsd/ccsd_util.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" using namespace tamm; namespace exachem::rteom_cc::ccsd { diff --git a/exachem/cc/rteom/rt_eom_cd_ccsd.hpp b/exachem/cc/rteom/rt_eom_cd_ccsd.hpp new file mode 100644 index 0000000..c5bf120 --- /dev/null +++ b/exachem/cc/rteom/rt_eom_cd_ccsd.hpp @@ -0,0 +1,14 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#pragma once +#include "exachem/common/chemenv.hpp" + +namespace exachem::rteom_cc::ccsd { +void rt_eom_cd_ccsd_driver(ExecutionContext& ec, ChemEnv& chem_env); +} // namespace exachem::rteom_cc::ccsd diff --git a/exachem/cc/rteom/rteom.cmake b/exachem/cc/rteom/rteom.cmake index e9fd764..434350e 100644 --- a/exachem/cc/rteom/rteom.cmake +++ b/exachem/cc/rteom/rteom.cmake @@ -1,8 +1,12 @@ include(TargetMacros) -set(RTEOM_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/../exachem/cc/rteom) +set(RTEOM_SRCDIR cc/rteom) set(RTEOM_SRCS ${RTEOM_SRCDIR}/rt_eom_cd_ccsd.cpp ) +set(RTEOM_INCLUDES + ${RTEOM_SRCDIR}/rt_eom_cd_ccsd.hpp + ) + diff --git a/exachem/cholesky/cholesky_2e_driver.cpp b/exachem/cholesky/cholesky_2e_driver.cpp index e7d4ecd..c96b3d4 100644 --- a/exachem/cholesky/cholesky_2e_driver.cpp +++ b/exachem/cholesky/cholesky_2e_driver.cpp @@ -6,7 +6,7 @@ * See LICENSE.txt for details */ -#include "cholesky/cholesky_2e_driver.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" using namespace exachem::scf; void exachem::cholesky_2e::cholesky_decomp_2e(ExecutionContext& ec, ChemEnv& chem_env) { diff --git a/exachem/common/common.cmake b/exachem/common/common.cmake index f057ce5..b470ac1 100644 --- a/exachem/common/common.cmake +++ b/exachem/common/common.cmake @@ -24,7 +24,8 @@ set(COMMON_INCLUDES ${COMMON_SRCDIR}/options/parse_fci_options.hpp ${COMMON_SRCDIR}/options/parse_gw_options.hpp ${COMMON_SRCDIR}/options/parse_task_options.hpp - ${COMMON_SRCDIR}/options/input_options.hpp + ${COMMON_SRCDIR}/options/input_options.hpp + ${COMMON_SRCDIR}/options/parser_utils.hpp ${COMMON_SRCDIR}/initialize_system_data.hpp ) @@ -44,7 +45,7 @@ set(COMMON_SRCS ${COMMON_SRCDIR}/options/parse_fci_options.cpp ${COMMON_SRCDIR}/options/parse_gw_options.cpp ${COMMON_SRCDIR}/options/parse_task_options.cpp - ${COMMON_SRCDIR}/options/input_options.cpp + ${COMMON_SRCDIR}/options/input_options.cpp ${COMMON_SRCDIR}/initialize_system_data.cpp ${COMMON_SRCDIR}/ec_molden.cpp ) diff --git a/exachem/common/options/parse_options.cpp b/exachem/common/options/parse_options.cpp index a281681..5f57c02 100644 --- a/exachem/common/options/parse_options.cpp +++ b/exachem/common/options/parse_options.cpp @@ -6,7 +6,7 @@ * See LICENSE.txt for details */ -#include "parse_options.hpp" +#include "exachem/common/options/parse_options.hpp" ECOptionParser::ECOptionParser(ChemEnv& chem_env) { initialize(chem_env); @@ -101,4 +101,4 @@ void ECOptionParser::parse_all_options(ChemEnv& chem_env) { ParseFCIOptions parse_fci_options(chem_env); ParseTaskOptions parse_task_options(chem_env); IniSystemData ini_sys_data(chem_env); -} \ No newline at end of file +} diff --git a/exachem/common/options/parse_options.hpp b/exachem/common/options/parse_options.hpp index 9be71a3..f5b0a09 100644 --- a/exachem/common/options/parse_options.hpp +++ b/exachem/common/options/parse_options.hpp @@ -8,14 +8,14 @@ #pragma once // clang-format off -#include "parser_utils.hpp" -#include "parse_common_options.hpp" -#include "parse_cd_options.hpp" -#include "parse_ccsd_options.hpp" -#include "parse_fci_options.hpp" -#include "parse_gw_options.hpp" -#include "parse_scf_options.hpp" -#include "parse_task_options.hpp" +#include "exachem/common/options/parser_utils.hpp" +#include "exachem/common/options/parse_common_options.hpp" +#include "exachem/common/options/parse_cd_options.hpp" +#include "exachem/common/options/parse_ccsd_options.hpp" +#include "exachem/common/options/parse_fci_options.hpp" +#include "exachem/common/options/parse_gw_options.hpp" +#include "exachem/common/options/parse_scf_options.hpp" +#include "exachem/common/options/parse_task_options.hpp" #include "exachem/common/initialize_system_data.hpp" // clang-format on diff --git a/exachem/fci/fci.cmake b/exachem/fci/fci.cmake new file mode 100644 index 0000000..95301f7 --- /dev/null +++ b/exachem/fci/fci.cmake @@ -0,0 +1,12 @@ + +include(TargetMacros) + +set(FCI_SRCDIR fci) + +set(FCI_INCLUDES + ${FCI_SRCDIR}/fci.hpp +) +set(FCI_SRCS + ${FCI_SRCDIR}/fci.cpp +) + diff --git a/exachem/fci/fci.cpp b/exachem/fci/fci.cpp new file mode 100644 index 0000000..98bfd4b --- /dev/null +++ b/exachem/fci/fci.cpp @@ -0,0 +1,156 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#include "exachem/fci/fci.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" + +using namespace tamm; + +namespace exachem::fci { + +template +std::string generate_fcidump(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpace& MSO, + Tensor& lcao, Tensor& d_f1, Tensor& full_v2, + ExecutionHW ex_hw) { + // int nactv = chem_env.ioptions.fci_options.nactive; + Scheduler sch{ec}; + + std::cout.precision(15); + // const auto rank = ec.pg().rank(); + + auto [z1, z2] = MSO.labels<2>("all"); + + // Transform d_f1 from Fock operator to the one-electron operator representation + TiledIndexSpace AO = lcao.tiled_index_spaces()[0]; + auto [mu, nu] = AO.labels<2>("all"); + + Tensor hcore{AO, AO}; + Tensor hcore_mo{{MSO, MSO}, {1, 1}}; + Tensor::allocate(&ec, hcore, hcore_mo); + + SystemData& sys_data = chem_env.sys_data; + std::string out_fp = chem_env.workspace_dir; + std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type + "/fci"; + std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; + if(!fs::exists(files_dir)) fs::create_directories(files_dir); + + std::string hcorefile = files_dir + "/../scf/" + sys_data.output_file_prefix + ".hcore"; + read_from_disk(hcore, hcorefile); + + Tensor tmp{MSO, AO}; + // clang-format off + sch.allocate(tmp) + (tmp(z1,nu) = lcao(mu,z1) * hcore(mu,nu)) + (hcore_mo(z1,z2) = tmp(z1,nu) * lcao(nu,z2)) + .deallocate(tmp,hcore).execute(); + // clang-format on + + std::vector symvec(sys_data.nbf_orig); + if(sys_data.is_unrestricted) symvec.resize(2 * sys_data.nbf_orig); + std::fill(symvec.begin(), symvec.end(), 1); + + // write fcidump file + std::string fcid_file = files_prefix + ".fcidump"; + fcidump::write_fcidump_file(chem_env, hcore_mo, full_v2, symvec, fcid_file); + + free_tensors(hcore_mo); + return files_prefix; +} + +void fci_driver(ExecutionContext& ec, ChemEnv& chem_env) { + using T = double; + + auto rank = ec.pg().rank(); + + scf::scf_driver(ec, chem_env); + + // double hf_energy = chem_env.hf_energy; + libint2::BasisSet shells = chem_env.shells; + Tensor C_AO = chem_env.C_AO; + Tensor C_beta_AO = chem_env.C_beta_AO; + Tensor F_AO = chem_env.F_AO; + Tensor F_beta_AO = chem_env.F_beta_AO; + TiledIndexSpace AO_opt = chem_env.AO_opt; + TiledIndexSpace AO_tis = chem_env.AO_tis; + std::vector shell_tile_map = chem_env.shell_tile_map; + + SystemData sys_data = chem_env.sys_data; + CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; + if(rank == 0) ccsd_options.print(); + + if(rank == 0) + cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; + + auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + + std::string out_fp = chem_env.workspace_dir; + std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; + std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; + std::string f1file = files_prefix + ".f1_mo"; + std::string v2file = files_prefix + ".cholv2"; + std::string cholfile = files_prefix + ".cholcount"; + + ExecutionHW ex_hw = ec.exhw(); + + bool ccsd_restart = ccsd_options.readt || (fs::exists(f1file) && fs::exists(v2file)); + + // deallocates F_AO, C_AO + auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = + cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, F_beta_AO, + shells, shell_tile_map, ccsd_restart, cholfile); + + TiledIndexSpace N = MO("all"); + + if(ccsd_restart) { + read_from_disk(d_f1, f1file); + read_from_disk(cholVpr, v2file); + ec.pg().barrier(); + } + + else if(ccsd_options.writet) { + // fs::remove_all(files_dir); + if(!fs::exists(files_dir)) fs::create_directories(files_dir); + + write_to_disk(d_f1, f1file); + write_to_disk(cholVpr, v2file); + + if(rank == 0) { + std::ofstream out(cholfile, std::ios::out); + if(!out) cerr << "Error opening file " << cholfile << endl; + out << chol_count << std::endl; + out.close(); + } + } + + ec.pg().barrier(); + + auto [cindex] = CI.labels<1>("all"); + auto [p, q, r, s] = MO.labels<4>("all"); + + Tensor full_v2{N, N, N, N}; + Tensor::allocate(&ec, full_v2); + + // clang-format off + Scheduler sch{ec}; + sch(full_v2(p, r, q, s) = cholVpr(p, r, cindex) * cholVpr(q, s, cindex)).execute(ex_hw); + // clang-format off + + free_tensors(cholVpr); + + files_prefix = generate_fcidump(chem_env, ec, MO, lcao, d_f1, full_v2, ex_hw); + #if defined(USE_MACIS) + if(options_map.task_options.fci) + macis_driver(ec, sys_data, files_prefix); + #endif + + free_tensors(lcao, d_f1, full_v2); + + ec.flush_and_sync(); + // delete ec; +} +} // namespace exachem::fci diff --git a/exachem/fci/fci.hpp b/exachem/fci/fci.hpp index 2ddcd9e..84dbd29 100644 --- a/exachem/fci/fci.hpp +++ b/exachem/fci/fci.hpp @@ -8,154 +8,15 @@ #pragma once -#include "cholesky/cholesky_2e_driver.hpp" #include "exachem/common/fcidump.hpp" -#if defined(USE_MACIS) -#include "macis.hpp" -#endif - -using namespace tamm; namespace exachem::fci { template -std::string generate_fcidump(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpace& MSO, - Tensor& lcao, Tensor& d_f1, Tensor& full_v2, - ExecutionHW ex_hw = ExecutionHW::CPU) { - // int nactv = chem_env.ioptions.fci_options.nactive; - Scheduler sch{ec}; - - std::cout.precision(15); - // const auto rank = ec.pg().rank(); - - auto [z1, z2] = MSO.labels<2>("all"); - - // Transform d_f1 from Fock operator to the one-electron operator representation - TiledIndexSpace AO = lcao.tiled_index_spaces()[0]; - auto [mu, nu] = AO.labels<2>("all"); - - Tensor hcore{AO, AO}; - Tensor hcore_mo{{MSO, MSO}, {1, 1}}; - Tensor::allocate(&ec, hcore, hcore_mo); - - SystemData& sys_data = chem_env.sys_data; - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type + "/fci"; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - std::string hcorefile = files_dir + "/../scf/" + sys_data.output_file_prefix + ".hcore"; - read_from_disk(hcore, hcorefile); - - Tensor tmp{MSO, AO}; - // clang-format off - sch.allocate(tmp) - (tmp(z1,nu) = lcao(mu,z1) * hcore(mu,nu)) - (hcore_mo(z1,z2) = tmp(z1,nu) * lcao(nu,z2)) - .deallocate(tmp,hcore).execute(); - // clang-format on - - std::vector symvec(sys_data.nbf_orig); - if(sys_data.is_unrestricted) symvec.resize(2 * sys_data.nbf_orig); - std::fill(symvec.begin(), symvec.end(), 1); - - // write fcidump file - std::string fcid_file = files_prefix + ".fcidump"; - fcidump::write_fcidump_file(chem_env, hcore_mo, full_v2, symvec, fcid_file); - - free_tensors(hcore_mo); - return files_prefix; -} - -void fci_driver(ExecutionContext& ec, ChemEnv& chem_env) { - using T = double; - - auto rank = ec.pg().rank(); - - scf::scf_driver(ec, chem_env); - - // double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - - SystemData sys_data = chem_env.sys_data; - CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - if(rank == 0) ccsd_options.print(); - - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; - - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); - - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - - ExecutionHW ex_hw = ec.exhw(); - - bool ccsd_restart = ccsd_options.readt || (fs::exists(f1file) && fs::exists(v2file)); - - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, F_beta_AO, - shells, shell_tile_map, ccsd_restart, cholfile); - - TiledIndexSpace N = MO("all"); - - if(ccsd_restart) { - read_from_disk(d_f1, f1file); - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); - } - - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - - ec.pg().barrier(); - - auto [cindex] = CI.labels<1>("all"); - auto [p, q, r, s] = MO.labels<4>("all"); - - Tensor full_v2{N, N, N, N}; - Tensor::allocate(&ec, full_v2); - - // clang-format off - Scheduler sch{ec}; - sch(full_v2(p, r, q, s) = cholVpr(p, r, cindex) * cholVpr(q, s, cindex)).execute(ex_hw); - // clang-format off - - free_tensors(cholVpr); - - files_prefix = generate_fcidump(chem_env, ec, MO, lcao, d_f1, full_v2, ex_hw); - #if defined(USE_MACIS) - if(options_map.task_options.fci) - macis_driver(ec, sys_data, files_prefix); - #endif - - free_tensors(lcao, d_f1, full_v2); +std::string generate_fcidump(ChemEnv& chem_env, tamm::ExecutionContext& ec, + const TiledIndexSpace& MSO, tamm::Tensor& lcao, + tamm::Tensor& d_f1, tamm::Tensor& full_v2, + ExecutionHW ex_hw = ExecutionHW::CPU); - ec.flush_and_sync(); - // delete ec; -} -}//end of namespace +void fci_driver(tamm::ExecutionContext& ec, ChemEnv& chem_env); +} // namespace exachem::fci diff --git a/exachem/mp2/cd_mp2.cpp b/exachem/mp2/cd_mp2.cpp index ac8f482..44ca061 100644 --- a/exachem/mp2/cd_mp2.cpp +++ b/exachem/mp2/cd_mp2.cpp @@ -6,9 +6,9 @@ * See LICENSE.txt for details */ -// #include "cc/ccsd/ccsd_util.hpp" +// #include "exachem/cc/ccsd/ccsd_util.hpp" -#include "cd_mp2.hpp" +#include "exachem/mp2/cd_mp2.hpp" #include namespace exachem::mp2 { diff --git a/exachem/mp2/cd_mp2.hpp b/exachem/mp2/cd_mp2.hpp index 38037e4..4ef6772 100644 --- a/exachem/mp2/cd_mp2.hpp +++ b/exachem/mp2/cd_mp2.hpp @@ -6,8 +6,8 @@ * See LICENSE.txt for details */ -#include "cholesky/cholesky_2e.hpp" -#include "cholesky/cholesky_2e_driver.hpp" +#include "exachem/cholesky/cholesky_2e.hpp" +#include "exachem/cholesky/cholesky_2e_driver.hpp" #include "tamm/eigen_utils.hpp" namespace exachem::mp2 { diff --git a/exachem/task/ec_task.cpp b/exachem/task/ec_task.cpp new file mode 100644 index 0000000..5c46094 --- /dev/null +++ b/exachem/task/ec_task.cpp @@ -0,0 +1,57 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#include "exachem/task/ec_task.hpp" + +namespace exachem::task { + +void ec_execute_task(ExecutionContext& ec, ChemEnv& chem_env, std::string ec_arg2) { + const auto task = chem_env.ioptions.task_options; + const auto input_file = chem_env.input_file; + + if(ec.print()) { + std::cout << std::endl << std::string(60, '-') << std::endl; + for(auto ecatom: chem_env.ec_atoms) { + std::cout << std::setw(3) << std::left << ecatom.esymbol << " " << std::right << std::setw(14) + << std::fixed << std::setprecision(10) << ecatom.atom.x << " " << std::right + << std::setw(14) << std::fixed << std::setprecision(10) << ecatom.atom.y << " " + << std::right << std::setw(14) << std::fixed << std::setprecision(10) + << ecatom.atom.z << std::endl; + } + } + + if(task.sinfo) chem_env.sinfo(); + else if(task.scf) { + scf::scf_driver(ec, chem_env); + Tensor::deallocate(chem_env.C_AO, chem_env.F_AO); + if(chem_env.sys_data.is_unrestricted) + Tensor::deallocate(chem_env.C_beta_AO, chem_env.F_beta_AO); + } +#if defined(ENABLE_CC) + else if(task.mp2) mp2::cd_mp2(ec, chem_env); + else if(task.cd_2e) cholesky_2e::cholesky_decomp_2e(ec, chem_env); + else if(task.ccsd) { cc::ccsd::cd_ccsd(ec, chem_env); } + else if(task.ccsd_t) cc::ccsd_t::ccsd_t_driver(ec, chem_env); + else if(task.cc2) cc2::cd_cc2_driver(ec, chem_env); + else if(task.ccsd_lambda) cc::ccsd_lambda::ccsd_lambda_driver(ec, chem_env); + else if(task.eom_ccsd) cc::eom::eom_ccsd_driver(ec, chem_env); + else if(task.ducc) cc::ducc::ducc_driver(ec, chem_env); +#if !defined(USE_UPCXX) and defined(EC_COMPLEX) + else if(task.fci || task.fcidump) fci::fci_driver(ec, chem_env); + else if(task.gfccsd) cc::gfcc::gfccsd_driver(ec, chem_env); + else if(task.rteom_ccsd) rteom_cc::ccsd::rt_eom_cd_ccsd_driver(ec, chem_env); +#endif + +#endif + + else + tamm_terminate( + "[ERROR] Unsupported task specified (or) code for the specified task is not built"); +} + +} // namespace exachem::task \ No newline at end of file diff --git a/exachem/task/ec_task.hpp b/exachem/task/ec_task.hpp new file mode 100644 index 0000000..c5eb1ec --- /dev/null +++ b/exachem/task/ec_task.hpp @@ -0,0 +1,39 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#pragma once + +#define EC_COMPLEX + +// clang-format off +#if defined(ENABLE_CC) +#include "exachem/cc/ccsd/cd_ccsd_os_ann.hpp" +//#include "exachem/cc/ccsd/ccsd_canonical.hpp" +#include "exachem/cc/ccsd_t/ccsd_t_fused_driver.hpp" +#include "exachem/cc/lambda/ccsd_lambda.hpp" +#include "exachem/cc/eom/eomccsd_opt.hpp" +#include "exachem/cc/ducc/ducc-t_ccsd.hpp" +#include "exachem/cc/cc2/cd_cc2.hpp" +#endif + +#include "exachem/common/chemenv.hpp" +#include "exachem/common/options/parse_options.hpp" +#include "exachem/scf/scf_main.hpp" +#include "exachem/mp2/cd_mp2.hpp" +// clang-format on +using namespace exachem; + +#if !defined(USE_UPCXX) and defined(EC_COMPLEX) and defined(ENABLE_CC) +#include "exachem/cc/gfcc/gfccsd.hpp" +#include "exachem/cc/rteom/rt_eom_cd_ccsd.hpp" +#include "exachem/fci/fci.hpp" +#endif + +namespace exachem::task { +void ec_execute_task(ExecutionContext& ec, ChemEnv& chem_env, std::string ec_arg2); +} \ No newline at end of file diff --git a/exachem/task/task.cmake b/exachem/task/task.cmake new file mode 100644 index 0000000..05f9e60 --- /dev/null +++ b/exachem/task/task.cmake @@ -0,0 +1,13 @@ + +include(TargetMacros) + +set(TASK_SRCDIR task) + +set(TASK_INCLUDES + ${TASK_SRCDIR}/ec_task.hpp + ) + +set(TASK_SRCS + ${TASK_SRCDIR}/ec_task.cpp + ) + diff --git a/methods/CMakeLists.txt b/methods/CMakeLists.txt index 386cf1f..5dbf451 100644 --- a/methods/CMakeLists.txt +++ b/methods/CMakeLists.txt @@ -3,33 +3,9 @@ project(ExaChem-Binary VERSION 0.0.0 LANGUAGES CXX) find_package(EXACHEM REQUIRED) include(TargetMacros) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) +# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) set(EXACHEM_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../exachem) - -option(EC_COMPLEX "enable complex codes" ON) - -#TODO: cleanup -include_directories(${EXACHEM_SRC_DIR}) - -list(FIND MODULES "CC" _cc_index) - -if(NOT _cc_index EQUAL -1) - message(STATUS "Compiling CC modules") - include(${EXACHEM_SRC_DIR}/cc/eom/eom.cmake) - include(${EXACHEM_SRC_DIR}/cc/lambda/lambda.cmake) - include(${EXACHEM_SRC_DIR}/cc/ducc/ducc.cmake) - - if(NOT USE_UPCXX AND EC_COMPLEX) - include(${EXACHEM_SRC_DIR}/cc/gfcc/gfcc.cmake) - include(${EXACHEM_SRC_DIR}/cc/rteom/rteom.cmake) - endif() - - set(CoupledCluster_SRCS ${CCSDT_SRCS} ${CC_LAMBDA_SRCS} ${CC_EOM_SRCS} - ${GFCC_SRCS} ${RTEOM_SRCS} ${DUCC_SRCS}) - -endif() - -set(EXACHEM_SRCS ${CoupledCluster_SRCS}) +set(EXACHEM_SRCS ${EXACHEM_SRC_DIR}/exachem.cpp) add_mpi_gpu_unit_test(ExaChem "${EXACHEM_SRCS}" 2 "${CMAKE_SOURCE_DIR}/../inputs/h2o.json") diff --git a/methods/ExaChem.cpp b/methods/ExaChem.cpp index affb843..4f2c602 100644 --- a/methods/ExaChem.cpp +++ b/methods/ExaChem.cpp @@ -7,44 +7,9 @@ */ #include +#include #include -#define EC_COMPLEX - -// clang-format off -#if defined(ENABLE_CC) -#include "cc/ccsd/cd_ccsd_os_ann.hpp" -#include "cc/ccsd_t/ccsd_t_fused_driver.hpp" -#include "exachem/cc/lambda/ccsd_lambda.hpp" -#include "exachem/cc/eom/eomccsd_opt.hpp" -#endif - -#include "exachem/common/chemenv.hpp" -#include "exachem/common/options/parse_options.hpp" -#include "exachem/scf/scf_main.hpp" -#include "mp2/cd_mp2.hpp" -// clang-format on -using namespace exachem; - -#if !defined(USE_UPCXX) and defined(EC_COMPLEX) and defined(ENABLE_CC) -namespace exachem::cc::gfcc { -void gfccsd_driver(ExecutionContext& ec, ChemEnv& chem_env); -} -namespace exachem::rteom_cc::ccsd { -void rt_eom_cd_ccsd_driver(ExecutionContext& ec, ChemEnv& chem_env); -} -#include "exachem/fci/fci.hpp" -#endif - -#if defined(ENABLE_CC) -namespace exachem::cc2 { -void cd_cc2_driver(ExecutionContext& ec, ChemEnv& chem_env); -} -namespace exachem::cc::ducc { -void ducc_driver(ExecutionContext& ec, ChemEnv& chem_env); -} -#endif - int main(int argc, char* argv[]) { tamm::initialize(argc, argv); @@ -159,6 +124,7 @@ int main(int argc, char* argv[]) { task.cd_2e, task.ducc, task.ccsd, + task.ccsdt, task.ccsd_t, task.ccsd_lambda, task.eom_ccsd, @@ -188,34 +154,9 @@ int main(int argc, char* argv[]) { chem_env.shells = chem_env.ec_basis.shells; chem_env.sys_data.has_ecp = chem_env.ec_basis.has_ecp; - if(task.sinfo) chem_env.sinfo(); - else if(task.scf) { - scf::scf_driver(ec, chem_env); - Tensor::deallocate(chem_env.C_AO, chem_env.F_AO); - if(chem_env.sys_data.is_unrestricted) - Tensor::deallocate(chem_env.C_beta_AO, chem_env.F_beta_AO); - } -#if defined(ENABLE_CC) - else if(task.mp2) mp2::cd_mp2(ec, chem_env); - else if(task.cd_2e) cholesky_2e::cholesky_decomp_2e(ec, chem_env); - else if(task.ccsd) cc::ccsd::cd_ccsd(ec, chem_env); - else if(task.ccsd_t) cc::ccsd_t::ccsd_t_driver(ec, chem_env); - else if(task.cc2) cc2::cd_cc2_driver(ec, chem_env); - else if(task.ccsd_lambda) cc::ccsd_lambda::ccsd_lambda_driver(ec, chem_env); - else if(task.eom_ccsd) cc::eom::eom_ccsd_driver(ec, chem_env); - else if(task.ducc) cc::ducc::ducc_driver(ec, chem_env); -#if !defined(USE_UPCXX) and defined(EC_COMPLEX) - else if(task.fci || task.fcidump) fci::fci_driver(ec, chem_env); - else if(task.gfccsd) cc::gfcc::gfccsd_driver(ec, chem_env); - else if(task.rteom_ccsd) rteom_cc::ccsd::rt_eom_cd_ccsd_driver(ec, chem_env); -#endif - -#endif + exachem::task::ec_execute_task(ec, chem_env, ec_arg2); - else - tamm_terminate( - "[ERROR] Unsupported task specified (or) code for the specified task is not built"); - } + } // loop over input files ec.flush_and_sync(); ec.pg().destroy_coll();