Skip to content

CMake tweaks and cleanup to help with alps uenv builds #358

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ manual/ippl_user_guide.pdf
build*/
*~
*.~
*.orig

# ignore build directories
build*/
Expand Down
92 changes: 74 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,88 @@
cmake_minimum_required(VERSION 3.20)
# ------------------------------------------------------------------------------
# CMake version requirement
# ------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.24)

set(CMAKE_CXX_FLAGS_DEBUG_INIT "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O3 -g")
# ------------------------------------------------------------------------------
# Policies - use the latest of everything
# ------------------------------------------------------------------------------
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})

project(IPPL LANGUAGES CXX VERSION 3.0.2)
# ------------------------------------------------------------------------------
# Project declaration and version
# ------------------------------------------------------------------------------
project(IPPL VERSION 3.2 LANGUAGES CXX)

list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Symbolic version string (for CLI, logs, headers, etc.)
set(IPPL_VERSION_NAME "IPPL v${IPPL_VERSION}")

option(IPPL_ENABLE_UNIT_TESTS "Enable unit tests using GoogleTest" OFF)
option(IPPL_ENABLE_FFT "Enable FFT support" OFF)
option(IPPL_ENABLE_SOLVERS "Enable IPPL solvers" OFF)
option(IPPL_ENABLE_ALPINE "Enable building the Alpine module" OFF)
option(IPPL_ENABLE_COSMOLOGY "Enable building the Cosmology module" OFF)
option(IPPL_ENABLE_TESTS "Build integration tests in test/ directory" OFF)
option(IPPL_DYL "Build IPPL as a shared library (ON) or static library (OFF)" OFF)
option(IPPL_ENABLE_COVERAGE "Enable code coverage" OFF)
option(IPPL_ENABLE_NSYS_PROFILER "Enable Nvidia Nsys Profiler" OFF)
option(IPPL_ENABLE_SANITIZER "Enable sanitizer(s)" OFF)
option(USE_ALTERNATIVE_VARIANT "Use modified variant implementation (required for CUDA 12.2 + GCC 12.3.0)" OFF)
message(STATUS
"📦 Configuring IPPL Version: ${IPPL_VERSION_MAJOR}.${IPPL_VERSION_MINOR} : \"${IPPL_VERSION_NAME}\""
)

# ------------------------------------------------------------------------------
# Module path
# ------------------------------------------------------------------------------
list(PREPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake" "${PROJECT_SOURCE_DIR}/CMakeModules")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want both a cmake and a CMakeModules folder? It might be more clean to have a folder-hierarchy all inside the cmake folder? Or what would the arguments be for having both?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that I just didn't notice there was the CMakeModules there - it doesn't exist on my tree, so is it a left over from somewhere, or should it be present. Probably I just added the cmake and missed the other, we can/should certainly remove one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see there is no official recommendation what name one should choose here but I've looked at some more modern projects and they mainly seem to be using "cmake" so I'd suggest using just that one?


# ------------------------------------------------------------------------------
# Primary IPPL options
# ------------------------------------------------------------------------------
option(IPPL_ENABLE_UNIT_TESTS "Enable unit tests using GoogleTest" OFF)
option(IPPL_ENABLE_FFT "Enable FFT support" OFF)
option(IPPL_ENABLE_SOLVERS "Enable IPPL solvers" OFF)
option(IPPL_ENABLE_ALPINE "Enable building the Alpine module" OFF)
option(IPPL_ENABLE_COSMOLOGY "Enable building the Cosmology module" OFF)
option(IPPL_ENABLE_TESTS "Build integration tests in test/ directory" OFF)
option(IPPL_DYL "Build IPPL as a shared library (ON) or static library (OFF)" OFF)
option(IPPL_ENABLE_COVERAGE "Enable code coverage" OFF)
option(IPPL_ENABLE_NSYS_PROFILER "Enable Nvidia Nsys Profiler" OFF)
option(IPPL_ENABLE_SANITIZER "Enable sanitizer(s)" OFF)
option(IPPL_USE_ALTERNATIVE_VARIANT "Use modified variant implementation (required for CUDA 12.2 + GCC 12.3.0)" OFF)
option(IPPL_USE_STANDARD_FOLDERS "Put all generated binaries in bin/lib folders" OFF)

# ------------------------------------------------------------------------------
# Setup Output directories
# ------------------------------------------------------------------------------
if (IPPL_USE_STANDARD_FOLDERS)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin
CACHE PATH "Single Directory for all Executables.")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib
CACHE PATH "Single Directory for all Libraries")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/lib
CACHE PATH "Single Directory for all static libraries.")
endif()

