diff --git a/CMakeLists.txt b/CMakeLists.txt index 537861ab6..85be5bc6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,25 @@ # Preamble cmake_minimum_required(VERSION 3.21) + +if(DEFINED MICM_MODULE_LOADS OR DEFINED MICM_MODULE_UNLOADS) + find_package(EnvModules REQUIRED) + foreach(NEEDED_MODULE IN LISTS MICM_MODULE_LOADS) + env_module(load "${NEEDED_MODULE}") + endforeach() + foreach(UNNEEDED_MODULE IN LISTS MICM_MODULE_UNLOADS) + env_module(unload "${UNNEEDED_MODULE}") + endforeach() + env_module_list(MICM_CURRENT_MODULES) + message(STATUS "Currently loaded modules: ${MICM_CURRENT_MODULES}") + message(STATUS "Currently using $ENV{SHELL}.") + # set(MACHINE_MODULE_PATH "$ENV{MODULESHOME}") + # add_custom_target(enable-module-command + # ALL COMMAND "." "${MACHINE_MODULE_PATH}/init/bash" + # COMMAND "ml" "${MICM_MODULE_LOADS}" + # COMMAND_EXPAND_LISTS) +endif() + project( micm VERSION 3.5.0 @@ -41,6 +60,8 @@ option(MICM_ENABLE_TESTS "Build the tests" ON) option(MICM_ENABLE_EXAMPLES "Build the examples" ON) option(MICM_ENABLE_PROFILE "Profile MICM Solver" OFF) set(MICM_DEFAULT_VECTOR_MATRIX_SIZE "4" CACHE STRING "Default size for vectorizable matrix types") +set(MICM_MODULE_LOADS "" CACHE STRING "Modules to load") +set(MICM_MODULE_UNLOADS "" CACHE STRING "Modules to unload") include(CMakeDependentOption) # Option to collect custom OpenACC flags diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..d8ff07c16 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,55 @@ +{ + "version" : 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 26 + }, + "configurePresets": [ + { + "name": "derecho-gpu-configure", + "displayName": "Derecho", + "description": "Presets for the Derecho cluster", + "cacheVariables": { + "MICM_MODULE_LOADS": { + "type": "STRING", + "value": "nvhpc/23.7;gcc-toolchain/12.2.0;cuda/12.2.1" + }, + "MICM_MODULE_UNLOADS": { + "type": "STRING", + "value": "cray-mpich" + }, + "MICM_GPU_TYPE": { + "type": "STRING", + "value": "a100" + }, + "MICM_ENABLE_CUDA": { + "type": "BOOL", + "value": "ON" + } + }, + "binaryDir": "nvhpc-test" + } + ], + "buildPresets": [ + { + "name": "derecho-gpu-build", + "configurePreset" : "derecho-gpu-configure", + "inheritConfigureEnvironment": true + } + ], + "workflowPresets": [ + { + "name" : "derecho-gpu-workflow", + "steps": [ + { + "type": "configure", + "name" : "derecho-gpu-configure" + }, + { + "type": "build", + "name": "derecho-gpu-build" + } + ] + } + ] +}