Skip to content

Commit

Permalink
Make C-interface a build time option
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlucf22 committed Dec 11, 2023
1 parent 746578f commit b761a0d
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 56 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
Expand All @@ -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}
Expand Down
45 changes: 24 additions & 21 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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})
5 changes: 3 additions & 2 deletions scripts/build_crusher_rocsparse_cce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
11 changes: 8 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
64 changes: 34 additions & 30 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b761a0d

Please sign in to comment.