Skip to content

Commit 111ac1c

Browse files
sethrjpcanal
andauthored
Default downstream CUDA/HIP architectures (#1669)
* Default downstream CUDA/HIP architectures * Docker didn't have a geant4 version number * Get geant4 version number through the geant4-config script * Disable MPI in offload test * Restore posix compatibility * Update scripts/ci/test-examples.sh Co-authored-by: Philippe Canal <[email protected]> * POSIX compliance --------- Co-authored-by: Philippe Canal <[email protected]>
1 parent 7d86471 commit 111ac1c

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

.github/workflows/build-spack.yml

-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ jobs:
280280
|| !matrix.geant
281281
) && '1' || ''
282282
}}
283-
CELER_GEANT4_VERSION: ${{matrix.geant}}
284283
if: >-
285284
${{
286285
(matrix.special != 'asanlite')

CMakeLists.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,11 @@ foreach(_key
713713
set(_cache_val "$CACHE{${_key}}")
714714
if(_cache_val)
715715
list(APPEND CELERITAS_EXPORT_VARIABLES
716-
"set(${_key} \"${_cache_val}\" CACHE PATH \"Set by CeleritasConfig.cmake\")"
716+
"_celer_set_cache_default(${_key} \"${_cache_val}\" PATH \"Set by CeleritasConfig.cmake\")"
717717
)
718718
else()
719719
list(APPEND CELERITAS_EXPORT_VARIABLES
720-
"if(NOT DEFINED ${_key})"
721-
" set(${_key} \"${_val}\")"
722-
"endif()"
720+
"_celer_set_local_default(${_key} \"${_val}\")"
723721
)
724722
endif()
725723
endif()

cmake/CeleritasConfig.cmake.in

+30
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ if(((@PROJECT_NAME@_FIND_VERSION_MAJOR EQUAL 0
2929
)
3030
endif()
3131

32+
#-----------------------------------------------------------------------------#
33+
# Configuration macros
34+
#-----------------------------------------------------------------------------#
35+
36+
macro(_celer_set_local_default var val)
37+
if(NOT DEFINED ${var})
38+
message(VERBOSE "Celeritas: set ${var}=${val}")
39+
set(${var} "${val}")
40+
endif()
41+
endmacro()
42+
43+
macro(_celer_set_cache_default var val)
44+
if(NOT DEFINED ${var})
45+
message(STATUS "Celeritas: set cache ${var}=${val}")
46+
set(${var} "${val}" CACHE ${ARGN})
47+
endif()
48+
endmacro()
49+
3250
#-----------------------------------------------------------------------------#
3351
# Variables
3452
#-----------------------------------------------------------------------------#
@@ -46,6 +64,13 @@ include(CMakeFindDependencyMacro)
4664
if(CELERITAS_USE_CUDA)
4765
find_dependency(CUDAToolkit REQUIRED)
4866

67+
# Set cache variable if needed *before* checking CUDA
68+
_celer_set_cache_default(
69+
CMAKE_CUDA_ARCHITECTURES
70+
"${CELERITAS_CMAKE_CUDA_ARCHITECTURES}"
71+
STRING "CUDA architectures"
72+
)
73+
4974
if(NOT CMAKE_CUDA_COMPILER_LOADED)
5075
# enable_language only really works in top-level CMake directory, not even subprojects
5176
# https://discourse.cmake.org/t/is-it-appropriate-to-use-enable-language-in-a-cmake-package-file/4335
@@ -65,6 +90,11 @@ if(CELERITAS_USE_CUDA)
6590
endif()
6691
endif()
6792
elseif(CELERITAS_USE_HIP)
93+
_celer_set_cache_default(
94+
CMAKE_HIP_ARCHITECTURES
95+
"${CELERITAS_CMAKE_HIP_ARCHITECTURES}"
96+
STRING "HIP architectures"
97+
)
6898
find_dependency(hip REQUIRED QUIET)
6999
endif()
70100

scripts/ci/test-examples.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,26 @@ build_local
4141

4242
# Run Geant4 app examples
4343
if [ -z "${CELER_DISABLE_ACCEL_EXAMPLES}" ]; then
44+
if [ -z "${G4VERSION_NUMBER}" ]; then
45+
# Get the geant4 version 11.2.3, failing if config isn't found
46+
_vers=$(geant4-config --version)
47+
# Replace . with ' ' and convert to MMmp (major/minor/patch)
48+
G4VERSION_NUMBER=$(echo "${_vers}" | tr '.' ' ' | xargs printf '%d%01d%01d')
49+
echo "Set G4VERSION_NUMBER=\"${G4VERSION_NUMBER}\""
50+
fi
51+
4452
# Run small accel examples
4553
cd "${CELER_SOURCE_DIR}/example/accel"
4654
build_local
4755
ctest -V --no-tests=error
4856

49-
if [ "$(echo $CELER_GEANT4_VERSION | awk -F. '{print $1*100 + $2}')" \
50-
-ge 1100 ]; then
57+
if [ "${G4VERSION_NUMBER}" -ge 1100 ]; then
5158
# Run offload-template only on Geant4 v11
5259
cd "${CELER_SOURCE_DIR}/example/offload-template"
5360
build_local
54-
./run-offload
61+
CELER_DISABLE_PARALLEL=1 \
62+
G4FORCENUMBEROFTHREADS=4 G4RUN_MANAGER_TYPE=MT \
63+
./run-offload
5564
fi
5665
else
5766
printf "\e[31mSkipping 'accel' tests due to insufficient requirements\e[m\n"

0 commit comments

Comments
 (0)