# ------------------------------------------------------------------------------
# cmake modules
# ------------------------------------------------------------------------------
# cmake supplied
include(GNUInstallDirs)
include(FetchContent)
include(CMakePackageConfigHelpers)
# custom ones
include(Messages)
include(ProjectSetup)
include(Version)
include(ExternalProject)
include(CompilerOptions)
include(Platforms)
include(Dependencies)

# ------------------------------------------------------------------------------
# Deprecated vars
# ------------------------------------------------------------------------------
if(DEFINED USE_ALTERNATIVE_VARIANT)
colour_message(WARNING ${Red} "USE_ALTERNATIVE_VARIANT is deprecated. Please set IPPL_USE_ALTERNATIVE_VARIANT instead.")
set(IPPL_USE_ALTERNATIVE_VARIANT ${USE_ALTERNATIVE_VARIANT})
endif()

# ------------------------------------------------------------------------------
# Define sources for project
# ------------------------------------------------------------------------------
add_subdirectory(src)

if (IPPL_ENABLE_UNIT_TESTS OR IPPL_ENABLE_TESTS)
Expand Down
64 changes: 64 additions & 0 deletions CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "testing",
"hidden": true,
"cacheVariables": {
"IPPL_ENABLE_TESTS": "ON",
"IPPL_ENABLE_UNIT_TESTS": "ON"
}
},
{
"name": "default",
"displayName": "Default",
"description": "Default build, release mode with most common options",
"generator": "Unix Makefiles",
"cacheVariables": {
"BUILD_SHARED_LIBS": "ON",
"CMAKE_BUILD_TYPE": "Release",
"Kokkos_VERSION_DEFAULT": "4.5.01",
"Heffte_VERSION_DEFAULT": "2.4.0",
"IPPL_PLATFORMS": "OPENMP;CUDA",
"IPPL_ENABLE_FFT": "ON",
"IPPL_ENABLE_ALPINE": "ON",
"IPPL_ENABLE_COSMOLOGY": "ON",
"IPPL_ENABLE_TESTS": "OFF",
"IPPL_ENABLE_UNIT_TESTS": "OFF",
"IPPL_USE_STANDARD_FOLDERS": "ON"
}
},
{
"name": "fetch",
"displayName": "ForceDownload",
"description": "Always downloads dependencies",
"inherits": ["default"],
"cacheVariables": {
"Kokkos_VERSION": "git.4.5.01",
"Heffte_VERSION": "git.9eab7c0eb18e86acaccc2b5699b30e85a9e7bdda"
}
},
{
"name": "release-testing",
"displayName": "Testing(Release)",
"description": "Enables building test in release mode",
"inherits": ["testing", "default"]
},
{
"name": "debug-testing",
"displayName": "Testing(Debug)",
"description": "Enables building test in debug mode",
"inherits": ["testing", "default"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"IPPL_ENABLE_SANITIZER": "ON",
"IPPL_PLATFORMS": "SERIAL"
}
}
]
}
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![License](https://img.shields.io/github/license/IPPL-framework/ippl)](https://github.com/IPPL-framework/ippl/blob/master/LICENSE)

# Independent Parallel Particle Layer (IPPL)
Independent Parallel Particle Layer (IPPL) is a performance portable C++ library for Particle-Mesh methods. IPPL makes use of Kokkos (https://github.com/kokkos/kokkos), HeFFTe (https://github.com/icl-utk-edu/heffte), and MPI (Message Passing Interface) to deliver a portable, massively parallel toolkit for particle-mesh methods. IPPL supports simulations in one to six dimensions, mixed precision, and asynchronous execution in different execution spaces (e.g. CPUs and GPUs).
Independent Parallel Particle Layer (IPPL) is a performance portable C++ library for Particle-Mesh methods. IPPL makes use of Kokkos (https://github.com/kokkos/kokkos), HeFFTe (https://github.com/icl-utk-edu/heffte), and MPI (Message Passing Interface) to deliver a portable, massively parallel toolkit for particle-mesh methods. IPPL supports simulations in one to six dimensions, mixed precision, and asynchronous execution in different execution spaces (e.g. CPUs and GPUs).

All IPPL releases (< 3.2.0) are available under the BSD 3-clause license. Since version 3.2.0, this repository includes a modified version of the `variant` header by GNU, created to support compilation under CUDA 12.2 with GCC 12.3.0. This header file is available under the same terms as the [GNU Standard Library](https://github.com/gcc-mirror/gcc); note the GNU runtime library exception. As long as this file is not removed, IPPL is available under GNU GPL version 3.

Expand Down Expand Up @@ -42,11 +42,11 @@ The relevant options of IPPL are
- `IPPL_ENABLE_FFT`, default `OFF`
- If `IPPL_ENABLE_FFT` is set, `Heffte_ENABLE_CUDA` will default to `ON` if `IPPL_PLATFORMS` contains `cuda`
- Otherwise, `Heffte_ENABLE_AVX2` is enabled. FFTW has to be enabled explicitly.
- `Heffte_ENABLE_FFTW`, default `OFF`
- `Heffte_ENABLE_FFTW`, default `OFF`
- `IPPL_ENABLE_TESTS`, default `OFF`
- `IPPL_ENABLE_UNIT_TESTS`, default `OFF`
- `IPPL_ENABLE_ALPINE`, default `OFF`
- `USE_ALTERNATIVE_VARIANT`, default `OFF`. Can turned on for GPU builds where the use of the system-provided variant doesn't work.
- `IPPL_USE_ALTERNATIVE_VARIANT`, default `OFF`. Can turned on for GPU builds where the use of the system-provided variant doesn't work.
- `IPPL_ENABLE_SANITIZER, default `OFF`
-
Furthermore, be aware of `CMAKE_BUILD_TYPE`, which can be either
Expand Down Expand Up @@ -82,20 +82,20 @@ cmake .. \
-DIPPL_PLATFORMS=openmp \
-DHeffte_ENABLE_FFTW=True
```
#### Cuda alpine release build
#### Cuda alpine release build
```
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DKokkos_ARCH_[architecture]=ON \
-DCMAKE_CXX_STANDARD=20 \
-DIPPL_ENABLE_FFT=ON \
-DIPPL_ENABLE_TESTS=ON \
-DUSE_ALTERNATIVE_VARIANT=ON \
-DIPPL_USE_ALTERNATIVE_VARIANT=ON \
-DIPPL_ENABLE_SOLVERS=ON \
-DIPPL_ENABLE_ALPINE=True \
-DIPPL_PLATFORMS=cuda
```
#### HIP release build (LUMI)
#### HIP release build (LUMI)
```
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
Expand Down Expand Up @@ -135,7 +135,7 @@ m-6.0.3/lib/llvm/lib"
# Contributions
We are open and welcome contributions from others. Please open an issue and a corresponding pull request in the main repository if it is a bug fix or a minor change.

For larger projects we recommend to fork the main repository and then submit a pull request from it. More information regarding github workflow for forks can be found in this [page](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks) and how to submit a pull request from a fork can be found [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork). Please follow the coding guidelines as mentioned in this [page](https://github.com/IPPL-framework/ippl/blob/master/WORKFLOW.md).
For larger projects we recommend to fork the main repository and then submit a pull request from it. More information regarding github workflow for forks can be found in this [page](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks) and how to submit a pull request from a fork can be found [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork). Please follow the coding guidelines as mentioned in this [page](https://github.com/IPPL-framework/ippl/blob/master/WORKFLOW.md).

You can add an upstream to be able to get all the latest changes from the master. For example, if you are working with a fork of the main repository, you can add the upstream by:
```bash
Expand Down
2 changes: 1 addition & 1 deletion alpine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_subdirectory(ExamplesWithoutPicManager)

set(COMMON_LIBS
ippl
${MPI_CXX_LIBRARIES}
MPI::MPI_CXX
)

set(COMMON_FLAGS
Expand Down
18 changes: 11 additions & 7 deletions cmake/CompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
#
# Not responsible for:
# - Enabling CUDA/OpenMP/Serial → Platforms.cmake
# - Selecting platform specific compiler flags → Platforms.cmake
# - Selecting platform specific compiler flags → Platforms.cmake
#
#
# This file is only concerned with general correctness and development-time safety.
# -----------------------------------------------------------------------------


# === Basic warnings (apply to all builds) ===
add_compile_options(
-Wall
Expand All @@ -25,8 +24,8 @@ add_compile_options(
)

# === Use modified variant implementation ===
if (USE_ALTERNATIVE_VARIANT)
add_definitions (-DUSE_ALTERNATIVE_VARIANT)
if (IPPL_USE_ALTERNATIVE_VARIANT)
add_definitions (-DIPPL_USE_ALTERNATIVE_VARIANT)
endif()

# === Code coverage options ===
Expand Down Expand Up @@ -57,9 +56,14 @@ endif()
# === Debug-specific sanitizers ===
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND IPPL_ENABLE_SANITIZER)
message(STATUS "✅ Enabling AddressSanitizer and UBSan for Debug build")
add_compile_options(-fsanitize=address,undefined)
add_link_options(-fsanitize=address,undefined)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()

message(STATUS "✅ Compiler options configured")
# === Position Independent Code (PIC) for shared libraries ===
if(BUILD_SHARED_LIBS)
message(STATUS "✅ Enabling Position Independent Code (PIC) for shared libraries")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

message(STATUS "✅ Compiler options configured")
Loading