Skip to content

Commit b68820f

Browse files
authored
Merge pull request #451 from IPPL-framework/cmake-alps
Cmake alps
2 parents 5f55bce + 7146be0 commit b68820f

24 files changed

+840
-158
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ cmake_minimum_required(VERSION 3.24)
88
# ------------------------------------------------------------------------------
99
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
1010

11-
# but disable c++20 module scanning until we have better support for it this seems to cause some
11+
# Disable c++20 module scanning until we have better support for it this seems to cause some
1212
# problems when using gcc@14
13-
cmake_policy(SET CMP0155 OLD)
13+
if(POLICY CMP0155)
14+
cmake_policy(SET CMP0155 OLD)
15+
endif()
1416

1517
# ------------------------------------------------------------------------------
1618
# Project declaration and version

CMakeUserPresets.json

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
"BUILD_SHARED_LIBS": "ON",
2424
"CMAKE_BUILD_TYPE": "Release",
2525
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
26-
"Kokkos_VERSION_DEFAULT": "4.5.01",
26+
"Kokkos_VERSION_DEFAULT": "4.7.01",
2727
"Heffte_VERSION_DEFAULT": "2.4.0",
28-
"IPPL_PLATFORMS": "OPENMP;CUDA",
28+
"IPPL_PLATFORMS": "SERIAL",
2929
"IPPL_ENABLE_FFT": "ON",
3030
"IPPL_ENABLE_ALPINE": "ON",
3131
"IPPL_ENABLE_COSMOLOGY": "ON",
3232
"IPPL_ENABLE_TESTS": "OFF",
3333
"IPPL_ENABLE_UNIT_TESTS": "OFF",
34-
"IPPL_USE_STANDARD_FOLDERS": "OFF"
34+
"IPPL_USE_STANDARD_FOLDERS": "ON"
3535
}
3636
},
3737
{
@@ -42,7 +42,7 @@
4242
"default"
4343
],
4444
"cacheVariables": {
45-
"Kokkos_VERSION": "git.4.6.02",
45+
"Kokkos_VERSION": "git.4.7.01",
4646
"Heffte_VERSION": "git.v2.4.1"
4747
}
4848
},
@@ -74,17 +74,34 @@
7474
"displayName": "Alps-GH200-defaults",
7575
"description": "Enables building test in debug mode",
7676
"inherits": [
77-
"testing",
78-
"default"
77+
"release-testing"
7978
],
8079
"cacheVariables": {
8180
"MPIEXEC_PREFLAGS": "--gpus-per-task=1;/user-environment/wrapper-mpi.sh",
82-
"IPPL_PLATFORMS": "OPENMP;CUDA",
81+
"IPPL_PLATFORMS": "SERIAL;CUDA",
8382
"CMAKE_CUDA_ARCHITECTURES": "90",
8483
"MPIEXEC_EXECUTABLE": "/usr/bin/srun",
8584
"Kokkos_VERSION_DEFAULT": "4.7",
8685
"Heffte_VERSION_DEFAULT": "2.4.1"
8786
}
87+
},
88+
{
89+
"name": "alps-mi300",
90+
"displayName": "Alps-mi300-defaults",
91+
"description": "Enables building test in debug mode",
92+
"inherits": [
93+
"release-testing"
94+
],
95+
"cacheVariables": {
96+
"MPIEXEC_PREFLAGS": "--gpus-per-node=4;/user-environment/wrapper-mpi.sh",
97+
"IPPL_PLATFORMS": "HIP;SERIAL",
98+
"CMAKE_HIP_ARCHITECTURES": "gfx942",
99+
"AMDGPU_TARGETS": "gfx942",
100+
"GPU_TARGETS": "gfx942",
101+
"MPIEXEC_EXECUTABLE": "/usr/bin/srun",
102+
"Kokkos_VERSION_DEFAULT": "git.4.7.01",
103+
"Heffte_VERSION_DEFAULT": "git.v2.4.1"
104+
}
88105
}
89106
]
90107
}

alpine/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ add_subdirectory(ExamplesWithoutPicManager)
99
function(add_alpine_example name)
1010
add_executable(${name} ${name}.cpp)
1111

12-
target_link_libraries(${name} PRIVATE ippl::ippl)
12+
target_link_libraries(${name} PRIVATE IPPL::ippl)
1313

