From bfa315c5a4bceca9167112f0b340ddaeca7c7e53 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Thu, 15 Jan 2026 11:40:56 +0100 Subject: [PATCH 1/6] 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/6] 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/6] 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 cbd9e668723505d829136795667032a6e263d91b Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Thu, 15 Jan 2026 18:44:49 +0100 Subject: [PATCH 4/6] refactor: further slip specialization lib source files --- CMakeLists.txt | 8 ++++--- include/viennaps/process/psProcessModel.hpp | 4 ++++ include/viennaps/psVTKRenderWindow.hpp | 4 ++-- lib/specMain.cpp | 5 ---- lib/specModelsEmulation.cpp | 24 +++++++++++++++++++ ...pecModels.cpp => specModelsSimulation.cpp} | 20 ---------------- lib/specProcess.cpp | 18 ++++++++++++++ 7 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 lib/specModelsEmulation.cpp rename lib/{specModels.cpp => specModelsSimulation.cpp} (65%) create mode 100644 lib/specProcess.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dd8750b8..ccac34f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,7 +126,8 @@ CPMAddPackage( NAME ViennaLS VERSION 5.4.0 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaLS" - EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON}) + EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON} + OPTIONS "VIENNALS_PRECOMPILE_HEADERS ${VIENNAPS_PRECOMPILE_HEADERS}") CPMAddPackage( NAME ViennaCS @@ -155,8 +156,9 @@ if(VIENNAPS_PRECOMPILE_HEADERS) target_link_libraries(${LIB_NAME} PRIVATE ${PROJECT_NAME}) target_compile_definitions(${LIB_NAME} PRIVATE VIENNAPS_USE_PRECOMPILED=1 VIENNACORE_COMPILE_SHARED_LIB=1) - target_sources(${LIB_NAME} PRIVATE "lib/specMain.cpp" "lib/specGeometries.cpp" - "lib/specModels.cpp") + target_sources( + ${LIB_NAME} PRIVATE "lib/specMain.cpp" "lib/specGeometries.cpp" "lib/specModelsEmulation.cpp" + "lib/specModelsSimulation.cpp" "lib/specProcess.cpp") set_target_properties( ${LIB_NAME} diff --git a/include/viennaps/process/psProcessModel.hpp b/include/viennaps/process/psProcessModel.hpp index b82274b7..3550a82f 100644 --- a/include/viennaps/process/psProcessModel.hpp +++ b/include/viennaps/process/psProcessModel.hpp @@ -169,6 +169,8 @@ class ProcessModelCPU : public ProcessModelBase { } }; +PS_PRECOMPILE_PRECISION_DIMENSION(ProcessModelCPU) + } // namespace viennaps #ifdef VIENNACORE_COMPILE_GPU @@ -239,5 +241,7 @@ class ProcessModelGPU : public ProcessModelBase { } }; +PS_PRECOMPILE_PRECISION_DIMENSION(ProcessModelGPU) + } // namespace viennaps::gpu #endif \ No newline at end of file diff --git a/include/viennaps/psVTKRenderWindow.hpp b/include/viennaps/psVTKRenderWindow.hpp index 4f3ac8e1..32abd77a 100644 --- a/include/viennaps/psVTKRenderWindow.hpp +++ b/include/viennaps/psVTKRenderWindow.hpp @@ -626,7 +626,7 @@ class Custom3DInteractorStyle : public vtkInteractorStyleTrackballCamera { private: viennaps::VTKRenderWindow *Window = nullptr; -}; // namespace viennaps +}; // vtkStandardNewMacro(Custom3DInteractorStyle); @@ -651,7 +651,7 @@ class Custom2DInteractorStyle : public vtkInteractorStyleImage { private: viennaps::VTKRenderWindow *Window = nullptr; -}; // namespace viennaps +}; // vtkStandardNewMacro(Custom2DInteractorStyle); diff --git a/lib/specMain.cpp b/lib/specMain.cpp index fc9825b7..f462e2a5 100644 --- a/lib/specMain.cpp +++ b/lib/specMain.cpp @@ -1,9 +1,6 @@ #include #include -#include -#include - #include #include #include @@ -23,9 +20,7 @@ namespace viennaps { // Precompile specializations for commonly used classes PRECOMPILE_SPECIALIZE(Domain) -PRECOMPILE_SPECIALIZE(Process) PRECOMPILE_SPECIALIZE(Planarize) -PRECOMPILE_SPECIALIZE(ProcessModelCPU) PRECOMPILE_SPECIALIZE(Reader) PRECOMPILE_SPECIALIZE(Writer) PRECOMPILE_SPECIALIZE(GDSGeometry) diff --git a/lib/specModelsEmulation.cpp b/lib/specModelsEmulation.cpp new file mode 100644 index 00000000..16d91ec8 --- /dev/null +++ b/lib/specModelsEmulation.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include + +namespace viennaps { + +// Precompile specializations for process models +// Emulation Models +PRECOMPILE_SPECIALIZE(CSVFileProcess) +PRECOMPILE_SPECIALIZE(DirectionalProcess) +PRECOMPILE_SPECIALIZE(IsotropicProcess) + +// Geometric Models +PRECOMPILE_SPECIALIZE(BoxDistribution) +PRECOMPILE_SPECIALIZE(SphereDistribution) + +// Crystal Anisotropy Models +PRECOMPILE_SPECIALIZE(SelectiveEpitaxy) +PRECOMPILE_SPECIALIZE(WetEtching) + +} // namespace viennaps \ No newline at end of file diff --git a/lib/specModels.cpp b/lib/specModelsSimulation.cpp similarity index 65% rename from lib/specModels.cpp rename to lib/specModelsSimulation.cpp index 75b8f1d6..66d9b52c 100644 --- a/lib/specModels.cpp +++ b/lib/specModelsSimulation.cpp @@ -1,35 +1,19 @@ #include -#include -#include #include #include -#include #include #include -#include #include #include #include #include -#include #include #include #include #include -#include namespace viennaps { -// Precompile specializations for process models -// Emulation Models -PRECOMPILE_SPECIALIZE(CSVFileProcess) -PRECOMPILE_SPECIALIZE(DirectionalProcess) -PRECOMPILE_SPECIALIZE(IsotropicProcess) - -// Geometric Models -PRECOMPILE_SPECIALIZE(BoxDistribution) -PRECOMPILE_SPECIALIZE(SphereDistribution) - // Plasma Etching Models PRECOMPILE_SPECIALIZE(CF4O2Etching) PRECOMPILE_SPECIALIZE(HBrO2Etching) @@ -49,10 +33,6 @@ PRECOMPILE_SPECIALIZE(TEOSPECVD) PRECOMPILE_SPECIALIZE(FaradayCageEtching) PRECOMPILE_SPECIALIZE(IonBeamEtching) -// Crystal Anisotropy Models -PRECOMPILE_SPECIALIZE(SelectiveEpitaxy) -PRECOMPILE_SPECIALIZE(WetEtching) - // Atomic Layer Processing Models PRECOMPILE_SPECIALIZE(SingleParticleALD) diff --git a/lib/specProcess.cpp b/lib/specProcess.cpp new file mode 100644 index 00000000..f40a5467 --- /dev/null +++ b/lib/specProcess.cpp @@ -0,0 +1,18 @@ +#include +#include + +#include + +namespace viennaps { + +// Precompile specializations for commonly used classes +PRECOMPILE_SPECIALIZE(Process) +PRECOMPILE_SPECIALIZE(ProcessModelCPU) + +#ifdef VIENNACORE_COMPILE_GPU +namespace gpu { +PRECOMPILE_SPECIALIZE(ProcessModelGPU) +} // namespace gpu +#endif + +} // namespace viennaps From 7c7c49e743bca69f276224e8d813eb780bbda2aa Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 16 Jan 2026 14:47:38 +0100 Subject: [PATCH 5/6] 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 { From 3f79b7e8d14da1c49eb2ea7c7d0de522f0f6eeb9 Mon Sep 17 00:00:00 2001 From: Tobias Reiter Date: Fri, 16 Jan 2026 15:59:52 +0100 Subject: [PATCH 6/6] fix: update deps, add sanitizers correctly --- CMakeLists.txt | 4 ++-- tests/removeStrayPoints/removeStrayPoints.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24bd9f30..a91d0fff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,7 +107,7 @@ include("cmake/cpm.cmake") CPMAddPackage( NAME ViennaCore - VERSION 1.9.4 + VERSION 1.9.5 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore" EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON} OPTIONS "VIENNACORE_USE_GPU ${VIENNAPS_USE_GPU}") @@ -126,7 +126,7 @@ CPMAddPackage( CPMAddPackage( NAME ViennaLS - VERSION 5.4.0 + VERSION 5.5.0 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaLS" EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON} OPTIONS "VIENNALS_PRECOMPILE_HEADERS ${VIENNAPS_PRECOMPILE_HEADERS}") diff --git a/tests/removeStrayPoints/removeStrayPoints.cpp b/tests/removeStrayPoints/removeStrayPoints.cpp index a0be8b5c..9a587e9c 100644 --- a/tests/removeStrayPoints/removeStrayPoints.cpp +++ b/tests/removeStrayPoints/removeStrayPoints.cpp @@ -41,7 +41,7 @@ int main() { std::cout << "Number of components before removing stray points: " << domain->getNumberOfComponents() << std::endl; - VC_TEST_ASSERT(domain->getNumberOfComponents() == 7); + VC_TEST_ASSERT(domain->getNumberOfComponents() == 8); domain->removeStrayPoints(); @@ -50,12 +50,12 @@ int main() { std::cout << "Number of components after removing stray points: " << domain->getNumberOfComponents() << std::endl; - VC_TEST_ASSERT(domain->getNumberOfComponents() == 1); + VC_TEST_ASSERT(domain->getNumberOfComponents() == 2); MakeTrench(domain, 5.0, 0.0, 0.0, 1.0).apply(); domain->removeMaterial(Material::Si); - VC_TEST_ASSERT(domain->getNumberOfComponents() == 2); + VC_TEST_ASSERT(domain->getNumberOfComponents() == 3); domain->saveLevelSetMesh("testInitial"); } \ No newline at end of file