Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Fortuno #59

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ include(GNUInstallDirs)
add_subdirectory(lib)
include(CTest) # note: this adds a BUILD_TESTING which defaults to ON
if(BUILD_TESTING)
include(FetchContent)
include(subprojects/Fortuno.cmake)
enable_testing()
add_subdirectory(test)
endif()
Expand Down
5 changes: 3 additions & 2 deletions cmake/MpiFxUtils.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Register custom commands for processing source files with fypp (.fpp -> .f90)
#
# Args:
# fyppflags [in]: Flags to use when invoking the fypp preprocessor (using ${FYPP})
# oldfiles [in]: List of files to preprocess (must have .fpp suffix)
# newfiles [out]: List of preprocessed files (will have .f90 suffix).
#
function(fypp_preprocess oldfiles newfiles)
function(fypp_preprocess fyppflags oldfiles newfiles)

set(_newfiles)
foreach(oldfile IN LISTS oldfiles)
string(REGEX REPLACE "\\.fpp" ".f90" newfile ${oldfile})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${newfile}
COMMAND ${FYPP} ${FYPP_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${oldfile} ${CMAKE_CURRENT_BINARY_DIR}/${newfile}
COMMAND ${FYPP} ${fyppflags} ${CMAKE_CURRENT_SOURCE_DIR}/${oldfile} ${CMAKE_CURRENT_BINARY_DIR}/${newfile}
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${oldfile})
list(APPEND _newfiles ${CMAKE_CURRENT_BINARY_DIR}/${newfile})
endforeach()
Expand Down
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set(sources-fpp
mpifx_send.fpp
mpifx_win.fpp)

fypp_preprocess("${sources-fpp}" sources-f90)
fypp_preprocess("${FYPP_FLAGS}" "${sources-fpp}" sources-f90)

# Some MPI frameworks (e.g. MPICH) do not provide all possible argument
# combinations explicitely in their mpi module. Consequently, compilers
Expand Down
2 changes: 0 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ if install
install_dir: get_option('datadir')/'licenses'/meson.project_name()
)
endif

subdir('test')
27 changes: 27 additions & 0 deletions subprojects/Fortuno.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Variables influencing how subproject is obtained
set(CMAKE_REQUIRE_FIND_PACKAGE_Fortuno ${MYPROJECT_SUBPROJECT_REQUIRE_FIND})
set(CMAKE_DISABLE_FIND_PACKAGE_Fortuno ${MYPROJECT_SUBPROJECT_DISABLE_FIND})
# set FETCHCONTENT_SOURCE_DIR_FORTUNO to use a local source of the subproject

# Subproject related variables
option(
FORTUNO_BUILD_SHARED_LIBS "Fortuno: Build as shared library" ${MYPROJECT_BUILD_SHARED_LIBS}
)
option(FORTUNO_WITH_MPI "Fortuno: Whether mpi interface should be built" ON)

# Make subproject available
FetchContent_Declare(
Fortuno
# GIT_REPOSITORY "https://github.com/fortuno-repos/fortuno.git"
# GIT_TAG "main"
GIT_REPOSITORY "https://github.com/aradi/fortuno.git"
GIT_TAG "isequal"
FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(Fortuno)

if (Fortuno_FOUND)
message(STATUS "Subproject Fortuno: using installed version")
else ()
message(STATUS "Subproject Fortuno: building from source in ${Fortuno_SOURCE_DIR}")
endif ()
44 changes: 1 addition & 43 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1 @@
set(tested
test_allgather
test_allgatherv)

set(targets
${tested}
test_allreduce
test_bcast
test_comm_split
test_comm_split_type
test_gather
test_gatherv
test_reduce
test_scatter
test_scatterv
test_win_shared_mem)

set(sources-helper
testhelper.f90)

add_library(mpifxtesthelp ${sources-helper})
target_link_libraries(mpifxtesthelp PRIVATE MPI::MPI_Fortran MpiFx)

foreach(target IN LISTS targets)
add_executable(${target} ${target}.f90)
target_link_libraries(${target} MpiFx mpifxtesthelp)
endforeach()

foreach(target IN LISTS tested)
add_test(NAME ${target}
COMMAND ${MPIEXEC_EXECUTABLE}
${MPIEXEC_NUMPROC_FLAG}
${MPIEXEC_MAX_NUMPROCS}
${MPIEXEC_PREFLAGS}
${CMAKE_CURRENT_BINARY_DIR}/${target}
${MPIEXEC_POSTFLAGS})
set_tests_properties(${target} PROPERTIES
# test cases generate this on stdOut
PASS_REGULAR_EXPRESSION "TestPASSED")
set_tests_properties(${target} PROPERTIES
# test cases generate this on stdOut
FAIL_REGULAR_EXPRESSION "TestFAILED")
endforeach()
add_subdirectory(unit)
24 changes: 0 additions & 24 deletions test/meson.build

This file was deleted.

69 changes: 0 additions & 69 deletions test/test_allgather.f90

This file was deleted.

116 changes: 0 additions & 116 deletions test/test_allgatherv.f90

This file was deleted.

42 changes: 0 additions & 42 deletions test/test_allreduce.f90

This file was deleted.

Loading