Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
640 changes: 514 additions & 126 deletions CMakeLists.txt

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions cmake/apply-patches.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Apply one or more unified patches without failing when a patch is already
# present in an incremental ExternalProject build.
if( NOT DEFINED GEOS_PATCH_FILES OR GEOS_PATCH_FILES STREQUAL "" )
message( FATAL_ERROR "GEOS_PATCH_FILES must name at least one patch file." )
endif()

if( NOT DEFINED GEOS_PATCH_STRIP OR GEOS_PATCH_STRIP STREQUAL "" )
set( GEOS_PATCH_STRIP 1 )
endif()

# A pipe is used as the list separator because semicolons are list separators
# in CMake command-line definitions.
string( REPLACE "|" ";" _geos_patch_files "${GEOS_PATCH_FILES}" )

foreach( _geos_patch_file IN LISTS _geos_patch_files )
if( NOT EXISTS "${_geos_patch_file}" )
message( FATAL_ERROR "Patch file does not exist: ${_geos_patch_file}" )
endif()

execute_process(
COMMAND patch --batch --forward --dry-run -p${GEOS_PATCH_STRIP} -i "${_geos_patch_file}"
RESULT_VARIABLE _geos_patch_forward_status
OUTPUT_VARIABLE _geos_patch_forward_output
ERROR_VARIABLE _geos_patch_forward_error )

if( _geos_patch_forward_status EQUAL 0 )
execute_process(
COMMAND patch --batch --forward -p${GEOS_PATCH_STRIP} -i "${_geos_patch_file}"
RESULT_VARIABLE _geos_patch_apply_status
OUTPUT_VARIABLE _geos_patch_apply_output
ERROR_VARIABLE _geos_patch_apply_error )
if( NOT _geos_patch_apply_status EQUAL 0 )
message( FATAL_ERROR
"Failed to apply patch ${_geos_patch_file}:\n"
"${_geos_patch_apply_output}${_geos_patch_apply_error}" )
endif()
else()
execute_process(
COMMAND patch --batch --reverse --dry-run -p${GEOS_PATCH_STRIP} -i "${_geos_patch_file}"
RESULT_VARIABLE _geos_patch_reverse_status
OUTPUT_VARIABLE _geos_patch_reverse_output
ERROR_VARIABLE _geos_patch_reverse_error )
if( _geos_patch_reverse_status EQUAL 0 )
message( STATUS "Patch already applied: ${_geos_patch_file}" )
else()
message( FATAL_ERROR
"Patch cannot be applied or recognized as already applied: ${_geos_patch_file}\n"
"Forward check:\n${_geos_patch_forward_output}${_geos_patch_forward_error}\n"
"Reverse check:\n${_geos_patch_reverse_output}${_geos_patch_reverse_error}" )
endif()
endif()
endforeach()
119 changes: 119 additions & 0 deletions cmake/geos-host-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Generated by the legacy GEOS TPL build.
# Configuration: @GEOS_TPL_HOST_CONFIG_FILENAME@
#
# This file configures a downstream GEOS build. It intentionally does not
# set CMAKE_INSTALL_PREFIX, so the GEOS installation location remains a
# downstream choice.

set(GEOS_TPL_HOST_CONFIG_LOADED ON CACHE INTERNAL "Generated GEOS TPL host config loaded")
set(GEOS_TPL_DIR "@GEOS_TPL_HOST_CONFIG_TPL_DIR@" CACHE PATH "GEOS third-party library installation")

set(CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@" CACHE STRING "")
set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@" CACHE FILEPATH "")
set(CMAKE_Fortran_COMPILER "@CMAKE_Fortran_COMPILER@" CACHE FILEPATH "")
set(CMAKE_CXX_STANDARD "@GEOS_TPL_HOST_CONFIG_CXX_STANDARD@" CACHE STRING "")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "")
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "")
set(BLT_CXX_STD "@BLT_CXX_STD@" CACHE STRING "")
set(ENABLE_FORTRAN OFF CACHE BOOL "")
set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "")
set(CMAKE_CXX_FLAGS "@CMAKE_CXX_FLAGS@" CACHE STRING "")