1414
target_include_directories(${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
1515
endfunction()

alpine/ExamplesWithoutPicManager/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ find_package(Threads REQUIRED)
88
function(add_alpine_example name)
99
add_executable(${name} ${name}.cpp)
1010

11-
target_link_libraries(${name} PRIVATE ippl::ippl)
11+
target_link_libraries(${name} PRIVATE IPPL::ippl)
1212

1313
target_include_directories(${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
1414
endfunction()
@@ -20,5 +20,5 @@ add_alpine_example(LandauDampingParameterList)
2020

2121
# LandauDampingMixedExec needs extra Threads lib
2222
add_executable(LandauDampingMixedExec LandauDampingMixedExec.cpp)
23-
target_link_libraries(LandauDampingMixedExec PRIVATE ippl::ippl Threads::Threads)
23+
target_link_libraries(LandauDampingMixedExec PRIVATE IPPL::ippl Threads::Threads)
2424
target_include_directories(LandauDampingMixedExec PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

cmake/Dependencies.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ endfunction()
164164
# * if the requested version is not found on the system
165165
# * if the requested version is found but doesn't have the backends/platforms we need
166166
# then build from source.
167-
# We use FIND_PACKAGE_ARGS (cmake 3.24+) to allow FetchContent to find a system version
168167
# cmake-format: on
169168
# ------------------------------------------------------------------------------
170169
# set the default version of kokkos we will ask for if not already set

cmake/IPPLConfig.cmake.in

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,16 @@ if (@Kokkos_FOUND@)
2626
set(Kokkos_DIR @Kokkos_DIR@)
2727
find_dependency(Kokkos REQUIRED)
2828
else()
29-
# Kokkos was built "in-tree" via FetchContent
30-
# we will instruct cmake to find Kokkos either in build or install tree
29+
# Make sure Kokkos is corrrectly picked up, regardless of where we got it or built it
3130
if(_INSTALL_TREE)
3231
set(Kokkos_ROOT "${_install_dir}")
3332
find_dependency(Kokkos REQUIRED)
3433
message(STATUS "Using Kokkos_ROOT in the ippl install tree ${_install_dir}")
3534
elseif(_BUILD_TREE)
36-
set(Kokkos_ROOT "${_build_dir}")
37-
message(FATAL_ERROR
38-
"You are using IPPL directly from the IPPL build tree with Kokkos compiled from source "
39-
"(inside the IPPL tree). "
40-
"CMake can't find correctly find Kokkos unless it has been 'installed', so please use an "
41-
"install tree of IPPL (where Kokkos will also be installed")
35+
set(Kokkos_ROOT "${Kokkos_BINARY_DIR}")
36+
find_dependency(Kokkos REQUIRED)
37+
message(STATUS
38+
"You are using IPPL directly from the IPPL build tree with Kokkos compiled from source inside the IPPL tree ${Kokkos_ROOT}")
4239
else()
4340
message(FATAL_ERROR "IPPLConfig.cmake location does not match IPPL build or install tree")
4441
endif()
@@ -61,10 +58,10 @@ if(@IPPL_ENABLE_FFT@)
6158
find_dependency(Heffte REQUIRED)
6259
message(STATUS "Using Heffte_ROOT in the ippl install tree ${_install_dir}")
6360
elseif(_BUILD_TREE)
64-
set(Heffte_ROOT "${_build_dir}")
65-
message(FATAL_ERROR
66-
"You are using IPPL from the build tree with IPPL-compiled Heffte "
67-
"CMake can't find correctly find Heffte, so please use an install tree of IPPL/Heffte")
61+
set(Heffte_ROOT "${Heffte_BINARY_DIR}")
62+
find_dependency(Heffte REQUIRED)
63+
message(STATUS
64+
"You are using IPPL directly from the IPPL build tree with Heffte compiled from source inside the IPPL tree ${Heffte_ROOT}")
6865
else()
6966
message(FATAL_ERROR "IPPLConfig.cmake location does not match IPPL build or install tree")
7067
endif()

cmake/InstallIppl.cmake

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
1-
# cmake/InstallIppl.cmake
2-
# -------------------------------------------------------
3-
# Installation logic for the IPPL library
4-
# -------------------------------------------------------
1+
# -----------------------------------------------------------------------------
2+
# InstallIppl.cmake
3+
# ~~~
4+
#
5+
# Setup install rules for ippl (and dependencies if needed).
6+
#
7+
# Responsibilities:
8+
# - Create IPPLConfig, IPPLConfigVersion, IPPLTargets files in install dir
9+
# - Also create above files in build dir, for development, when building ippl
10+
# locally and using a non-installed version
11+
#
12+
# Note:
13+
# - NameSpace 'IPPL' should be used to match Project name as used in
14+
# find_package(IPPL ...
15+
# ~~~
16+
# -----------------------------------------------------------------------------
517

618
set(IPPL_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/ippl"
719
CACHE PATH "Directory for ippl CMake package files")
820

21+
# cmake-format: off
22+
# -------------------------------------------------------
23+
# Define patterns for globbing of files we are not installing
24+
# -------------------------------------------------------
925
set(_ippl_install_excludes
10-
PATTERN
11-
"CMakeFiles"
12-
EXCLUDE
13-
PATTERN
14-
"CMakeLists.txt"
15-
EXCLUDE
16-
PATTERN
17-
"*.c"
18-
EXCLUDE
19-
PATTERN
20-
"*.cc"
21-
EXCLUDE
22-
PATTERN
23-
"*.cpp"
24-
EXCLUDE
25-
PATTERN
26-
"*.cu"
27-
EXCLUDE)
26+
PATTERN "CMakeFiles" EXCLUDE
27+
PATTERN "CMakeLists.txt" EXCLUDE
28+
PATTERN "*.c" EXCLUDE
29+
PATTERN "*.cc" EXCLUDE
30+
PATTERN "*.cpp" EXCLUDE
31+
PATTERN "*.cu" EXCLUDE
32+
# match your filenames if needed
33+
)
34+
2835
if(NOT IPPL_ENABLE_FFT)
2936
list(
30-
APPEND
31-
_ippl_install_excludes
32-
PATTERN
33-
"FFT/*"
34-
EXCLUDE
35-
PATTERN
36-
"PoissonSolvers/FFT*"
37-
EXCLUDE # match your filenames if needed
38-
)
37+
APPEND _ippl_install_excludes
38+
PATTERN "FFT/*" EXCLUDE
39+
PATTERN "PoissonSolvers/FFT*" EXCLUDE)
3940
endif()
4041

42+
# -------------------------------------------------------
43+
# Define patterns for files we are installing
4144
install(
4245
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
4346
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ippl
@@ -49,9 +52,16 @@ install(
4952
PATTERN "*.cuh"
5053
PATTERN "*.tpp" ${_ippl_install_excludes})
5154

52-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/IpplVersions.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
55+
# -------------------------------------------------------
56+
# install all the header/other files
57+
# -------------------------------------------------------
58+
install(
59+
FILES ${CMAKE_CURRENT_BINARY_DIR}/IpplVersions.h
60+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
5361

54-
# Install the actual library target
62+
# -------------------------------------------------------
63+
# Define an install rule for the targets we export
64+
# -------------------------------------------------------
5565
install(
5666
TARGETS ippl
5767
EXPORT ipplTargets
@@ -61,66 +71,56 @@ install(
6171
INCLUDES
6272
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
6373

64-
# Export the CMake target for find_package()
65-
install(EXPORT ipplTargets FILE ipplTargets.cmake NAMESPACE ippl::
66-
DESTINATION ${IPPL_INSTALL_CMAKEDIR})
67-
68-
include(CMakePackageConfigHelpers)
69-
70-
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/IPPLConfigVersion.cmake"
71-
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
72-
73-
configure_package_config_file(
74-
"${PROJECT_SOURCE_DIR}/cmake/IPPLConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/IPPLConfig.cmake"
75-
INSTALL_DESTINATION ${IPPL_INSTALL_CMAKEDIR})
76-
77-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/IPPLConfig.cmake"
78-
"${CMAKE_CURRENT_BINARY_DIR}/IPPLConfigVersion.cmake"
79-
DESTINATION ${IPPL_INSTALL_CMAKEDIR})
80-
81-
return()
82-
83-
# cmake/InstallIppl.cmake
8474
# -------------------------------------------------------
85-
# Installation logic for the IPPL library
75+
# Install rule to create the CMake targets for find_package()
8676
# -------------------------------------------------------
87-
include(CMakePackageConfigHelpers)
88-
89-
# -------------------------------------------------------
90-
# Install public headers
91-
install(FILES ${IPPL_SOURCE_DIR}/Ippl.h ${IPPL_SOURCE_DIR}/IpplCore.h
92-
${IPPL_BINARY_DIR}/IpplVersions.h DESTINATION include)
77+
install(
78+
EXPORT ipplTargets
79+
FILE IPPLTargets.cmake
80+
NAMESPACE IPPL::
81+
DESTINATION ${IPPL_INSTALL_CMAKEDIR})
9382

94-
# -------------------------------------------------------
95-
# Install the actual library target
96-
install(TARGETS ippl EXPORT IpplTargets DESTINATION lib)
83+
# Also export targets to the build directory to support uninstalled builds
84+
export(
85+
EXPORT ipplTargets
86+
FILE "${PROJECT_BINARY_DIR}/IPPLTargets.cmake"
87+
NAMESPACE IPPL::)
9788

98-
# Ensure extern dependencies (like HEFFTE) are exported correctly if they were built in-tree. This
99-
# is necessary for Heffte because it does not use CMake's export target mechanism
100-
if(TARGET Heffte)
101-
install(TARGETS Heffte EXPORT IpplTargets DESTINATION lib)
102-
endif()
89+
# cmake-format: on
10390

10491
# -------------------------------------------------------
105-
# Export the CMake targets for find_package()
106-
install(EXPORT IpplTargets FILE IPPLTargets.cmake NAMESPACE IPPL:: DESTINATION lib/cmake/IPPL)
107-
92+
# Create the project ConfigVersion file
10893
# -------------------------------------------------------
109-
# Also export targets to the build directory to support uninstalled builds
110-
export(EXPORT IpplTargets FILE "${PROJECT_BINARY_DIR}/IPPLTargets.cmake" NAMESPACE IPPL::)
94+
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/IPPLConfigVersion.cmake"
95+
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
11196

112-
# -------------------------------------------------------
113-
# generate a version file for the package (in the build tree)
97+
# Also generate version file in the build directory to support uninstalled builds
11498
write_basic_package_version_file("${PROJECT_BINARY_DIR}/IPPLConfigVersion.cmake"
11599
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
116100

117101
# -------------------------------------------------------
118-
# generate a package config file (in the build tree)
102+
# Setup the main project config file found by find_package(IPPL
103+
# -------------------------------------------------------
104+
configure_package_config_file(
105+
"${PROJECT_SOURCE_DIR}/cmake/IPPLConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/IPPLConfig.cmake"
106+
INSTALL_DESTINATION ${IPPL_INSTALL_CMAKEDIR})
107+
108+
# Also generate config file in the build directory to support uninstalled builds
119109
configure_package_config_file(
120110
"${PROJECT_SOURCE_DIR}/cmake/IPPLConfig.cmake.in" "${PROJECT_BINARY_DIR}/IPPLConfig.cmake"
121111
INSTALL_DESTINATION lib/cmake/IPPL)
122112

123113
# -------------------------------------------------------
124-
# install the generated version and package config files in the install tree
125-
install(FILES "${PROJECT_BINARY_DIR}/IPPLConfig.cmake"
126-
"${PROJECT_BINARY_DIR}/IPPLConfigVersion.cmake" DESTINATION lib/cmake/IPPL)
114+
# The install rule that copies the generated config files to the install tree
115+
# -------------------------------------------------------
116+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/IPPLConfig.cmake"
117+
"${CMAKE_CURRENT_BINARY_DIR}/IPPLConfigVersion.cmake"
118+
DESTINATION ${IPPL_INSTALL_CMAKEDIR})
119+
120+
# -------------------------------------------------------
121+
# Fix/Hack: Ensure extern dependencies are exported correctly if they were built in-tree. This is
122+
# needed for Heffte because it doesn't fully use CMake's export target mechanism
123+
# -------------------------------------------------------
124+
if(TARGET Heffte)
125+
install(TARGETS Heffte EXPORT ipplTargets DESTINATION lib)
126+
endif()

cmake/MachineName.cmake

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -----------------------------------------------------------------------------
2+
# MachineName..cmake
3+
# cmake-format: off
4+
#
5+
# Tries to find which machine we are running on so that scripts can be
6+
# configured accordingly.
7+
#
8+
# Currently we support
9+
# Lumi, alps (CSCS) machines,
10+
#
11+
# cmake-format: on
12+
# -----------------------------------------------------------------------------
13+
14+
if(NOT "$ENV{CLUSTER_NAME}" STREQUAL "")
15+
set(IPPL_MACHINENAME "$ENV{CLUSTER_NAME}")
16+
elseif(NOT "$ENV{LMOD_SYSTEM_NAME}" STREQUAL "")
17+
set(IPPL_MACHINENAME "$ENV{LMOD_SYSTEM_NAME}")
18+
elseif(NOT "$ENV{APPS}" STREQUAL "")
19+
# basename of $APPS then append -xc
20+
get_filename_component(_apps_basename "$ENV{APPS}" NAME)
21+
set(IPPL_MACHINENAME "${_apps_basename}-xc")
22+
elseif(NOT "$ENV{LUMI_LMOD_FAMILY_COMPILER}" STREQUAL "")
23+
set(IPPL_MACHINENAME "lumi")
24+
else()
25+
execute_process(COMMAND hostname OUTPUT_VARIABLE _host OUTPUT_STRIP_TRAILING_WHITESPACE)
26+
set(IPPL_MACHINENAME "${_host}")
27+
endif()
28+
29+
# export to environment and make available in cache for other CMake code
30+
set(ENV{IPPL_MACHINENAME} "${IPPL_MACHINENAME}")
31+
set(IPPL_MACHINENAME "${IPPL_MACHINENAME}" CACHE STRING "Detected machine name")

0 commit comments

Comments
 (0)