From 4af28a0d5d35f8c2557697ffff636b7cdce6059c Mon Sep 17 00:00:00 2001 From: Jean-Luc Fattebert Date: Mon, 11 Dec 2023 15:24:42 -0500 Subject: [PATCH] Make C-interface a build time option --- CMakeLists.txt | 6 +++ build.sh | 2 + examples/CMakeLists.txt | 45 +++++++++--------- scripts/build_crusher_rocsparse_cce.sh | 5 +- src/CMakeLists.txt | 11 +++-- tests/CMakeLists.txt | 64 ++++++++++++++------------ 6 files changed, 77 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a23be714..74032a63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,6 +195,12 @@ if(DOXYGEN_FOUND) add_dependencies(docs docs-progress) endif(DOXYGEN_FOUND) +set(PROGRESS_CINTERFACE FALSE + CACHE BOOL "Whether to build C interface.") +if(PROGRESS_CINTERFACE) + message(STATUS "Build C interface") +endif() + set(PROGRESS_TESTING FALSE CACHE BOOL "Whether to build the test suite.") diff --git a/build.sh b/build.sh index 1173a0ea..cfc1d45b 100755 --- a/build.sh +++ b/build.sh @@ -37,6 +37,7 @@ EOF echo "FC Path to Fortran compiler (default is ${FC})" echo "PROGRESS_OPENMP {yes,no} (default is ${PROGRESS_OPENMP})" echo "PROGRESS_MPI {yes,no} (default is ${PROGRESS_MPI})" + echo "PROGRESS_CINTERFACE{yes,no} (default is ${PROGRESS_CINTERFACE})" echo "PROGRESS_TESTING {yes,no} (default is ${PROGRESS_TESTING})" echo "PROGRESS_EXAMPLES {yes,no} (default is ${PROGRESS_EXAMPLES})" echo "PROGRESS_BENCHMARKS {yes,no} (default is ${PROGRESS_BENCHMARKS})" @@ -60,6 +61,7 @@ set_defaults() { : ${FC:=gfortran} : ${PROGRESS_OPENMP:=yes} : ${PROGRESS_MPI:=no} + : ${PROGRESS_CINTERFACE:=yes} : ${PROGRESS_TESTING:=no} : ${PROGRESS_EXAMPLES:=no} : ${PROGRESS_BENCHMARKS:=no} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8f44a914..1bb2df7e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,28 +26,29 @@ function(progress_example myexample path_to_example) endfunction(progress_example) -function(progress_c_example myexample path_to_example) - add_executable(${myexample} ${path_to_example}) - target_link_libraries(${myexample} PUBLIC - progress - ${LINK_LIBRARIES}) - set_target_properties(${myexample} - PROPERTIES - LINK_FLAGS "--coverage") - if(OPENMP_FOUND) - set_target_properties(${myexample} - PROPERTIES - COMPILE_FLAGS ${OpenMP_C_FLAGS} - LINK_FLAGS ${OpenMP_C_FLAGS}) - endif() - if(MPI_C_FOUND AND MPI_C_COMPILE_FLAGS) +if(PROGRESS_CINTERFACE) + function(progress_c_example myexample path_to_example) + add_executable(${myexample} ${path_to_example}) + target_link_libraries(${myexample} PUBLIC + progress + ${LINK_LIBRARIES}) set_target_properties(${myexample} PROPERTIES - COMPILE_FLAGS ${MPI_C_COMPILE_FLAGS} - LINK_FLAGS ${MPI_C_LINK_FLAGS}) - endif() -endfunction(progress_c_example) - + LINK_FLAGS "--coverage") + if(OPENMP_FOUND) + set_target_properties(${myexample} + PROPERTIES + COMPILE_FLAGS ${OpenMP_C_FLAGS} + LINK_FLAGS ${OpenMP_C_FLAGS}) + endif() + if(MPI_C_FOUND AND MPI_C_COMPILE_FLAGS) + set_target_properties(${myexample} + PROPERTIES + COMPILE_FLAGS ${MPI_C_COMPILE_FLAGS} + LINK_FLAGS ${MPI_C_LINK_FLAGS}) + endif() + endfunction(progress_c_example) +endif() progress_example(changecoords changecoords/changecoords.F90) @@ -67,6 +68,8 @@ progress_example(replicate replicate/replicate.F90) progress_example(sp2run sp2run/src/main.F90) progress_example(scf scf/src/main.F90) progress_example(mdresponse mdresponse/mdresponse.F90) -progress_c_example(cinterface c_interface/progress.c) +if(PROGRESS_CINTERFACE) + progress_c_example(cinterface c_interface/progress.c) +endif() SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}) diff --git a/scripts/build_crusher_rocsparse_cce.sh b/scripts/build_crusher_rocsparse_cce.sh index 79f4c509..e0bb708e 100755 --- a/scripts/build_crusher_rocsparse_cce.sh +++ b/scripts/build_crusher_rocsparse_cce.sh @@ -15,9 +15,10 @@ export BML_OPENMP=yes export PROGRESS_OPENMP=${PROGRESS_OPENMP:=yes} export INSTALL_DIR=${INSTALL_DIR:="${MY_PATH}/install"} export PROGRESS_GRAPHLIB=${PROGRESS_GRAPHLIB:=no} -export PROGRESS_TESTING=${PROGRESS_TESTING:=no} +export PROGRESS_TESTING=${PROGRESS_TESTING:=yes} export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=RelWithDebInfo} -export PROGRESS_EXAMPLES=${PROGRESS_EXAMPLES:=no} +export PROGRESS_EXAMPLES=${PROGRESS_EXAMPLES:=yes} +export PROGRESS_CINTERFACE=${PROGRESS_CINTERFACE:=no} export PROGRESS_BENCHMARKS=${PROGRESS_BENCHMARKS:=yes} export EXTRA_FCFLAGS="-hsystem_alloc" export EXTRA_LINK_FLAGS="" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 89dec935..4f69bd96 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,7 +51,7 @@ set(PROGRESS_SOURCES prg_graphsolver_mod.F90 prg_xlbokernel_mod.F90) -if(NOT (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")) +if(PROGRESS_CINTERFACE) set(PROGRESS_SOURCES ${PROGRESS_SOURCES} prg_c_interface.F90) endif() @@ -142,7 +142,12 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/prg_graphsolver_mod.mod ${CMAKE_CURRENT_BINARY_DIR}/slaterkosterforce_latte_mod.mod ${CMAKE_CURRENT_BINARY_DIR}/tbparams_latte_mod.mod - ${CMAKE_CURRENT_BINARY_DIR}/prg_c_interface.mod - #${CMAKE_CURRENT_BINARY_DIR}/prg_densitymatrix_mod_c.mod ${CMAKE_CURRENT_SOURCE_DIR}/prg_progress_mod.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +if(PROGRESS_CINTERFACE) + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/prg_c_interface.mod + #${CMAKE_CURRENT_BINARY_DIR}/prg_densitymatrix_mod_c.mod + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 07599e2e..439e86f1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,9 +10,11 @@ add_executable(main target_link_libraries(main progress ${LINK_LIBRARIES}) -add_executable(main_c - src/main.c) -target_link_libraries(main_c progress ${LINK_LIBRARIES}) +if(PROGRESS_CINTERFACE) + add_executable(main_c + src/main.c) + target_link_libraries(main_c progress ${LINK_LIBRARIES}) +endif() set_target_properties(main PROPERTIES @@ -102,33 +104,35 @@ if(PROGRESS_GRAPHLIB) progress_test(prg_build_zmatGP) endif() -# c test modules -progress_test(prg_density_cheb_fermi_c) -progress_test(prg_density_c) -progress_test(prg_density_T_c) -progress_test(prg_density_T_fermi_c) -progress_test(prg_density_T_fermi_grad_c) -# implicit fermi -progress_test(prg_implicit_fermi_c) -progress_test(prg_implicit_fermi_save_inverse_c) -# sp2 -progress_test(prg_sp2_basic_c) -progress_test(prg_sp2_alg1_dense_c) -progress_test(prg_sp2_alg2_dense_c) -progress_test(prg_sp2_alg1_ellpack_c) -progress_test(prg_sp2_alg2_ellpack_c) -progress_test(prg_sp2_alg2_ellpack_poly_c) -progress_test(prg_sp2_alg1_seq_dense_c) -progress_test(prg_sp2_alg2_seq_dense_c) -progress_test(prg_sp2_alg1_seq_ellpack_c) -progress_test(prg_sp2_alg2_seq_ellpack_c) -progress_test(prg_sp2_alg1_seq_inplace_dense_c) -progress_test(prg_sp2_alg2_seq_inplace_dense_c) -progress_test(prg_sp2_alg1_seq_inplace_ellpack_c) -progress_test(prg_sp2_alg2_seq_inplace_ellpack_c) -progress_test(prg_sp2_fermi_dense_c) -progress_test(prg_pulaycomponent0_c) -# graph +if(PROGRESS_CINTERFACE) + # c test modules + progress_test(prg_density_cheb_fermi_c) + progress_test(prg_density_c) + progress_test(prg_density_T_c) + progress_test(prg_density_T_fermi_c) + progress_test(prg_density_T_fermi_grad_c) + # implicit fermi + progress_test(prg_implicit_fermi_c) + progress_test(prg_implicit_fermi_save_inverse_c) + # sp2 + progress_test(prg_sp2_basic_c) + progress_test(prg_sp2_alg1_dense_c) + progress_test(prg_sp2_alg2_dense_c) + progress_test(prg_sp2_alg1_ellpack_c) + progress_test(prg_sp2_alg2_ellpack_c) + progress_test(prg_sp2_alg2_ellpack_poly_c) + progress_test(prg_sp2_alg1_seq_dense_c) + progress_test(prg_sp2_alg2_seq_dense_c) + progress_test(prg_sp2_alg1_seq_ellpack_c) + progress_test(prg_sp2_alg2_seq_ellpack_c) + progress_test(prg_sp2_alg1_seq_inplace_dense_c) + progress_test(prg_sp2_alg2_seq_inplace_dense_c) + progress_test(prg_sp2_alg1_seq_inplace_ellpack_c) + progress_test(prg_sp2_alg2_seq_inplace_ellpack_c) + progress_test(prg_sp2_fermi_dense_c) + progress_test(prg_pulaycomponent0_c) + # graph +endif() # LATTE modules progress_test(load_tbparms_latte)