set(ENABLE_MPI "@ENABLE_MPI@" CACHE BOOL "")
set(MPI_C_COMPILER "@MPI_C_COMPILER@" CACHE FILEPATH "")
set(MPI_CXX_COMPILER "@MPI_CXX_COMPILER@" CACHE FILEPATH "")
set(MPI_Fortran_COMPILER "@MPI_Fortran_COMPILER@" CACHE FILEPATH "")
set(MPIEXEC_EXECUTABLE "@GEOS_TPL_HOST_CONFIG_MPIEXEC@" CACHE FILEPATH "")
set(MPIEXEC_NUMPROC_FLAG "@GEOS_TPL_HOST_CONFIG_MPIEXEC_NUMPROC_FLAG@" CACHE STRING "")

set(CMAKE_PREFIX_PATH "@GEOS_TPL_HOST_CONFIG_PREFIX_PATH@" CACHE STRING "")
set(RAJA_DIR "@RAJA_DIR@" CACHE PATH "")
set(CAMP_DIR "@GEOS_TPL_HOST_CONFIG_CAMP_DIR@" CACHE PATH "")
set(UMPIRE_DIR "@CHAI_DIR@" CACHE PATH "")
set(CHAI_DIR "@CHAI_DIR@" CACHE PATH "")
set(HDF5_DIR "@HDF5_DIR@" CACHE PATH "")
set(CONDUIT_DIR "@CONDUIT_DIR@" CACHE PATH "")
set(SILO_DIR "@SILO_DIR@" CACHE PATH "")
set(ADIAK_DIR "@ADIAK_DIR@" CACHE PATH "")
set(CALIPER_DIR "@CALIPER_DIR@" CACHE PATH "")
set(PUGIXML_DIR "@PUGIXML_DIR@" CACHE PATH "")
set(VTK_DIR "@VTK_DIR@" CACHE PATH "")
set(FMT_DIR "@GEOS_TPL_HOST_CONFIG_FMT_DIR@" CACHE PATH "")
set(METIS_DIR "@METIS_DIR@" CACHE PATH "")
set(PARMETIS_DIR "@PARMETIS_DIR@" CACHE PATH "")
set(SUPERLU_DIST_DIR "@SUPERLU_DIR@" CACHE PATH "")
set(SUITESPARSE_DIR "@SUITESPARSE_DIR@" CACHE PATH "")
# HypreDrive's package config may probe for a CMake HYPRE package while GEOS
# consumes the superbuild's headers and archive directly. That probe can leave
# HYPRE_DIR as HYPRE_DIR-NOTFOUND; recover that value on the next configure
# while preserving a valid explicit -DHYPRE_DIR override.
if(NOT DEFINED HYPRE_DIR OR HYPRE_DIR MATCHES "-NOTFOUND$")
set(HYPRE_DIR "@HYPRE_DIR@" CACHE PATH "" FORCE)
endif()
set(HYPREDRV_DIR "@HYPREDRV_DIR@" CACHE PATH "")
set(SCOTCH_DIR "@SCOTCH_DIR@" CACHE PATH "")
set(PETSC_DIR "@PETSC_INSTALL_DIR@" CACHE PATH "")
set(MATHPRESSO_DIR "@MATHPRESSO_DIR@" CACHE PATH "")
set(DOXYGEN_EXECUTABLE "@GEOS_TPL_HOST_CONFIG_DOXYGEN_EXECUTABLE@" CACHE FILEPATH "")
set(UNCRUSTIFY_EXECUTABLE "@GEOS_TPL_HOST_CONFIG_UNCRUSTIFY_EXECUTABLE@" CACHE FILEPATH "")

