Skip to content

Commit

Permalink
Merge pull request #82 from FluidNumerics/bugfix/parallel-builds
Browse files Browse the repository at this point in the history
Bugfix/parallel builds
  • Loading branch information
fluidnumerics-joe authored Nov 25, 2024
2 parents 3b30551 + 336f4bb commit 2024f39
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-amdflang-cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DSELF_MPIEXEC_NUMPROCS=2 \
../
make VERBOSE=1
make -j $(nproc) VERBOSE=1
- name: Run ctests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-gnu-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DSELF_MPIEXEC_NUMPROCS=2 \
../
make VERBOSE=1
make -j $(nproc) VERBOSE=1
- name: Initialize coverage counters
if: ${{ matrix.build_type == 'coverage' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-gnu-multithreaded-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
-DSELF_MULTITHREADING_NTHREADS=4 \
-DSELF_MPIEXEC_NUMPROCS=2 \
../
make VERBOSE=1
make -j $(nproc) VERBOSE=1
- name: Run ctests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-nvfortran-cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
cd build
FC=${{ env.FC }} CC=${{ env.CC }} \
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ../
make VERBOSE=1
make -j $(nproc) VERBOSE=1
- name: Run ctests
run: |
Expand Down
6 changes: 3 additions & 3 deletions .superci/armory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ steps:
cd ${WORKSPACE}/build
FC=gfortran \
CXX=hipcc \
cmake -DCMAKE_PREFIX_PATH=${ROCM_PATH} \
cmake -G Ninja \
-DCMAKE_PREFIX_PATH=${ROCM_PATH} \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DSELF_ENABLE_GPU=${ENABLE_GPU} \
Expand All @@ -43,8 +44,7 @@ steps:
-DSELF_ENABLE_DOUBLE_PRECISION=${ENABLE_DOUBLE_PRECISION} \
-DCMAKE_HIP_ARCHITECTURE=${GPU_ARCH} \
../
make VERBOSE=1
make install
ninja
# Initialize coverage
Expand Down
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

cmake_minimum_required(VERSION 3.21)
cmake_policy(VERSION 3.21...3.27)

# C Language is needed in order to verify Fortran compiler is C-interoperable
# CXX language is needed to properly find "hip" package
project(SELF VERSION 1.0.0
DESCRIPTION "Spectral Element Library in Fortran"
LANGUAGES Fortran C CXX)


option(SELF_ENABLE_MULTITHREADING "Option to enable CPU multithreading for `do concurrent` loop blocks." OFF)
option(SELF_ENABLE_TESTING "Option to enable build of tests. (Default On)" ON)
option(SELF_ENABLE_EXAMPLES "Option to enable build of examples. (Default On)" ON)
Expand All @@ -48,11 +56,6 @@ if(NOT DEFINED ROCM_PATH)
endif()
endif()

# C Language is needed in order to verify Fortran compiler is C-interoperable
# CXX language is needed to properly find "hip" package
project(self VERSION 1.0.0
DESCRIPTION "Spectral Element Library in Fortran"
LANGUAGES Fortran C CXX)

# Fortran compiler requirements
include(FortranCInterface)
Expand Down Expand Up @@ -241,7 +244,7 @@ endif()

# Libraries
add_subdirectory(${CMAKE_SOURCE_DIR}/src)

# link_directories(${CMAKE_BINARY_DIR}/src)

if(SELF_ENABLE_TESTING)
enable_testing()
Expand Down
30 changes: 6 additions & 24 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,9 @@ function (add_fortran_tests)
foreach (TFILE ${ARGN})
string (REGEX REPLACE ".f90$" "" TEST_NAME ${TFILE})
add_executable (${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TFILE})
target_link_libraries(${TEST_NAME}
${CMAKE_BINARY_DIR}/src/libself-static.a
${FEQPARSE_LIBRARIES}
${HDF5_LIBRARIES}
${MPI_Fortran_LIBRARIES}
${BACKEND_LIBRARIES})

target_include_directories(${TEST_NAME} PRIVATE
${CMAKE_BINARY_DIR}/include
${FEQPARSE_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${MPI_Fortran_INCLUDE_DIRS})
add_dependencies(${TEST_NAME} self)
target_link_libraries(${TEST_NAME} self)
target_include_directories(${TEST_NAME} PUBLIC ${CMAKE_BINARY_DIR}/include)

add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
install(TARGETS ${TEST_NAME} DESTINATION test)
Expand All @@ -58,18 +49,9 @@ function (add_mpi_fortran_tests)
foreach (TFILE ${ARGN})
string (REGEX REPLACE ".f90$" "" TEST_NAME ${TFILE})
add_executable (${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TFILE})
target_link_libraries(${TEST_NAME}
${CMAKE_BINARY_DIR}/src/libself-static.a
${FEQPARSE_LIBRARIES}
${HDF5_LIBRARIES}
${MPI_Fortran_LIBRARIES}
${BACKEND_LIBRARIES})

target_include_directories(${TEST_NAME} PRIVATE
${CMAKE_BINARY_DIR}/include
${FEQPARSE_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${MPI_Fortran_INCLUDE_DIRS})
add_dependencies(${TEST_NAME} self)
target_link_libraries(${TEST_NAME} self)
target_include_directories(${TEST_NAME} PUBLIC ${CMAKE_BINARY_DIR}/include)

add_test(NAME ${TEST_NAME} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${SELF_MPIEXEC_NUMPROCS} ${SELF_MPIEXEC_OPTIONS} ${TEST_NAME})

Expand Down
6 changes: 3 additions & 3 deletions examples/linear_euler2d_planewave_propagation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!
! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// !
module lineareuler2d_planewave_model
module lineareuler2d_planewave_prop_model
!! This module can be used for simulating plane wave propagation in a 2-D domain
!! We use a type extension of the linearEuler2D class to add parameters for a simple
!! plane wave solution, including the x and y wave numbers and the peak pressure.
Expand Down Expand Up @@ -110,12 +110,12 @@ pure function hbc2d_Prescribed_lineareuler2d_planewave(this,x,t) result(exts)

endfunction hbc2d_Prescribed_lineareuler2d_planewave

endmodule lineareuler2d_planewave_model
endmodule lineareuler2d_planewave_prop_model

program LinearEuler_Example

use self_data
use lineareuler2d_planewave_model
use lineareuler2d_planewave_prop_model

implicit none
character(SELF_INTEGRATOR_LENGTH),parameter :: integrator = 'rk3'
Expand Down
24 changes: 10 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,27 @@ set_source_files_properties(

set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)

# add_library(self SHARED ${SELF_FSRC} ${SELF_HIPSRC})
# target_link_libraries(self PRIVATE ${libfeqparse} HDF5::HDF5 ${MPI_Fortran_LIBRARIES})
# target_include_directories(self PRIVATE ${incfeqparse} ${HDF5_INCLUDE_DIRS} ${MPI_Fortran_INCLUDE_DIRS})
# target_compile_options(self PRIVATE -fPIC)

add_library(self-static STATIC ${SELF_FSRC} ${SELF_BACKEND_CPPSRC} ${SELF_BACKEND_FSRC})

target_link_libraries(self-static PRIVATE
add_library(self SHARED ${SELF_FSRC} ${SELF_BACKEND_CPPSRC} ${SELF_BACKEND_FSRC})
#set_target_properties(self PROPERTIES OUTPUT_NAME "self")
target_link_libraries(self PUBLIC
${FEQPARSE_LIBRARIES}
HDF5::HDF5
${MPI_Fortran_LIBRARIES}
${BACKEND_LIBRARIES})

target_include_directories(self-static PRIVATE
target_include_directories(self PUBLIC
${FEQPARSE_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${MPI_Fortran_INCLUDE_DIRS})

set_target_properties(self-static PROPERTIES LINKER_LANGUAGE Fortran)
set_target_properties(self-static PROPERTIES PUBLIC_HEADER ${SELF_HEADERS})

install(TARGETS self-static
target_compile_options(self PUBLIC -fPIC)

set_target_properties(self PROPERTIES LINKER_LANGUAGE Fortran)
set_target_properties(self PROPERTIES PUBLIC_HEADER ${SELF_HEADERS})

install(TARGETS self
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include)


install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION include)
32 changes: 6 additions & 26 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,9 @@ function (add_fortran_tests)
foreach (TFILE ${ARGN})
string (REGEX REPLACE ".f90$" "" TEST_NAME ${TFILE})
add_executable (${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TFILE})
target_link_libraries(${TEST_NAME}
${CMAKE_BINARY_DIR}/src/libself-static.a
${FEQPARSE_LIBRARIES}
${HDF5_LIBRARIES}
${MPI_Fortran_LIBRARIES}
${BACKEND_LIBRARIES})

target_include_directories(${TEST_NAME} PRIVATE
${CMAKE_BINARY_DIR}/include
${FEQPARSE_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${MPI_Fortran_INCLUDE_DIRS})

add_dependencies(${TEST_NAME} self)
target_link_libraries(${TEST_NAME} self)
target_include_directories(${TEST_NAME} PUBLIC ${CMAKE_BINARY_DIR}/include)
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
install(TARGETS ${TEST_NAME} DESTINATION test)
endforeach ()
Expand All @@ -58,19 +48,9 @@ function (add_mpi_fortran_tests)
foreach (TFILE ${ARGN})
string (REGEX REPLACE ".f90$" "" TEST_NAME ${TFILE})
add_executable (${TEST_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TFILE})
target_link_libraries(${TEST_NAME}
${CMAKE_BINARY_DIR}/src/libself-static.a
${FEQPARSE_LIBRARIES}
${HDF5_LIBRARIES}
${MPI_Fortran_LIBRARIES}
${BACKEND_LIBRARIES})

target_include_directories(${TEST_NAME} PRIVATE
${CMAKE_BINARY_DIR}/include
${FEQPARSE_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${MPI_Fortran_INCLUDE_DIRS})

add_dependencies(${TEST_NAME} self)
target_link_libraries(${TEST_NAME} self)
target_include_directories(${TEST_NAME} PUBLIC ${CMAKE_BINARY_DIR}/include)
add_test(NAME ${TEST_NAME} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${SELF_MPIEXEC_NUMPROCS} ${SELF_MPIEXEC_OPTIONS} ${TEST_NAME})

install(TARGETS ${TEST_NAME} DESTINATION test)
Expand Down

0 comments on commit 2024f39

Please sign in to comment.