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

Fix parallel build issues #788

Merged
merged 7 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_subdirectory(application-binary-interface )
add_subdirectory(runtime-libraries )
add_subdirectory(application-binary-interface)
add_subdirectory(runtime-libraries)
add_subdirectory(tests)

set(N_CPU ${N_CPU} PARENT_SCOPE)
Expand Down
41 changes: 17 additions & 24 deletions src/script-templates/caf.in
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,13 @@ __caf_err_report() {
trap '__caf_err_report "${FUNCNAME:-.}" ${LINENO}' ERR

# See if we are compiling or compiling and/or linking
__only_compiling () {
rouson marked this conversation as resolved.
Show resolved Hide resolved
for arg in "${@}"; do
if [[ "${arg}" == "-c" ]]; then
return 0
fi
done
return 1
}
with_link="true"
for arg in "${@}"; do
if [[ "${arg}" == "-c" || "${arg}" == "-cpp" ]]; then
rouson marked this conversation as resolved.
Show resolved Hide resolved
with_link="false"
break
fi
done

#--------------------------------------------------------------------------
# End configured variables, now process them and build compile/link command
Expand Down Expand Up @@ -223,16 +222,14 @@ if [[ -n "${mpi_compile_flags[*]:-}" ]]; then
caf_pre_flags+=("${compileflag}")
done
fi
if [[ -n "${mpi_link_flags[*]:-}" ]]; then
if ! __only_compiling "${@}"; then
for linkflag in "${mpi_link_flags[@]:-}"; do
caf_pre_flags+=("${linkflag}")
done
fi
if [[ -n "${mpi_link_flags[*]:-}" && "${with_link}" == "true" ]]; then
for linkflag in "${mpi_link_flags[@]:-}"; do
caf_pre_flags+=("${linkflag}")
done
fi

# Now do libraries, IN CORRECT ORDER, to append to command
if [[ -n "${caf_libs[*]:-}" ]]; then
if [[ "${with_link}" == "true" && -n "${caf_libs[*]:-}" ]]; then
for lib in "${caf_libs[@]:-}"; do
caf_added_libs+=("$(substitute_lib "${prefix%/}/${lib}")")
done
Expand All @@ -242,7 +239,7 @@ if [[ -n "${threads_lib}" ]]; then
caf_added_libs+=("${threads_lib}")
fi

if [[ -n "${mpi_libs[*]:-}" ]]; then
if [[ "${with_link}" == "true" && -n "${mpi_libs[*]:-}" ]]; then
for lib in "${mpi_libs[@]:-}"; do
caf_added_libs+=("$(substitute_lib "${lib}")")
done
Expand Down Expand Up @@ -330,10 +327,8 @@ elif [[ ${1} == '-s' || ${1} == '--show' || ${1} == '-show' ]]; then
if [[ "${args}" ]]; then
compiler_args+=("${args}")
fi
if [[ "${caf_added_libs[*]:-}" ]]; then
if ! __only_compiling "${@}"; then
compiler_args+=("${caf_added_libs[@]}")
fi
if [[ "${caf_added_libs[*]:-}" && "${with_link}" == "true" ]]; then
compiler_args+=("${caf_added_libs[@]}")
fi
echo "${cafc}" "${compiler_args[@]}"
exit 0
Expand Down Expand Up @@ -365,10 +360,8 @@ fi
if [[ "${*:-}" ]]; then
compiler_args+=("${@}")
fi
if [[ "${caf_added_libs[*]:-}" ]]; then
if ! __only_compiling "${@}" ; then
compiler_args+=("${caf_added_libs[@]}")
fi
if [[ "${caf_added_libs[*]:-}" && "${with_link}" == "true" ]]; then
compiler_args+=("${caf_added_libs[@]}")
fi
#set -o xtrace # Show what we're doing
set +o errtrace
Expand Down
24 changes: 18 additions & 6 deletions src/tests/integration/pde_solvers/coarrayBurgers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ else()
endif()

set(CMAKE_Fortran_COMPILER "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/caf")
add_executable(coarray_burgers_pde
main.F90
global_field.F90
local_field.F90
add_library(cbp_base STATIC
${config_directory}/compiler_capabilities.txt
${library_directory}/ForTrilinos_assertion_utility.F90
${library_directory}/object_interface.F90
${library_directory}/co_object_interface.F90
)
add_dependencies(coarray_burgers_pde caf_mpi_static)
target_include_directories(coarray_burgers_pde PRIVATE ${config_directory})
add_library(cbp_local STATIC
${config_directory}/compiler_capabilities.txt
local_field.F90
)
add_executable(coarray_burgers_pde
${config_directory}/compiler_capabilities.txt
global_field.F90
main.F90
)
target_link_libraries(cbp_local PUBLIC cbp_base caf_mpi_static)
target_link_libraries(coarray_burgers_pde PRIVATE cbp_local)
set_target_properties(cbp_base cbp_local coarray_burgers_pde
PROPERTIES
Fortran_MODULE_DIRECTORY "${config_directory}"
INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR};${config_directory}"
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
set(CMAKE_Fortran_COMPILER "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/caf")
add_library(local_field OBJECT local_field.f90)
add_library(global_field OBJECT global_field.f90)
add_dependencies(local_field caf_mpi_static)
add_dependencies(global_field local_field caf_mpi_static)
add_library(local_field STATIC local_field.f90)
add_library(global_field STATIC global_field.f90)
add_executable(co_heat
main.f90
$<TARGET_OBJECTS:local_field>
$<TARGET_OBJECTS:global_field>
)
add_dependencies(co_heat caf_mpi_static)
target_link_libraries(global_field PUBLIC local_field caf_mpi_static)
target_link_libraries(co_heat PRIVATE global_field)
set_target_properties(local_field global_field co_heat
PROPERTIES
INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}"
Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}"
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
!
module global_field_module
use local_field_module, only : local_field
module chs_global_field_module
use chs_local_field_module, only : local_field
implicit none
private
public :: global_field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
!
module local_field_module
module chs_local_field_module
implicit none
private
public :: local_field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

program main
use IEEE_arithmetic, only : IEEE_is_NaN
use global_field_module, only : global_field
use chs_global_field_module, only : global_field
implicit none
type(global_field) :: T,laplacian_T,T_half
real, parameter :: alpha=1.,dt=0.0001,final_time=1.,tolerance=1.E-3
Expand Down
22 changes: 8 additions & 14 deletions src/tests/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,21 @@ if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" )
set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
endif()

add_library( oc_test_interfaces OBJECT
add_library( oc_test_interfaces STATIC
opencoarrays_object_interface.f90
oc_assertions_interface.F90
)
add_library( opencoarrays_test_utilities STATIC
oc_assertions_implementation.F90
$<TARGET_OBJECTS:oc_test_interfaces>
oc_assertions_implementation.F90
)
set_target_properties(opencoarrays_test_utilities
PROPERTIES
Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}")
set_target_properties(oc_test_interfaces
target_link_libraries(opencoarrays_test_utilities PUBLIC oc_test_interfaces)
set_target_properties(oc_test_interfaces opencoarrays_test_utilities
PROPERTIES
Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}")

target_compile_options(oc_test_interfaces
PUBLIC
"-fcoarray=lib")
target_compile_options(opencoarrays_test_utilities
PUBLIC
"-fcoarray=lib")
Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}"
INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}"
COMPILE_OPTIONS "-fcoarray=lib"
)

if(HAVE_ERROR_STOP_IN_PURE)
target_compile_definitions(oc_test_interfaces
Expand Down
4 changes: 2 additions & 2 deletions src/tests/utilities/opencoarrays_object_interface.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module opencoarrays_object_interface
!! Object pattern abstract type to provide a universal interface to a userd-defined derived type ouptput
!! capability specified in a generic binding
!! Object pattern abstract type to provide a universal interface to a user-defined
!! derived type output capability specified in a generic binding
implicit none

type, abstract :: object
Expand Down
Loading