From bfa315c5a4bceca9167112f0b340ddaeca7c7e53 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Thu, 15 Jan 2026 11:40:56 +0100 Subject: [PATCH 1/4] feat: enable sanitizer build (CPU-only) --- CMakeLists.txt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd8750b8..a4cdee3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ endif() option(VIENNAPS_PRECOMPILE_HEADERS "Enable precompiled headers" OFF) option(VIENNAPS_STATIC_BUILD "Build ViennaPS as static library" OFF) +option(VIENNAPS_ENABLE_SANITIZER "Enable sanitizers" OFF) option(VIENNAPS_USE_GPU "Enable GPU support" OFF) @@ -68,7 +69,7 @@ if(VIENNAPS_BUILD_PYTHON) endif() if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp:llvm /bigobj") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp:llvm /bigobj") endif() # -------------------------------------------------------------------------------------------------------- @@ -105,7 +106,7 @@ include("cmake/cpm.cmake") CPMAddPackage( NAME ViennaCore - VERSION 1.9.2 + VERSION 1.9.3 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore" EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON} OPTIONS "VIENNACORE_USE_GPU ${VIENNAPS_USE_GPU}") @@ -137,6 +138,19 @@ CPMAddPackage( target_link_libraries(${PROJECT_NAME} INTERFACE ViennaTools::ViennaCore ViennaTools::ViennaLS ViennaTools::ViennaRay ViennaTools::ViennaCS) +# -------------------------------------------------------------------------------------------------------- +# Setup Sanitizer +# -------------------------------------------------------------------------------------------------------- + +if(VIENNAPS_ENABLE_SANITIZER) + if(VIENNAPS_USE_GPU) + message(WARNING "[ViennaPS] Sanitizers cannot be used with GPU support enabled!") + else() + viennacore_enable_sanitizer() + message(STATUS "[ViennaPS] Enabled Sanitizers") + endif() +endif() + # -------------------------------------------------------------------------------------------------------- # Setup Shared/Static Library # -------------------------------------------------------------------------------------------------------- From f274e6e0bb580d471ee88c3256f51ef388604d78 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Thu, 15 Jan 2026 13:09:33 +0100 Subject: [PATCH 2/4] chore: bump ViennaCore --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4cdee3b..fa9c51d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,7 @@ include("cmake/cpm.cmake") CPMAddPackage( NAME ViennaCore - VERSION 1.9.3 + VERSION 1.9.4 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore" EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON} OPTIONS "VIENNACORE_USE_GPU ${VIENNAPS_USE_GPU}") From db2dae8110a6daac57dc7175f87ce1de180697cb Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Thu, 15 Jan 2026 13:12:23 +0100 Subject: [PATCH 3/4] chore: enable sanitizers in CI build --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66b2725c..f0e39543 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,7 @@ jobs: path: build - name: ๐Ÿ—๏ธ Compile - run: cmake -DVIENNAPS_BUILD_TESTS=ON -B build && cmake --build build --config ${{ matrix.config }} + run: cmake -DVIENNAPS_BUILD_TESTS=ON -DVIENNAPS_ENABLE_SANITIZER=ON -B build && cmake --build build --config ${{ matrix.config }} - name: ๐Ÿงช Test run: ctest -E "Benchmark|Performance" -C ${{ matrix.config }} --test-dir build \ No newline at end of file From 7c7c49e743bca69f276224e8d813eb780bbda2aa Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 16 Jan 2026 14:47:38 +0100 Subject: [PATCH 4/4] feat: add clang-tidy build, fix: clang-tidy warnings --- CMakeLists.txt | 13 ++++++++++++- include/viennaps/models/psCF4O2Etching.hpp | 2 +- .../viennaps/models/psDirectionalProcess.hpp | 18 +++++++++--------- .../viennaps/models/psFluorocarbonEtching.hpp | 2 +- include/viennaps/models/psPlasmaEtching.hpp | 2 +- include/viennaps/psMaterials.hpp | 4 ++++ include/viennaps/psReader.hpp | 3 ++- lib/specMain.cpp | 2 ++ 8 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa9c51d9..784c7ce9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ endif() option(VIENNAPS_PRECOMPILE_HEADERS "Enable precompiled headers" OFF) option(VIENNAPS_STATIC_BUILD "Build ViennaPS as static library" OFF) option(VIENNAPS_ENABLE_SANITIZER "Enable sanitizers" OFF) +option(VIENNAPS_ENABLE_CLANG_TIDY "Run clang-tidy during build" OFF) option(VIENNAPS_USE_GPU "Enable GPU support" OFF) @@ -139,7 +140,7 @@ target_link_libraries(${PROJECT_NAME} INTERFACE ViennaTools::ViennaCore ViennaTo ViennaTools::ViennaRay ViennaTools::ViennaCS) # -------------------------------------------------------------------------------------------------------- -# Setup Sanitizer +# Setup Sanitizer or Clang-Tidy # -------------------------------------------------------------------------------------------------------- if(VIENNAPS_ENABLE_SANITIZER) @@ -151,6 +152,16 @@ if(VIENNAPS_ENABLE_SANITIZER) endif() endif() +if(VIENNAPS_ENABLE_CLANG_TIDY) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + find_program(CLANG_TIDY_EXE NAMES clang-tidy) + if(NOT CLANG_TIDY_EXE) + message(FATAL_ERROR "clang-tidy not found") + endif() + + set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" "--quiet" "--warnings-as-errors=*") +endif() + # -------------------------------------------------------------------------------------------------------- # Setup Shared/Static Library # -------------------------------------------------------------------------------------------------------- diff --git a/include/viennaps/models/psCF4O2Etching.hpp b/include/viennaps/models/psCF4O2Etching.hpp index 2a060e09..5dc4cc9a 100644 --- a/include/viennaps/models/psCF4O2Etching.hpp +++ b/include/viennaps/models/psCF4O2Etching.hpp @@ -344,7 +344,7 @@ class CF4O2Ion final const NumericType sqrt_E_th_ie_C; const NumericType sqrt_E_th_ie_Si; - NumericType E; + NumericType E = 0.; }; template diff --git a/include/viennaps/models/psDirectionalProcess.hpp b/include/viennaps/models/psDirectionalProcess.hpp index 926e4b45..ac439ede 100644 --- a/include/viennaps/models/psDirectionalProcess.hpp +++ b/include/viennaps/models/psDirectionalProcess.hpp @@ -195,15 +195,6 @@ class DirectionalProcess : public ProcessModelCPU { // Default surface model auto surfModel = SmartPointer>::New(); - // Velocity field with multiple rate sets - auto velField = - SmartPointer>::New( - std::move(rateSets)); - - this->setSurfaceModel(surfModel); - this->setVelocityField(velField); - this->setProcessName("DirectionalProcess"); - // Store process data processMetaData["DirectionalVelocity"] = std::vector(); processMetaData["IsotropicVelocity"] = std::vector(); @@ -223,6 +214,15 @@ class DirectionalProcess : public ProcessModelCPU { processMetaData["Direction " + std::to_string(i++)] = std::vector{ rateSet.direction[0], rateSet.direction[1], rateSet.direction[2]}; } + + // Velocity field with multiple rate sets + auto velField = + SmartPointer>::New( + std::move(rateSets)); + + this->setVelocityField(velField); + this->setSurfaceModel(surfModel); + this->setProcessName("DirectionalProcess"); } using ProcessModelCPU::processMetaData; diff --git a/include/viennaps/models/psFluorocarbonEtching.hpp b/include/viennaps/models/psFluorocarbonEtching.hpp index b4654d79..d9c4061b 100644 --- a/include/viennaps/models/psFluorocarbonEtching.hpp +++ b/include/viennaps/models/psFluorocarbonEtching.hpp @@ -346,7 +346,7 @@ class FluorocarbonIon const FluorocarbonParameters &p; const NumericType A; NumericType minEnergy = std::numeric_limits::max(); - NumericType E; + NumericType E = 0.; public: FluorocarbonIon(const FluorocarbonParameters ¶meters) diff --git a/include/viennaps/models/psPlasmaEtching.hpp b/include/viennaps/models/psPlasmaEtching.hpp index b1d065bf..7dd93ec7 100644 --- a/include/viennaps/models/psPlasmaEtching.hpp +++ b/include/viennaps/models/psPlasmaEtching.hpp @@ -327,7 +327,7 @@ class PlasmaEtchingIon const NumericType sqrt_E_th_ie_P; const NumericType sqrt_E_th_ie_Sub; - NumericType E; + NumericType E = 0.; }; template diff --git a/include/viennaps/psMaterials.hpp b/include/viennaps/psMaterials.hpp index 23490026..e69ca772 100644 --- a/include/viennaps/psMaterials.hpp +++ b/include/viennaps/psMaterials.hpp @@ -216,6 +216,10 @@ class MaterialMap { } static inline Material mapToMaterial(const int matId) { + if (matId < 0 || matId > static_cast(kMaterialMaxId)) { + VIENNACORE_LOG_ERROR("Invalid material id " + std::to_string(matId)); + return Material::GAS; + } return static_cast(matId); } diff --git a/include/viennaps/psReader.hpp b/include/viennaps/psReader.hpp index e4246b58..d2c24390 100644 --- a/include/viennaps/psReader.hpp +++ b/include/viennaps/psReader.hpp @@ -3,6 +3,7 @@ #include "psDomain.hpp" #include "psPreCompileMacros.hpp" +#include #include #include #include @@ -66,7 +67,7 @@ template class Reader { // Check identifier char identifier[8]; fin.read(identifier, 8); - if (std::string(identifier).compare(0, 8, "psDomain")) { + if (std::memcmp(identifier, "psDomain", 8) != 0) { VIENNACORE_LOG_ERROR( "Reading domain from stream failed. Header could not be found."); return; diff --git a/lib/specMain.cpp b/lib/specMain.cpp index fc9825b7..a3965253 100644 --- a/lib/specMain.cpp +++ b/lib/specMain.cpp @@ -16,8 +16,10 @@ #include +#ifdef VIENNACORE_COMPILE_GPU // this include may only appear in a single source file: #include +#endif namespace viennaps {