set(ENABLE_CALIPER "@ENABLE_CALIPER@" CACHE BOOL "")
set(ENABLE_CUDA "@ENABLE_CUDA@" CACHE BOOL "")
set(ENABLE_CUDA_NVTOOLSEXT "@GEOS_TPL_HOST_CONFIG_CUDA_NVTOOLSEXT@" CACHE BOOL "")
set(ENABLE_HIP "@ENABLE_HIP@" CACHE BOOL "")
set(ENABLE_OPENMP "@ENABLE_OPENMP@" CACHE BOOL "")
set(ENABLE_HYPRE "@ENABLE_HYPRE@" CACHE BOOL "")
set(ENABLE_HYPREDRV "@ENABLE_HYPREDRV@" CACHE BOOL "")
set(ENABLE_HYPRE_DEVICE "@GEOS_TPL_HOST_CONFIG_HYPRE_DEVICE@" CACHE STRING "")
set(ENABLE_HYPRE_GPU_AWARE_MPI "@GEOS_TPL_HOST_CONFIG_HYPRE_GPU_AWARE_MPI@" CACHE BOOL "")
set(ENABLE_HYPRE_GPU_PROFILING "@ENABLE_HYPRE_GPU_PROFILING@" CACHE BOOL "")
set(ENABLE_CALIPER_HYPRE "@GEOS_TPL_HOST_CONFIG_CALIPER_HYPRE@" CACHE BOOL "")
set(ENABLE_HYPRE_MIXINT "@GEOS_TPL_HOST_CONFIG_HYPRE_MIXINT@" CACHE BOOL "")
set(GEOS_LA_INTERFACE "@GEOS_TPL_HOST_CONFIG_LA_INTERFACE@" CACHE STRING "")
set(ENABLE_TRILINOS "@ENABLE_TRILINOS@" CACHE BOOL "")
set(ENABLE_PETSC "@ENABLE_PETSC@" CACHE BOOL "")
set(ENABLE_METIS "@GEOS_TPL_HOST_CONFIG_METIS@" CACHE BOOL "")
set(ENABLE_PARMETIS "@GEOS_TPL_HOST_CONFIG_PARMETIS@" CACHE BOOL "")
set(ENABLE_SCOTCH "@ENABLE_SCOTCH@" CACHE BOOL "")
set(ENABLE_SUPERLU_DIST "@ENABLE_SUPERLU_DIST@" CACHE BOOL "")
set(ENABLE_SUITESPARSE "@ENABLE_SUITESPARSE@" CACHE BOOL "")
set(ENABLE_SILO "@GEOS_TPL_HOST_CONFIG_SILO@" CACHE BOOL "")
set(ENABLE_MATHPRESSO "@GEOS_TPL_HOST_CONFIG_MATHPRESSO@" CACHE BOOL "")
set(ENABLE_VTK "@ENABLE_VTK@" CACHE BOOL "")
set(ENABLE_VTK_WRAP_PYTHON "@ENABLE_VTK_WRAP_PYTHON@" CACHE BOOL "")
set(ENABLE_UNCRUSTIFY "@GEOS_TPL_HOST_CONFIG_UNCRUSTIFY@" CACHE BOOL "")
set(ENABLE_DOXYGEN OFF CACHE BOOL "")
set(ENABLE_DOCS OFF CACHE BOOL "")
set(ENABLE_EXAMPLES OFF CACHE BOOL "")
set(ENABLE_BENCHMARKS OFF CACHE BOOL "")
set(ENABLE_TESTS ON CACHE BOOL "")
set(GEOS_ENABLE_TESTS ON CACHE BOOL "")

# Compare the substituted option as a string because this cache file is
# loaded before the downstream project establishes CMake's boolean policies.
if("@ENABLE_CUDA@" STREQUAL "ON")
set(CMAKE_CUDA_COMPILER "@CMAKE_CUDA_COMPILER@" CACHE FILEPATH "")
set(CMAKE_CUDA_HOST_COMPILER "@CMAKE_CUDA_HOST_COMPILER@" CACHE FILEPATH "")
set(CUDA_TOOLKIT_ROOT_DIR "@CUDA_TOOLKIT_ROOT_DIR@" CACHE PATH "")
set(CUDA_ARCH "@CUDA_ARCH@" CACHE STRING "")
set(CMAKE_CUDA_ARCHITECTURES "@CMAKE_CUDA_ARCHITECTURES@" CACHE STRING "")
set(CMAKE_CUDA_STANDARD "@CMAKE_CUDA_STANDARD@" CACHE STRING "")
set(CMAKE_CUDA_STANDARD_REQUIRED ON CACHE BOOL "")
set(CMAKE_CUDA_FLAGS "@CMAKE_CUDA_FLAGS@" CACHE STRING "")
endif()

