From 66c0ad07c421a4c2ec0a782cc7ce27d790467150 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 16:19:43 +0800 Subject: [PATCH 01/13] use system gtest if possible --- .github/workflows/manifold.yml | 6 ++--- flake.lock | 48 ++++++++++++++++++++++++++++----- flake.nix | 14 ++++++---- test/CMakeLists.txt | 23 +++++++++++++--- test/third_party/CMakeLists.txt | 37 ------------------------- test/third_party/google_test | 1 - 6 files changed, 74 insertions(+), 55 deletions(-) delete mode 100644 test/third_party/CMakeLists.txt delete mode 160000 test/third_party/google_test diff --git a/.github/workflows/manifold.yml b/.github/workflows/manifold.yml index 20d175d34..bbc606292 100644 --- a/.github/workflows/manifold.yml +++ b/.github/workflows/manifold.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: | apt-get -y update - DEBIAN_FRONTEND=noninteractive apt install -y libomp-dev libassimp-dev git libtbb-dev pkg-config libpython3-dev python3 python3-distutils python3-pip lcov + DEBIAN_FRONTEND=noninteractive apt install -y libgtest-dev libomp-dev libassimp-dev git libtbb-dev pkg-config libpython3-dev python3 python3-distutils python3-pip lcov pip install trimesh - uses: actions/checkout@v3 with: @@ -80,7 +80,7 @@ jobs: - name: Install dependencies run: | apt-get -y update - DEBIAN_FRONTEND=noninteractive apt install -y libomp-dev libassimp-dev git libtbb-dev pkg-config libpython3-dev python3 python3-distutils python3-pip + DEBIAN_FRONTEND=noninteractive apt install -y libgtest-dev libomp-dev libassimp-dev git libtbb-dev pkg-config libpython3-dev python3 python3-distutils python3-pip - uses: actions/checkout@v3 with: submodules: recursive @@ -194,7 +194,7 @@ jobs: steps: - name: Install common dependencies run: | - brew install pkg-config assimp + brew install pkg-config googletest assimp pip install trimesh - name: Install OpenMP if: matrix.parallel_backend == 'OMP' diff --git a/flake.lock b/flake.lock index 56a2baf29..47f6c17b3 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1649676176, - "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "owner": "numtide", "repo": "flake-utils", - "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "type": "github" }, "original": { @@ -15,13 +18,30 @@ "type": "github" } }, + "gtest-src": { + "flake": false, + "locked": { + "lastModified": 1690989893, + "narHash": "sha256-t0RchAHTJbuI5YW4uyBPykTvcjy90JW9AOPNjIhwh6U=", + "owner": "google", + "repo": "googletest", + "rev": "f8d7d77c06936315286eb55f8de22cd23c188571", + "type": "github" + }, + "original": { + "owner": "google", + "ref": "v1.14.0", + "repo": "googletest", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1689008574, - "narHash": "sha256-VFMgyHDiqsGDkRg73alv6OdHJAqhybryWHv77bSCGIw=", + "lastModified": 1691006197, + "narHash": "sha256-DbtxVWPt+ZP5W0Usg7jAyTomIM//c3Jtfa59Ht7AV8s=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4a729ce4b1fe5ec4fffc71c67c96aa5184ebb462", + "rev": "66aedfd010204949cb225cf749be08cb13ce1813", "type": "github" }, "original": { @@ -33,8 +53,24 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "gtest-src": "gtest-src", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 04ffc90ed..f2af6d33e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,12 @@ { inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.nixpkgs.url = "nixpkgs/nixos-unstable"; + inputs.gtest-src = { + url = "github:google/googletest/v1.14.0"; + flake = false; + }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, flake-utils, gtest-src }: flake-utils.lib.eachDefaultSystem (system: let @@ -25,7 +29,7 @@ "manifold-${parallel-backend}"; version = "beta"; src = self; - nativeBuildInputs = (with pkgs; [ cmake (python39.withPackages (ps: with ps; [ trimesh ])) ]) ++ build-tools ++ + nativeBuildInputs = (with pkgs; [ cmake (python39.withPackages (ps: with ps; [ trimesh ])) gtest ]) ++ build-tools ++ (if cuda-support then with pkgs.cudaPackages; [ cuda_nvcc cuda_cudart cuda_cccl pkgs.addOpenGLRunpath ] else [ ]); cmakeFlags = [ "-DMANIFOLD_PYBIND=ON" @@ -75,6 +79,8 @@ emscripten tbb lcov + gtest + tracy ] ++ additional; }; in @@ -98,9 +104,7 @@ export EM_CACHE=$(pwd)/.emscriptencache mkdir build cd build - mkdir cache - export EM_CACHE=$(pwd)/cache - emcmake cmake -DCMAKE_BUILD_TYPE=Release .. + emcmake cmake -DCMAKE_BUILD_TYPE=Release -DFETCHCONTENT_SOURCE_DIR_GOOGLETEST=${gtest-src} .. ''; buildPhase = '' emmake make -j''${NIX_BUILD_CORES} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c1f61f103..db89e5445 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,8 +14,6 @@ project(manifold_test) -add_subdirectory(third_party) - enable_testing() set(SOURCE_FILES polygon_test.cpp cross_section_test.cpp manifold_test.cpp boolean_test.cpp sdf_test.cpp samples_test.cpp test_main.cpp) @@ -24,8 +22,27 @@ if(MANIFOLD_CBIND) list(APPEND SOURCE_FILES manifoldc_test.cpp) endif() +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +# Prevent installation of GTest with your project +set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) +set(INSTALL_GMOCK OFF CACHE BOOL "" FORCE) + +find_package(GTest) +if(NOT GTest_FOUND) + message(STATUS "GTest not found, downloading from source") + include(FetchContent) + FetchContent_Declare(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.14.0 + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + ) + FetchContent_MakeAvailable(googletest) +endif() + add_executable(${PROJECT_NAME} ${SOURCE_FILES}) -target_link_libraries(${PROJECT_NAME} polygon GTest::GTest manifold sdf samples samplesGPU cross_section) +target_link_libraries(${PROJECT_NAME} polygon gtest manifold sdf samples samplesGPU cross_section) + if(MANIFOLD_CBIND) target_link_libraries(${PROJECT_NAME} manifoldc) diff --git a/test/third_party/CMakeLists.txt b/test/third_party/CMakeLists.txt deleted file mode 100644 index 6319b9627..000000000 --- a/test/third_party/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2020 The Manifold Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# ########################################################################### -# Build Google Test # -# ########################################################################### -# Prevent overriding the parent project's compiler/linker -# settings on Windows -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - -# Prevent installation of GTest with your project -set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) -set(INSTALL_GMOCK OFF CACHE BOOL "" FORCE) - -add_subdirectory(google_test) - -# Add aliases for GTest and GMock libraries -if(NOT TARGET GTest::GTest) - add_library(GTest::GTest ALIAS gtest) - add_library(GTest::Main ALIAS gtest_main) -endif() - -if(NOT TARGET GTest::GMock) - add_library(GMock::GMock ALIAS gmock) - add_library(GMock::Main ALIAS gmock_main) -endif() diff --git a/test/third_party/google_test b/test/third_party/google_test deleted file mode 160000 index 2fe3bd994..000000000 --- a/test/third_party/google_test +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2fe3bd994b3189899d93f1d5a881e725e046fdc2 From 4579ede7e4a93a7087b21c51c287b62a600398fb Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 16:27:34 +0800 Subject: [PATCH 02/13] optional tracy support --- CMakeLists.txt | 1 + README.md | 5 +++++ test/CMakeLists.txt | 11 +++++++++++ test/test_main.cpp | 14 +++++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 021c8ffe9..f08447ba8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,7 @@ option(MANIFOLD_DEBUG "Enable debug tracing/timing" OFF) option(MANIFOLD_USE_CUDA "Enable GPU support via CUDA" OFF) option(MANIFOLD_PYBIND "Build python bindings" ON) option(MANIFOLD_CBIND "Build C (FFI) bindings" OFF) +option(TRACY_ENABLE "Use tracy profiling" OFF) set(MANIFOLD_PAR "NONE" CACHE STRING "Parallel backend, either \"TBB\" or \"OpenMP\" or \"NONE\"") set(MANIFOLD_FLAGS -O3) diff --git a/README.md b/README.md index 3f3e03853..a41d7648e 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,11 @@ For more detailed documentation, please refer to the C++ API. Contributions are welcome! A lower barrier contribution is to simply make a PR that adds a test, especially if it repros an issue you've found. Simply name it prepended with DISABLED_, so that it passes the CI. That will be a very strong signal to me to fix your issue. However, if you know how to fix it yourself, then including the fix in your PR would be much appreciated! +## Profiling + +There is now basic support for the [Tracy profiler](https://github.com/wolfpld/tracy) for our tests. +To enable tracing, compile with `-DTRACY_ENABLE=on` cmake option, and run the test with administrator privileges. + ## About the author This library was started by [Emmett Lalish](https://elalish.blogspot.com/). I am currently a Google employee and this is my 20% project, not an official Google project. At my day job I'm the maintainer of [\](https://modelviewer.dev/). I was the first employee at a 3D video startup, [Omnivor](https://www.omnivor.io/), and before that I worked on 3D printing at Microsoft, including [3D Builder](https://www.microsoft.com/en-us/p/3d-builder/9wzdncrfj3t6?activetab=pivot%3Aoverviewtab). Originally an aerospace engineer, I started at a small DARPA contractor doing seedling projects, one of which became [Sea Hunter](https://en.wikipedia.org/wiki/Sea_Hunter). I earned my doctorate from the University of Washington in control theory and published some [papers](https://www.researchgate.net/scientific-contributions/75011026_Emmett_Lalish). diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index db89e5445..9e87be7ca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -43,6 +43,17 @@ endif() add_executable(${PROJECT_NAME} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} polygon gtest manifold sdf samples samplesGPU cross_section) +if (TRACY_ENABLE) + include(FetchContent) + FetchContent_Declare(tracy + GIT_REPOSITORY https://github.com/wolfpld/tracy.git + GIT_TAG v0.9.1 + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + ) + FetchContent_MakeAvailable(tracy) + target_link_libraries(${PROJECT_NAME} TracyClient) +endif() if(MANIFOLD_CBIND) target_link_libraries(${PROJECT_NAME} manifoldc) diff --git a/test/test_main.cpp b/test/test_main.cpp index 58073962c..964295416 100644 --- a/test/test_main.cpp +++ b/test/test_main.cpp @@ -17,6 +17,14 @@ #include "sdf.h" #include "test.h" +// we need to call some tracy API to establish the connection +#if __has_include() +#include +#else +#define FrameMarkStart(x) +#define FrameMarkEnd(x) +#endif + using namespace manifold; Options options; @@ -34,6 +42,9 @@ void print_usage() { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); + const char* name = "test setup"; + FrameMarkStart(name); + for (int i = 1; i < argc; i++) { if (argv[i][0] != '-') { fprintf(stderr, "Unknown option: %s\n", argv[i]); @@ -67,6 +78,7 @@ int main(int argc, char** argv) { manifold::PolygonParams().intermediateChecks = true; manifold::PolygonParams().processOverlaps = false; + FrameMarkEnd(name); return RUN_ALL_TESTS(); } @@ -442,4 +454,4 @@ void CheckGL(const Manifold& manifold) { EXPECT_EQ(meshGL.runTransform.size(), 12 * meshGL.runOriginalID.size()); } EXPECT_EQ(meshGL.faceID.size(), meshGL.NumTri()); -} \ No newline at end of file +} From a80c57cabd510f7fccd83bb063fa78ff80ce6f52 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 14:58:36 +0800 Subject: [PATCH 03/13] fix meshid not found situation --- src/manifold/src/manifold.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/manifold/src/manifold.cpp b/src/manifold/src/manifold.cpp index 057a97159..452060b65 100644 --- a/src/manifold/src/manifold.cpp +++ b/src/manifold/src/manifold.cpp @@ -260,7 +260,10 @@ MeshGL Manifold::GetMeshGL(glm::ivec3 normalIdx) const { out.triVerts[3 * tri + i] = impl.halfedge_[3 * oldTri + i].startVert; if (meshID != lastID) { - addRun(out, runNormalTransform, tri, meshIDtransform.at(meshID)); + Impl::Relation rel; + auto it = meshIDtransform.find(meshID); + if (it != meshIDtransform.end()) rel = it->second; + addRun(out, runNormalTransform, tri, rel); meshIDtransform.erase(meshID); lastID = meshID; } From a7b9a055a41beded5fca36560529abba1b0a67f2 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 16:44:12 +0800 Subject: [PATCH 04/13] try fix CI --- .github/workflows/manifold.yml | 2 +- CMakeLists.txt | 6 ++++-- src/utilities/CMakeLists.txt | 34 +++++++++++++++++++++++++++++----- src/utilities/include/public.h | 12 +++--------- test/CMakeLists.txt | 12 +++++++++--- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/.github/workflows/manifold.yml b/.github/workflows/manifold.yml index bbc606292..a4d082bb5 100644 --- a/.github/workflows/manifold.yml +++ b/.github/workflows/manifold.yml @@ -144,7 +144,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - parallel_backend: [NONE] + parallel_backend: [NONE, TBB] cuda_support: [OFF] max-parallel: 1 runs-on: windows-2019 diff --git a/CMakeLists.txt b/CMakeLists.txt index f08447ba8..44006954a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,14 +66,16 @@ endif() if(NOT MSVC) set(WARNING_FLAGS -Werror -Wall -Wno-sign-compare -Wno-unused) - add_compile_options( + set(MANIFOLD_FLAGS + "${MANIFOLD_FLAGS}" "$<$:${WARNING_FLAGS}>" "$<$:-Xcompiler=${WARNING_FLAGS}>") endif() if(CODE_COVERAGE AND NOT MSVC) set(COVERAGE_FLAGS -coverage -fno-inline-small-functions -fkeep-inline-functions -fkeep-static-functions) - add_compile_options( + set(MANIFOLD_FLAGS + "${MANIFOLD_FLAGS}" "$<$:${COVERAGE_FLAGS}>" "$<$:-Xcompiler=-coverage>") add_link_options("-coverage") diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index 1e7d45db9..69955f5ad 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -29,11 +29,35 @@ if(MANIFOLD_PAR STREQUAL "OMP") target_compile_options(${PROJECT_NAME} PUBLIC -DMANIFOLD_PAR='O' -fopenmp) target_link_options(${PROJECT_NAME} PUBLIC -fopenmp) elseif(MANIFOLD_PAR STREQUAL "TBB") - find_package(PkgConfig REQUIRED) - pkg_check_modules(TBB REQUIRED tbb) - target_include_directories(${PROJECT_NAME} PUBLIC ${TBB_INCLUDE_DIRS}) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(TBB tbb) + endif() + if(NOT TBB_FOUND) + message(STATUS "tbb not found, downloading from source") + include(FetchContent) + FetchContent_Declare(TBB + GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git + # versions afterward forces -D_FORTIFY_SOURCE=2 + # which conflicts with defaults with nixos... + GIT_TAG v2021.10.0 + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + ) + if (NOT MSVC) + set(TBB_COMMON_COMPILE_FLAGS "-Wno-uninitialized") + set(TBB_TEST_COMPILE_FLAGS "-Wno-address") + endif() + set(TBB_TEST off) + FetchContent_MakeAvailable(TBB) + endif() target_compile_options(${PROJECT_NAME} PUBLIC -DMANIFOLD_PAR='T') - target_link_libraries(${PROJECT_NAME} PUBLIC ${TBB_LINK_LIBRARIES}) + if(TARGET TBB::tbb) + target_link_libraries(${PROJECT_NAME} PUBLIC TBB::tbb) + else() + target_include_directories(${PROJECT_NAME} PUBLIC ${TBB_INCLUDE_DIRS}) + target_link_libraries(${PROJECT_NAME} PUBLIC ${TBB_LINK_LIBRARIES}) + endif() elseif(MANIFOLD_PAR STREQUAL "NONE") set(MANIFOLD_PAR "CPP") else() @@ -63,4 +87,4 @@ if(MANIFOLD_DEBUG) PUBLIC -DMANIFOLD_DEBUG) endif() -target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) \ No newline at end of file +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) diff --git a/src/utilities/include/public.h b/src/utilities/include/public.h index 31a66a985..8f4c6111d 100644 --- a/src/utilities/include/public.h +++ b/src/utilities/include/public.h @@ -19,17 +19,14 @@ #include #include #include +#include +#include #include #include +#include #include #include -#ifdef MANIFOLD_DEBUG -#include -#include -#include -#endif - namespace manifold { constexpr float kTolerance = 1e-5; @@ -454,8 +451,6 @@ struct ExecutionParams { bool suppressErrors = false; }; -#ifdef MANIFOLD_DEBUG - inline std::ostream& operator<<(std::ostream& stream, const Box& box) { return stream << "min: " << box.min.x << ", " << box.min.y << ", " << box.min.z << ", " @@ -514,7 +509,6 @@ void Diff(const std::vector& a, const std::vector& b) { std::cout << std::endl; } /** @} */ -#endif } // namespace manifold #undef HOST_DEVICE diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9e87be7ca..694b1eb9b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -27,8 +27,8 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) set(INSTALL_GMOCK OFF CACHE BOOL "" FORCE) -find_package(GTest) -if(NOT GTest_FOUND) +find_package(GTest 1.12) +if((NOT GTest_FOUND) OR NOT(GTest_VERSION GREATER_EQUAL 1.12)) message(STATUS "GTest not found, downloading from source") include(FetchContent) FetchContent_Declare(googletest @@ -36,12 +36,18 @@ if(NOT GTest_FOUND) GIT_TAG v1.14.0 GIT_SHALLOW TRUE GIT_PROGRESS TRUE + OVERRIDE_FIND_PACKAGE ) FetchContent_MakeAvailable(googletest) endif() +if(NOT TARGET GTest::GTest) + add_library(GTest::GTest ALIAS gtest) + add_library(GTest::Main ALIAS gtest_main) +endif() + add_executable(${PROJECT_NAME} ${SOURCE_FILES}) -target_link_libraries(${PROJECT_NAME} polygon gtest manifold sdf samples samplesGPU cross_section) +target_link_libraries(${PROJECT_NAME} polygon GTest::GTest manifold sdf samples samplesGPU cross_section) if (TRACY_ENABLE) include(FetchContent) From f859d417f764e212f8f9b36f0b384c347cabb272 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 20:12:34 +0800 Subject: [PATCH 05/13] fix ubuntu build --- test/test.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test.h b/test/test.h index 44a53f348..b624a2082 100644 --- a/test/test.h +++ b/test/test.h @@ -13,10 +13,18 @@ // limitations under the License. #pragma once +#include #include "gtest/gtest.h" #include "manifold.h" #include "public.h" +// somehow gcc11 + gtest 1.11.0 is unable to print glm::ivec3 +namespace glm { + inline void PrintTo(const ivec3& point, std::ostream* os) { + *os << "(" << point.x << "," << point.y << "," << point.x << ")"; + } +} + using namespace manifold; struct Options { From 4577775fa1f02e21ff0ce9e8e0ff5f686ebe323e Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 20:13:11 +0800 Subject: [PATCH 06/13] disable windows tbb build first --- .github/workflows/manifold.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/manifold.yml b/.github/workflows/manifold.yml index a4d082bb5..bbc606292 100644 --- a/.github/workflows/manifold.yml +++ b/.github/workflows/manifold.yml @@ -144,7 +144,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - parallel_backend: [NONE, TBB] + parallel_backend: [NONE] cuda_support: [OFF] max-parallel: 1 runs-on: windows-2019 From 51155bca502bb9ae3174607d654f5d199f689be5 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 20:21:16 +0800 Subject: [PATCH 07/13] update tbb config --- .github/workflows/manifold.yml | 2 +- src/utilities/CMakeLists.txt | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/manifold.yml b/.github/workflows/manifold.yml index bbc606292..a4d082bb5 100644 --- a/.github/workflows/manifold.yml +++ b/.github/workflows/manifold.yml @@ -144,7 +144,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - parallel_backend: [NONE] + parallel_backend: [NONE, TBB] cuda_support: [OFF] max-parallel: 1 runs-on: windows-2019 diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index 69955f5ad..e04a55e31 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -36,6 +36,7 @@ elseif(MANIFOLD_PAR STREQUAL "TBB") if(NOT TBB_FOUND) message(STATUS "tbb not found, downloading from source") include(FetchContent) + set(TBB_TEST OFF CACHE INTERNAL "" FORCE) FetchContent_Declare(TBB GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git # versions afterward forces -D_FORTIFY_SOURCE=2 @@ -44,11 +45,6 @@ elseif(MANIFOLD_PAR STREQUAL "TBB") GIT_SHALLOW TRUE GIT_PROGRESS TRUE ) - if (NOT MSVC) - set(TBB_COMMON_COMPILE_FLAGS "-Wno-uninitialized") - set(TBB_TEST_COMPILE_FLAGS "-Wno-address") - endif() - set(TBB_TEST off) FetchContent_MakeAvailable(TBB) endif() target_compile_options(${PROJECT_NAME} PUBLIC -DMANIFOLD_PAR='T') From c9dda155d125b954b75fb501a30b49469c4ca1ed Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 20:21:29 +0800 Subject: [PATCH 08/13] format --- test/test.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test.h b/test/test.h index b624a2082..50312f3b0 100644 --- a/test/test.h +++ b/test/test.h @@ -14,16 +14,17 @@ #pragma once #include + #include "gtest/gtest.h" #include "manifold.h" #include "public.h" // somehow gcc11 + gtest 1.11.0 is unable to print glm::ivec3 namespace glm { - inline void PrintTo(const ivec3& point, std::ostream* os) { - *os << "(" << point.x << "," << point.y << "," << point.x << ")"; - } +inline void PrintTo(const ivec3& point, std::ostream* os) { + *os << "(" << point.x << "," << point.y << "," << point.x << ")"; } +} // namespace glm using namespace manifold; From 00e403b89c659b31efb036cc5989799ddaaadf5c Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 5 Aug 2023 20:59:43 +0800 Subject: [PATCH 09/13] fix cmake BUILD_SHARED_LIBS we should make the library type implicit, so users can decide whether or not to build shared libraries. --- CMakeLists.txt | 12 ++++-------- src/collider/CMakeLists.txt | 2 +- src/cross_section/CMakeLists.txt | 2 +- src/polygon/CMakeLists.txt | 2 +- src/third_party/graphlite/CMakeLists.txt | 2 +- src/utilities/CMakeLists.txt | 3 ++- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44006954a..fe6f37a90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,9 +32,12 @@ if(EMSCRIPTEN) message("Building for Emscripten") set(MANIFOLD_FLAGS -fexceptions -D_LIBCUDACXX_HAS_THREAD_API_EXTERNAL -D_LIBCUDACXX_HAS_THREAD_API_CUDA) set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -sALLOW_MEMORY_GROWTH=1) + set(MANIFOLD_PYBIND OFF) endif() -option(PYBIND11_FINDPYTHON "Enable PyBind to perform FindPython for you" ON) +if(MANIFOLD_PYBIND) +find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) +endif() option(BUILD_TEST_CGAL "Build CGAL performance comparisons" OFF) @@ -42,13 +45,6 @@ option(BUILD_SHARED_LIBS "Build dynamic/shared libraries" OFF) set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/bindings/python/third_party/pybind11) set(THRUST_INC_DIR ${PROJECT_SOURCE_DIR}/src/third_party/thrust) -if(BUILD_SHARED_LIBS OR MANIFOLD_CBIND) - # Allow shared libraries to be relocatable (add Place Independent Code flag). - # Also include when statically linking C bindings to avoid issues with bundling - # artefacts in host languages using them for FFI. - add_compile_options(-fPIC) -endif() - if(MANIFOLD_USE_CUDA) enable_language(CUDA) find_package(CUDA REQUIRED) diff --git a/src/collider/CMakeLists.txt b/src/collider/CMakeLists.txt index 8cb298d6e..73682672a 100644 --- a/src/collider/CMakeLists.txt +++ b/src/collider/CMakeLists.txt @@ -15,7 +15,7 @@ project (collider) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +add_library(${PROJECT_NAME} ${SOURCE_FILES}) if(MANIFOLD_USE_CUDA) set_source_files_properties(${SOURCE_FILES} PROPERTIES LANGUAGE CUDA) diff --git a/src/cross_section/CMakeLists.txt b/src/cross_section/CMakeLists.txt index e7eddae5f..4f9c28d00 100644 --- a/src/cross_section/CMakeLists.txt +++ b/src/cross_section/CMakeLists.txt @@ -15,7 +15,7 @@ project (cross_section) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +add_library(${PROJECT_NAME} ${SOURCE_FILES}) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include diff --git a/src/polygon/CMakeLists.txt b/src/polygon/CMakeLists.txt index d24497490..1d2cbe6af 100644 --- a/src/polygon/CMakeLists.txt +++ b/src/polygon/CMakeLists.txt @@ -15,7 +15,7 @@ project (polygon) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +add_library(${PROJECT_NAME} ${SOURCE_FILES}) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include diff --git a/src/third_party/graphlite/CMakeLists.txt b/src/third_party/graphlite/CMakeLists.txt index d7b080db1..30d67b005 100644 --- a/src/third_party/graphlite/CMakeLists.txt +++ b/src/third_party/graphlite/CMakeLists.txt @@ -1,6 +1,6 @@ project (graphlite) -add_library(${PROJECT_NAME} OBJECT src/connected_components.cpp) +add_library(${PROJECT_NAME} src/connected_components.cpp) target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index e04a55e31..1d79a401b 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -15,7 +15,7 @@ project(utilities) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +add_library(${PROJECT_NAME} ${SOURCE_FILES}) message("CUDA Support: ${MANIFOLD_USE_CUDA}") message("Parallel Backend: ${MANIFOLD_PAR}") @@ -37,6 +37,7 @@ elseif(MANIFOLD_PAR STREQUAL "TBB") message(STATUS "tbb not found, downloading from source") include(FetchContent) set(TBB_TEST OFF CACHE INTERNAL "" FORCE) + set(TBB_STRICT OFF CACHE INTERNAL "" FORCE) FetchContent_Declare(TBB GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git # versions afterward forces -D_FORTIFY_SOURCE=2 From 58ec421139c47bdae22a401ba50b029309d7c8f3 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sun, 6 Aug 2023 15:01:17 +0800 Subject: [PATCH 10/13] revert public.h changes --- src/utilities/include/public.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utilities/include/public.h b/src/utilities/include/public.h index 8f4c6111d..31a66a985 100644 --- a/src/utilities/include/public.h +++ b/src/utilities/include/public.h @@ -19,14 +19,17 @@ #include #include #include -#include -#include #include #include -#include #include #include +#ifdef MANIFOLD_DEBUG +#include +#include +#include +#endif + namespace manifold { constexpr float kTolerance = 1e-5; @@ -451,6 +454,8 @@ struct ExecutionParams { bool suppressErrors = false; }; +#ifdef MANIFOLD_DEBUG + inline std::ostream& operator<<(std::ostream& stream, const Box& box) { return stream << "min: " << box.min.x << ", " << box.min.y << ", " << box.min.z << ", " @@ -509,6 +514,7 @@ void Diff(const std::vector& a, const std::vector& b) { std::cout << std::endl; } /** @} */ +#endif } // namespace manifold #undef HOST_DEVICE From cc25dbf06491e5b0ebd70a933c88e84462cc38d1 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sun, 6 Aug 2023 15:01:43 +0800 Subject: [PATCH 11/13] remove version requirement for gtest --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 694b1eb9b..3db2c15c0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -27,8 +27,8 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) set(INSTALL_GMOCK OFF CACHE BOOL "" FORCE) -find_package(GTest 1.12) -if((NOT GTest_FOUND) OR NOT(GTest_VERSION GREATER_EQUAL 1.12)) +find_package(GTest) +if(NOT GTest_FOUND) message(STATUS "GTest not found, downloading from source") include(FetchContent) FetchContent_Declare(googletest From 95374d992018154f9b246d08c3cf3acdf16dada8 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sun, 6 Aug 2023 15:31:27 +0800 Subject: [PATCH 12/13] update tracy instructions no need to use sudo, and we need some debug flags for good stack capture --- CMakeLists.txt | 10 ++++++++++ README.md | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe6f37a90..3c41db8b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,16 @@ option(MANIFOLD_USE_CUDA "Enable GPU support via CUDA" OFF) option(MANIFOLD_PYBIND "Build python bindings" ON) option(MANIFOLD_CBIND "Build C (FFI) bindings" OFF) option(TRACY_ENABLE "Use tracy profiling" OFF) + +if(TRACY_ENABLE) + option(CMAKE_BUILD_TYPE "Build type" RelWithDebInfo) + if(NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") + endif() +else() + option(CMAKE_BUILD_TYPE "Build type" Release) +endif() + set(MANIFOLD_PAR "NONE" CACHE STRING "Parallel backend, either \"TBB\" or \"OpenMP\" or \"NONE\"") set(MANIFOLD_FLAGS -O3) diff --git a/README.md b/README.md index a41d7648e..ae99c1245 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Contributions are welcome! A lower barrier contribution is to simply make a PR t ## Profiling There is now basic support for the [Tracy profiler](https://github.com/wolfpld/tracy) for our tests. -To enable tracing, compile with `-DTRACY_ENABLE=on` cmake option, and run the test with administrator privileges. +To enable tracing, compile with `-DTRACY_ENABLE=on` cmake option, and run the test with Tracy server running. ## About the author From c749750f231e9b779c671f1c8ce992e80fd193f9 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sun, 6 Aug 2023 16:04:27 +0800 Subject: [PATCH 13/13] fix js build --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 870e6a2a7..578446f90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,8 @@ set(MANIFOLD_FLAGS -O3) if(EMSCRIPTEN) message("Building for Emscripten") - set(MANIFOLD_FLAGS -fwasm-exceptions -D_LIBCUDACXX_HAS_THREAD_API_EXTERNAL -D_LIBCUDACXX_HAS_THREAD_API_CUDA) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sALLOW_MEMORY_GROWTH=1 -fwasm-exceptions") + set(MANIFOLD_FLAGS -fexceptions -D_LIBCUDACXX_HAS_THREAD_API_EXTERNAL -D_LIBCUDACXX_HAS_THREAD_API_CUDA) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sALLOW_MEMORY_GROWTH=1 -fexceptions -sDISABLE_EXCEPTION_CATCHING=0") set(MANIFOLD_PYBIND OFF) endif()