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 diff --git a/CMakeLists.txt b/CMakeLists.txt index dd8750b8..784c7ce9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,8 @@ 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) @@ -68,7 +70,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 +107,7 @@ include("cmake/cpm.cmake") CPMAddPackage( NAME ViennaCore - VERSION 1.9.2 + VERSION 1.9.4 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore" EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON} OPTIONS "VIENNACORE_USE_GPU ${VIENNAPS_USE_GPU}") @@ -137,6 +139,29 @@ CPMAddPackage( target_link_libraries(${PROJECT_NAME} INTERFACE ViennaTools::ViennaCore ViennaTools::ViennaLS ViennaTools::ViennaRay ViennaTools::ViennaCS) +# -------------------------------------------------------------------------------------------------------- +# Setup Sanitizer or Clang-Tidy +# -------------------------------------------------------------------------------------------------------- + +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() + +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 {