if("@ENABLE_HIP@" STREQUAL "ON")
set(CMAKE_HIP_COMPILER "@CMAKE_HIP_COMPILER@" CACHE FILEPATH "")
set(CMAKE_HIP_ARCHITECTURES "@CMAKE_HIP_ARCHITECTURES@" CACHE STRING "")
set(CMAKE_HIP_STANDARD "@CMAKE_HIP_STANDARD@" CACHE STRING "")
set(CMAKE_HIP_STANDARD_REQUIRED ON CACHE BOOL "")
set(ROCM_PATH "@ROCM_PATH@" CACHE PATH "")
set(HIP_ROOT "@HIP_ROOT@" CACHE PATH "")
set(CMAKE_HIP_FLAGS "@CMAKE_HIP_FLAGS@" CACHE STRING "")
set(GPU_TARGETS "@CMAKE_HIP_ARCHITECTURES@" CACHE STRING "")
set(AMDGPU_TARGETS "@CMAKE_HIP_ARCHITECTURES@" CACHE STRING "")
endif()

set(BLAS_LIBRARIES "@BLAS_LIBRARIES@" CACHE STRING "")
set(LAPACK_LIBRARIES "@LAPACK_LIBRARIES@" CACHE STRING "")
94 changes: 94 additions & 0 deletions patch/raja-reducer-assignment.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
diff --git a/include/RAJA/policy/cuda/reduce.hpp b/include/RAJA/policy/cuda/reduce.hpp
--- a/include/RAJA/policy/cuda/reduce.hpp
+++ b/include/RAJA/policy/cuda/reduce.hpp
@@ -1123,6 +1123,43 @@
#endif
}

+ //! assign a reducer while preserving ownership of host and device resources
+ Reduce& operator=(const Reduce& other)
+ {
+ if (this != &other)
+ {
+ // The implicitly generated assignment operator shallow-copies the
+ // reducer state. In particular, it overwrites an owning tally pointer
+ // and leaks the tally allocated by the destination. It also copies the
+ // device-ownership flag, which can make two reducers free the same
+ // device allocation. Match the copy constructor's non-owning semantics
+ // after releasing resources currently owned by the destination.
+ if (parent == this)
+ {
+ delete tally_or_val_ptr.list;
+ }
+ else if (parent == nullptr)
+ {
+ val.teardownForDevice();
+ }
+
+ parent = other.parent;
+ tally_or_val_ptr = other.tally_or_val_ptr;
+ val = reduce_data_type(other.val);
+
+ if (parent && tally_or_val_ptr.list)
+ {
+ if (val.setupForDevice())
+ {
+ tally_or_val_ptr.val_ptr = val.init_grid_vals(
+ tally_or_val_ptr.list->new_value(currentResource()));
+ parent = nullptr;
+ }
+ }
+ }
+ return *this;
+ }
+
//! apply reduction upon destruction and cleanup resources owned by this copy
// on device store in pinned buffer on host
RAJA_HOST_DEVICE
diff --git a/include/RAJA/policy/hip/reduce.hpp b/include/RAJA/policy/hip/reduce.hpp
--- a/include/RAJA/policy/hip/reduce.hpp
+++ b/include/RAJA/policy/hip/reduce.hpp
@@ -1116,6 +1116,43 @@
#endif
}

+ //! assign a reducer while preserving ownership of host and device resources
+ Reduce& operator=(const Reduce& other)
+ {
+ if (this != &other)
+ {
+ // The implicitly generated assignment operator shallow-copies the
+ // reducer state. In particular, it overwrites an owning tally pointer
+ // and leaks the tally allocated by the destination. It also copies the
+ // device-ownership flag, which can make two reducers free the same
+ // device allocation. Match the copy constructor's non-owning semantics
+ // after releasing resources currently owned by the destination.
+ if (parent == this)
+ {
+ delete tally_or_val_ptr.list;
+ }
+ else if (parent == nullptr)
+ {
+ val.teardownForDevice();
+ }
+
+ parent = other.parent;
+ tally_or_val_ptr = other.tally_or_val_ptr;
+ val = reduce_data_type(other.val);
+
+ if (parent && tally_or_val_ptr.list)
+ {
+ if (val.setupForDevice())
+ {
+ tally_or_val_ptr.val_ptr = val.init_grid_vals(
+ tally_or_val_ptr.list->new_value(currentResource()));
+ parent = nullptr;
+ }
+ }
+ }
+ return *this;
+ }
+
//! apply reduction upon destruction and cleanup resources owned by this copy
// on device store in pinned buffer on host
RAJA_HOST_DEVICE
Loading
Loading