From 3d322b355824f06caa7721e2a1fece33ebe447bb Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Tue, 17 Feb 2026 10:39:03 +0100 Subject: [PATCH 01/11] test: add -cache option to the test script to accelerate the build --- pytools/idfx_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pytools/idfx_test.py b/pytools/idfx_test.py index 25bac76b..42eb70b7 100644 --- a/pytools/idfx_test.py +++ b/pytools/idfx_test.py @@ -98,7 +98,10 @@ def __init__ (self): parser.add_argument("-Werror", help="Consider warnings as errors", action="store_true") - + + parser.add_argument("-ccache", + help="Use CCache to reduce the build time over multiple run of the test suite.", + action="store_true") args, unknown=parser.parse_known_args() @@ -169,6 +172,9 @@ def configure(self,definitionFile=""): elif(self.reconstruction==4): comm.append("-DIdefix_RECONSTRUCTION=Parabolic") + # export ccache env + if self.ccache: + comm.append("-DCMAKE_CXX_COMPILER_LAUNCHER=ccache") try: cmake=subprocess.run(comm) From 202e380983f0e10f8b3e47fe358aea983d069190 Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Tue, 17 Feb 2026 10:39:31 +0100 Subject: [PATCH 02/11] test: enable usage of -ccache on tests in the github action scripts --- .github/workflows/idefix-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/idefix-ci.yml b/.github/workflows/idefix-ci.yml index cb946143..fb773110 100644 --- a/.github/workflows/idefix-ci.yml +++ b/.github/workflows/idefix-ci.yml @@ -28,7 +28,7 @@ jobs: name: CPU Jobs (intel OneApi) uses: ./.github/workflows/idefix-ci-jobs.yml with: - TESTME_OPTIONS: -intel -Werror + TESTME_OPTIONS: -intel -Werror -ccache IDEFIX_COMPILER: icc gcc-jobs: @@ -36,7 +36,7 @@ jobs: name: CPU Jobs (gcc) uses: ./.github/workflows/idefix-ci-jobs.yml with: - TESTME_OPTIONS: -Werror + TESTME_OPTIONS: -Werror -ccache IDEFIX_COMPILER: gcc cuda-jobs: @@ -44,5 +44,5 @@ jobs: name: CUDA Jobs uses: ./.github/workflows/idefix-ci-jobs.yml with: - TESTME_OPTIONS: -cuda -Werror + TESTME_OPTIONS: -cuda -Werror -ccache IDEFIX_COMPILER: nvcc From c19ed7219b6326d3f70775f64ec587f8f04405bb Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Tue, 17 Feb 2026 11:10:59 +0100 Subject: [PATCH 03/11] test: fix linter issue due to empty line spaces + cache name in help message. --- pytools/idfx_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytools/idfx_test.py b/pytools/idfx_test.py index 42eb70b7..942cb32d 100644 --- a/pytools/idfx_test.py +++ b/pytools/idfx_test.py @@ -98,9 +98,9 @@ def __init__ (self): parser.add_argument("-Werror", help="Consider warnings as errors", action="store_true") - + parser.add_argument("-ccache", - help="Use CCache to reduce the build time over multiple run of the test suite.", + help="Use ccache to reduce the build time over multiple run of the test suite.", action="store_true") args, unknown=parser.parse_known_args() From 077d0179a71c3fc1e652cc0eb9b5d34ef5624b4c Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Mon, 16 Feb 2026 23:19:01 +0100 Subject: [PATCH 04/11] build: Add option -DIdefix_PROBLEM_DIR to allow using the standard out-of-source build way of cmake --- CMakeLists.txt | 24 ++++++++++++++++-------- src/input.cpp | 7 +++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7c856dd..e0447e78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ option(Idefix_DEBUG "Enable Idefix debug features (makes the code very slow)" OF option(Idefix_RUNTIME_CHECKS "Enable runtime sanity checks" OFF) option(Idefix_WERROR "Treat compiler warnings as errors" OFF) option(Idefix_PYTHON "Enable python bindings (requires pybind11)" OFF) +Option(Idefix_PROBLEM_DIR "Define the directory of the case to build for." ${PROJECT_BINARY_DIR}) set(Idefix_CXX_FLAGS "" CACHE STRING "Additional compiler/linker flag") set(Idefix_DEFS "definitions.hpp" CACHE FILEPATH "Problem definition header file") option(Idefix_CUSTOM_EOS "Use custom equation of state" OFF) @@ -34,7 +35,6 @@ set_property(CACHE Idefix_PRECISION PROPERTY STRINGS Double Single) set(Idefix_LOOP_PATTERN "Default" CACHE STRING "Loop pattern for idefix_for") set_property(CACHE Idefix_LOOP_PATTERN PROPERTY STRINGS Default SIMD Range MDRange TeamPolicy TeamPolicyInnerVector) - # load git revision tools list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") include(GetGitRevisionDescription) @@ -51,7 +51,7 @@ if(Kokkos_ENABLE_CUDA) endif() # Add kokkos CMAKE files (required early since these set compiler options) -add_subdirectory(src/kokkos build/kokkos) +add_subdirectory(src/kokkos ${CMAKE_BINARY_DIR}/build/kokkos) include_directories(${Kokkos_INCLUDE_DIRS_RET}) # Add Idefix CXX Flags @@ -75,19 +75,27 @@ endif() add_executable(idefix) add_subdirectory(src build) -if(EXISTS ${PROJECT_BINARY_DIR}/setup.cpp) - target_sources(idefix PUBLIC ${PROJECT_BINARY_DIR}/setup.cpp) +# make absolute +get_filename_component(Idefix_PROBLEM_DIR_ABS "${Idefix_PROBLEM_DIR}" REALPATH BASE_DIR "${PROJECT_BINARY_DIR}") + +if(EXISTS ${Idefix_PROBLEM_DIR_ABS}/setup.cpp) + target_sources(idefix PUBLIC ${Idefix_PROBLEM_DIR_ABS}/setup.cpp) else() message(WARNING "No specific setup.cpp found in the problem directory (this message can be ignored if using python to define your problem)") endif() # If a CMakeLists.txt is in the problem dir (for problem-specific source files) # then read it -if(EXISTS ${PROJECT_BINARY_DIR}/CMakeLists.txt) - message(STATUS "Including problem-specific CMakeLists in '${PROJECT_BINARY_DIR}'") - add_subdirectory(${PROJECT_BINARY_DIR} build/setup) +if(EXISTS ${Idefix_PROBLEM_DIR_ABS}/CMakeLists.txt) + message(STATUS "Including problem-specific CMakeLists in '${Idefix_PROBLEM_DIR_ABS}'") + add_subdirectory(${Idefix_PROBLEM_DIR_ABS} build/setup) endif() +# if case dir is not PROJECT_BUILD_DIR we need to point the remote config as backup +# if the user don't copy it locally +if (NOT Idefix_PROBLEM_DIR STREQUAL PROJECT_BUILD_DIR) + add_definitions(-DIDEFIX_CASE_INI_FALLBACK="${Idefix_PROBLEM_DIR}/idefix.ini") +endif() if(Idefix_MHD) add_compile_definitions("MHD=YES") @@ -210,7 +218,7 @@ if(${Idefix_PRECISION} STREQUAL "Single") endif() target_include_directories(idefix PUBLIC - "${PROJECT_BINARY_DIR}" + "${Idefix_PROBLEM_DIR_ABS}" ) target_include_directories(idefix PUBLIC src/kokkos/core/src diff --git a/src/input.cpp b/src/input.cpp index 33641495..af0f3b57 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "idefix.hpp" #include "input.hpp" @@ -54,6 +55,12 @@ Input::Input(int argc, char* argv[] ) { // Default input file name this->inputFileName = std::string("idefix.ini"); + // Default backup if not copied locally and Idefix_CASE_DIR is not local one + #ifdef IDEFIX_CASE_INI_FALLBACK + if (!std::filesystem::exists(this->inputFileName)) + this->inputFileName = IDEFIX_CASE_INI_FALLBACK; + #endif + // Parse command line (may replace the input file) ParseCommandLine(argc,argv); From c6e885d6888cdbbd4050525de75f77c54153e3e1 Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Tue, 17 Feb 2026 13:29:25 +0100 Subject: [PATCH 05/11] test: use the new -DIdefix_PROBLEM_DIR to build the tests into their own sub directory (./build-test) --- CMakeLists.txt | 7 +------ pytools/idfx_test.py | 26 ++++++++++++++++++++++---- src/input.cpp | 7 ------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0447e78..fb804072 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,12 +91,6 @@ if(EXISTS ${Idefix_PROBLEM_DIR_ABS}/CMakeLists.txt) add_subdirectory(${Idefix_PROBLEM_DIR_ABS} build/setup) endif() -# if case dir is not PROJECT_BUILD_DIR we need to point the remote config as backup -# if the user don't copy it locally -if (NOT Idefix_PROBLEM_DIR STREQUAL PROJECT_BUILD_DIR) - add_definitions(-DIDEFIX_CASE_INI_FALLBACK="${Idefix_PROBLEM_DIR}/idefix.ini") -endif() - if(Idefix_MHD) add_compile_definitions("MHD=YES") else() @@ -257,6 +251,7 @@ message(STATUS " Python: ${Idefix_PYTHON}") message(STATUS " Reconstruction: ${Idefix_RECONSTRUCTION}") message(STATUS " Precision: ${Idefix_PRECISION}") message(STATUS " Version: ${Idefix_VERSION}") +message(STATUS " Problem directory: '${Idefix_PROBLEM_DIR_ABS}'") message(STATUS " Problem definitions: '${Idefix_DEFS}'") if(Idefix_CUSTOM_EOS) message(STATUS " EOS: Custom file '${Idefix_CUSTOM_EOS_FILE}'") diff --git a/pytools/idfx_test.py b/pytools/idfx_test.py index 942cb32d..fed74a22 100644 --- a/pytools/idfx_test.py +++ b/pytools/idfx_test.py @@ -110,11 +110,19 @@ def __init__ (self): self.referenceDirectory = os.path.join(idefix_dir_env,"reference") # current directory relative to $IDEFIX_DIR/test (used to retrieve the path ot reference files) self.testDir=os.path.relpath(os.curdir,os.path.join(idefix_dir_env,"test")) + # build directory, currently inside the test named build-test + self.buildDir=os.path.abspath("./build-test") + # store the full path of problem directory + self.problemDir=os.path.abspath("./") def configure(self,definitionFile=""): comm=["cmake"] # add source directory comm.append(self.idefixDir) + + # we will build in ./build-test so problem dir is parent + comm.append("-DIdefix_PROBLEM_DIR="+self.problemDir) + # add specific options for opt in self.cmake: comm.append("-D"+opt) @@ -158,7 +166,7 @@ def configure(self,definitionFile=""): else: self.definitions="definitions.hpp" - comm.append("-DIdefix_DEFS="+self.definitions) + comm.append("-DIdefix_DEFS="+os.path.join(self.problemDir, self.definitions)) if(self.mpi): comm.append("-DIdefix_MPI=ON") @@ -177,7 +185,11 @@ def configure(self,definitionFile=""): comm.append("-DCMAKE_CXX_COMPILER_LAUNCHER=ccache") try: - cmake=subprocess.run(comm) + # clean before configuring again + self.clean() + + # call cmake + cmake=subprocess.run(comm, cwd=os.path.abspath(self.buildDir)) cmake.check_returncode() except subprocess.CalledProcessError as e: print(bcolors.FAIL+"***************************************************") @@ -185,9 +197,15 @@ def configure(self,definitionFile=""): print("***************************************************"+bcolors.ENDC) raise e + def clean(self): + # remove the build directory before re-creating it + if os.path.exists(self.buildDir): + shutil.rmtree(self.buildDir) + os.makedirs(self.buildDir, exist_ok=False) + def compile(self,jobs=8): try: - make=subprocess.run(["make","-j"+str(jobs)]) + make=subprocess.run(["make","-j"+str(jobs)], cwd=os.path.abspath(self.buildDir)) make.check_returncode() except subprocess.CalledProcessError as e: print(bcolors.FAIL+"***************************************************") @@ -196,7 +214,7 @@ def compile(self,jobs=8): raise e def run(self, inputFile="", np=2, nowrite=False, restart=-1): - comm=["./idefix"] + comm=[os.path.join(self.buildDir,"idefix")] if inputFile: comm.append("-i") comm.append(inputFile) diff --git a/src/input.cpp b/src/input.cpp index af0f3b57..33641495 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include "idefix.hpp" #include "input.hpp" @@ -55,12 +54,6 @@ Input::Input(int argc, char* argv[] ) { // Default input file name this->inputFileName = std::string("idefix.ini"); - // Default backup if not copied locally and Idefix_CASE_DIR is not local one - #ifdef IDEFIX_CASE_INI_FALLBACK - if (!std::filesystem::exists(this->inputFileName)) - this->inputFileName = IDEFIX_CASE_INI_FALLBACK; - #endif - // Parse command line (may replace the input file) ParseCommandLine(argc,argv); From 4af7e8a3eedc100a48ddf6d0ca9eabe054a8847f Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Tue, 17 Feb 2026 14:30:02 +0100 Subject: [PATCH 06/11] test: disable ccache for CUDA --- .github/workflows/idefix-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/idefix-ci.yml b/.github/workflows/idefix-ci.yml index fb773110..f0050b36 100644 --- a/.github/workflows/idefix-ci.yml +++ b/.github/workflows/idefix-ci.yml @@ -44,5 +44,5 @@ jobs: name: CUDA Jobs uses: ./.github/workflows/idefix-ci-jobs.yml with: - TESTME_OPTIONS: -cuda -Werror -ccache + TESTME_OPTIONS: -cuda -Werror IDEFIX_COMPILER: nvcc From de40090676d67070ec25f9c0de4bcd0b8077be50 Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Tue, 17 Feb 2026 17:51:40 +0100 Subject: [PATCH 07/11] build: fix issue with the -DIdefix_PROBLEM_DIR default value --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb804072..93f64e3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ option(Idefix_DEBUG "Enable Idefix debug features (makes the code very slow)" OF option(Idefix_RUNTIME_CHECKS "Enable runtime sanity checks" OFF) option(Idefix_WERROR "Treat compiler warnings as errors" OFF) option(Idefix_PYTHON "Enable python bindings (requires pybind11)" OFF) -Option(Idefix_PROBLEM_DIR "Define the directory of the case to build for." ${PROJECT_BINARY_DIR}) +set(Idefix_PROBLEM_DIR "${CMAKE_BINARY_DIR}" CACHE STRING "Define the directory of the case to build for.") set(Idefix_CXX_FLAGS "" CACHE STRING "Additional compiler/linker flag") set(Idefix_DEFS "definitions.hpp" CACHE FILEPATH "Problem definition header file") option(Idefix_CUSTOM_EOS "Use custom equation of state" OFF) @@ -76,7 +76,7 @@ add_executable(idefix) add_subdirectory(src build) # make absolute -get_filename_component(Idefix_PROBLEM_DIR_ABS "${Idefix_PROBLEM_DIR}" REALPATH BASE_DIR "${PROJECT_BINARY_DIR}") +file(REAL_PATH ${Idefix_PROBLEM_DIR} Idefix_PROBLEM_DIR_ABS BASE_DIRECTORY ${PROJECT_BINARY_DIR}) if(EXISTS ${Idefix_PROBLEM_DIR_ABS}/setup.cpp) target_sources(idefix PUBLIC ${Idefix_PROBLEM_DIR_ABS}/setup.cpp) From 1258056a3b9eef3d064f3af4fd2f201fd0353d96 Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Tue, 17 Feb 2026 17:51:40 +0100 Subject: [PATCH 08/11] build: prefer using get_filename_component(ABSOLUTE) which is compatible cmake 3.4 again 3.19 for file(REAL_PATH) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93f64e3a..987d41f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ add_executable(idefix) add_subdirectory(src build) # make absolute -file(REAL_PATH ${Idefix_PROBLEM_DIR} Idefix_PROBLEM_DIR_ABS BASE_DIRECTORY ${PROJECT_BINARY_DIR}) +get_filename_component(Idefix_PROBLEM_DIR_ABS ${Idefix_PROBLEM_DIR} ABSOLUTE BASE_DIR ${PROJECT_BINARY_DIR}) if(EXISTS ${Idefix_PROBLEM_DIR_ABS}/setup.cpp) target_sources(idefix PUBLIC ${Idefix_PROBLEM_DIR_ABS}/setup.cpp) From 2c6526d45412b813340f91852f2eda37430d1624 Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Fri, 20 Feb 2026 15:55:44 +0100 Subject: [PATCH 09/11] build: update documentation message about Idefix_PROBLEM_DIR. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 987d41f0..27131df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ option(Idefix_DEBUG "Enable Idefix debug features (makes the code very slow)" OF option(Idefix_RUNTIME_CHECKS "Enable runtime sanity checks" OFF) option(Idefix_WERROR "Treat compiler warnings as errors" OFF) option(Idefix_PYTHON "Enable python bindings (requires pybind11)" OFF) -set(Idefix_PROBLEM_DIR "${CMAKE_BINARY_DIR}" CACHE STRING "Define the directory of the case to build for.") +set(Idefix_PROBLEM_DIR "${CMAKE_BINARY_DIR}" CACHE STRING "Define the directory of the problem to build for.") set(Idefix_CXX_FLAGS "" CACHE STRING "Additional compiler/linker flag") set(Idefix_DEFS "definitions.hpp" CACHE FILEPATH "Problem definition header file") option(Idefix_CUSTOM_EOS "Use custom equation of state" OFF) From 446ad687a96508f8da63fbff97e6e82796b36b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Valat?= Date: Fri, 20 Feb 2026 16:35:16 +0100 Subject: [PATCH 10/11] build: fix help message and printing about -DIdefix_PROBLEM_DIR Co-authored-by: Geoffroy Lesur --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27131df8..f4a647fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ option(Idefix_DEBUG "Enable Idefix debug features (makes the code very slow)" OF option(Idefix_RUNTIME_CHECKS "Enable runtime sanity checks" OFF) option(Idefix_WERROR "Treat compiler warnings as errors" OFF) option(Idefix_PYTHON "Enable python bindings (requires pybind11)" OFF) -set(Idefix_PROBLEM_DIR "${CMAKE_BINARY_DIR}" CACHE STRING "Define the directory of the problem to build for.") +set(Idefix_PROBLEM_DIR "${CMAKE_BINARY_DIR}" CACHE STRING "Problem directory to build for.") set(Idefix_CXX_FLAGS "" CACHE STRING "Additional compiler/linker flag") set(Idefix_DEFS "definitions.hpp" CACHE FILEPATH "Problem definition header file") option(Idefix_CUSTOM_EOS "Use custom equation of state" OFF) @@ -251,7 +251,7 @@ message(STATUS " Python: ${Idefix_PYTHON}") message(STATUS " Reconstruction: ${Idefix_RECONSTRUCTION}") message(STATUS " Precision: ${Idefix_PRECISION}") message(STATUS " Version: ${Idefix_VERSION}") -message(STATUS " Problem directory: '${Idefix_PROBLEM_DIR_ABS}'") +message(STATUS " Problem directory: '${Idefix_PROBLEM_DIR}'") message(STATUS " Problem definitions: '${Idefix_DEFS}'") if(Idefix_CUSTOM_EOS) message(STATUS " EOS: Custom file '${Idefix_CUSTOM_EOS_FILE}'") From 7d1657d80637028910923d26e2fd8b35097643aa Mon Sep 17 00:00:00 2001 From: Sebastien Valat Date: Fri, 20 Feb 2026 16:59:27 +0100 Subject: [PATCH 11/11] build: update the documentation about usage of -DIdefix_PROBLEM_DIR --- doc/source/reference/makefile.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/source/reference/makefile.rst b/doc/source/reference/makefile.rst index 23052d92..8f58ceed 100644 --- a/doc/source/reference/makefile.rst +++ b/doc/source/reference/makefile.rst @@ -59,6 +59,12 @@ Several options can be enabled from the command line (or are accessible with ``c The number of ghost cells is automatically adjusted as a function of the order of the reconstruction scheme. *Idefix* uses 2 ghost cells when ``ORDER < 4`` and 3 ghost cells when ``ORDER = 4`` +``-D Idefix_PROBLEM_DIR=.`` + Specify where to find the problem directory to build *Idefix* out of source. + Place yourself in the ``build`` directory you want to build in and call the ``cmake`` by : + + pointing the *Idefix* source directory via ``IDEFIX_DIR`` as usual. + + using ``-D Idefix_PROBLEM_DIR`` to point the problem to build. + ``-D Kokkos_ENABLE_OPENMP=ON`` Enable OpenMP parallelisation on supported compilers. Note that this can be enabled simultaneously with MPI, resulting in a hybrid MPI+OpenMP compilation.