From 50e31f11666de790b3dc717dc720f33c2f7301f9 Mon Sep 17 00:00:00 2001 From: attcs Date: Sun, 22 Dec 2024 22:20:08 +0100 Subject: [PATCH] Apple Clang compiler support (and all other non exec-pol compiler) --- gcc/CMakeLists.txt | 10 ++++- octree.h | 91 ++++++++++++++++++++++++---------------- octree_container.h | 80 +++++++++++++++++++++-------------- unittests/compile_test.h | 91 +++++++++++++++++++++++----------------- 4 files changed, 164 insertions(+), 108 deletions(-) diff --git a/gcc/CMakeLists.txt b/gcc/CMakeLists.txt index 9b10168..5f23264 100644 --- a/gcc/CMakeLists.txt +++ b/gcc/CMakeLists.txt @@ -1,8 +1,14 @@ cmake_minimum_required(VERSION 3.10) project(octree) -find_package(TBB REQUIRED COMPONENTS tbb) +find_package(TBB QUIET) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTBB_ENABLE_IPO=off -std=c++20") include_directories(../) add_executable(octree main.cpp) -target_link_libraries(octree tbb) \ No newline at end of file + +if (TBB_FOUND) + target_link_libraries(octree TBB::tbb) + message(STATUS "TBB library is linked.") +else() + message(STATUS "TBB library is not linked.") +endif() \ No newline at end of file diff --git a/octree.h b/octree.h index f9c3303..258697c 100644 --- a/octree.h +++ b/octree.h @@ -34,6 +34,7 @@ SOFTWARE. #include #include #include +#include #include #include @@ -71,6 +72,21 @@ SOFTWARE. #define LOOPIVDEP #endif +#ifdef __cpp_lib_execution +#define EXEC_POL_TEMPLATE_DECL template +#define EXEC_POL_TEMPLATE_PARAM typename TExecutionPolicy = std::execution::unsequenced_policy, +#define EXEC_POL_TEMPLATE_ADD(func) template func +#define EXEC_POL_TEMPLATE_ADDF(func) func +#define EXEC_POL_DEF(e) auto constexpr e = TExecutionPolicy{} +#define EXEC_POL_ADD(e) e, +#else +#define EXEC_POL_TEMPLATE_DECL +#define EXEC_POL_TEMPLATE_PARAM +#define EXEC_POL_TEMPLATE_ADD(func) func +#define EXEC_POL_TEMPLATE_ADDF(func) func +#define EXEC_POL_DEF(e) +#define EXEC_POL_ADD(e) +#endif namespace OrthoTree { @@ -717,8 +733,6 @@ namespace OrthoTree template bitset_arithmetic operator-(bitset_arithmetic const& lhs, bitset_arithmetic const& rhs) noexcept { - assert(lhs >= rhs); - auto ret = lhs; bool borrow = false; for (std::size_t i = 0; i < N; ++i) @@ -1787,13 +1801,13 @@ namespace OrthoTree } // Update all element which are in the given hash-table. - template + template void UpdateIndexes(std::unordered_map> const& updateMap) noexcept { autoc updateMapEndIterator = updateMap.end(); - autoce ep = TExecutionPolicy{}; - std::for_each(ep, m_nodes.begin(), m_nodes.end(), [&](auto& node) { + EXEC_POL_DEF(ep); + std::for_each(EXEC_POL_ADD(ep) m_nodes.begin(), m_nodes.end(), [&](auto& node) { decltype(Node::Entities) entitiesNew; for (autoc& id : node.second.Entities) { @@ -1873,11 +1887,11 @@ namespace OrthoTree // Move the whole tree with a std::vector of the movement - template + EXEC_POL_TEMPLATE_DECL void Move(TVector const& moveVector) noexcept { - auto ep = TExecutionPolicy{}; // GCC 11.3 - std::for_each(ep, m_nodes.begin(), m_nodes.end(), [&moveVector](auto& pairKeyNode) { + EXEC_POL_DEF(ep); // GCC 11.3 + std::for_each(EXEC_POL_ADD(ep) m_nodes.begin(), m_nodes.end(), [&moveVector](auto& pairKeyNode) { auto box = pairKeyNode.second.GetBoxInternal(); AD::MoveBox(box, moveVector); pairKeyNode.second.SetBox(std::move(box)); @@ -2301,7 +2315,7 @@ namespace OrthoTree } // Create - template + EXEC_POL_TEMPLATE_DECL static void Create( OrthoTreePoint& tree, TContainer const& points, @@ -2319,13 +2333,13 @@ namespace OrthoTree return; auto pointLocations = std::vector(pointNo); - auto ept = TExecutionPolicy{}; // GCC 11.3 only accept in this form - std::transform(ept, points.begin(), points.end(), pointLocations.begin(), [&](autoc& point) { + EXEC_POL_DEF(ept); // GCC 11.3 + std::transform(EXEC_POL_ADD(ept) points.begin(), points.end(), pointLocations.begin(), [&](autoc& point) { return Location{ detail::getKeyPart(points, point), tree.getLocationID(detail::getValuePart(point)) }; }); - - auto eps = TExecutionPolicy{}; // GCC 11.3 only accept in this form - std::sort(eps, pointLocations.begin(), pointLocations.end(), [&](autoc& leftLocation, autoc& rightLocation) { + + EXEC_POL_DEF(eps); // GCC 11.3 + std::sort(EXEC_POL_ADD(eps) pointLocations.begin(), pointLocations.end(), [&](autoc& leftLocation, autoc& rightLocation) { return leftLocation.GridID < rightLocation.GridID; }); @@ -2879,7 +2893,7 @@ namespace OrthoTree } // Create - template + EXEC_POL_TEMPLATE_DECL static void Create( OrthoTreeBoundingBox& tree, TContainer const& boxes, @@ -2900,15 +2914,18 @@ namespace OrthoTree auto& nodeRoot = cont_at(tree.m_nodes, rootKey); autoce NON_SPLITTED = SPLIT_DEPTH_INCREASEMENT == 0; + #ifdef __cpp_lib_execution autoce NON_PARALLEL = std::is_same::value || std::is_same::value; + #else + autoce NON_PARALLEL = true; + #endif - auto epf = TExecutionPolicy{}; // GCC 11.3 auto locations = LocationContainer(entityNo); - if constexpr (NON_SPLITTED) { - std::transform(epf, boxes.begin(), boxes.end(), locations.begin(), [&tree, &boxes](autoc& box) { + EXEC_POL_DEF(epf); // GCC 11.3 + std::transform(EXEC_POL_ADD(epf) boxes.begin(), boxes.end(), locations.begin(), [&tree, &boxes](autoc& box) { return tree.getLocation(detail::getKeyPart(boxes, box), detail::getValuePart(box), nullptr); }); } @@ -2917,7 +2934,8 @@ namespace OrthoTree locations.reserve(entityNo * std::min(10, Base::CHILD_NO * SPLIT_DEPTH_INCREASEMENT)); std::size_t locationID = 0; - std::for_each(epf, boxes.begin(), boxes.end(), [&tree, &boxes, &locations, &locationID](autoc& box) { + EXEC_POL_DEF(epf); // GCC 11.3 + std::for_each(EXEC_POL_ADD(epf) boxes.begin(), boxes.end(), [&tree, &boxes, &locations, &locationID](autoc& box) { locations[locationID] = tree.getLocation(detail::getKeyPart(boxes, box), detail::getValuePart(box), &locations); ++locationID; }); @@ -2929,7 +2947,8 @@ namespace OrthoTree additionalLocations[detail::getKeyPart(boxes, entity)]; locations.reserve(entityNo * std::min(10, Base::CHILD_NO * SPLIT_DEPTH_INCREASEMENT)); - std::transform(epf, boxes.begin(), boxes.end(), locations.begin(), [&tree, &boxes, &additionalLocations](autoc& box) { + EXEC_POL_DEF(epf); // GCC 11.3 + std::transform(EXEC_POL_ADD(epf) boxes.begin(), boxes.end(), locations.begin(), [&tree, &boxes, &additionalLocations](autoc& box) { autoc entityID = detail::getKeyPart(boxes, box); return tree.getLocation(entityID, detail::getValuePart(box), &additionalLocations.at(entityID)); }); @@ -2943,9 +2962,9 @@ namespace OrthoTree } locations.resize(position); - auto epf2 = TExecutionPolicy{}; // GCC 11.3 + EXEC_POL_DEF(epf2); // GCC 11.3 std::for_each( - epf2, + EXEC_POL_ADD(epf2) additionalLocations.begin(), additionalLocations.end(), [&locations, &additionalLocationPositions](auto& additionalLocation) { @@ -2959,16 +2978,16 @@ namespace OrthoTree }); } - auto eps = TExecutionPolicy{}; // GCC 11.3 - std::sort(eps, locations.begin(), locations.end()); + EXEC_POL_DEF(eps); // GCC 11.3 + std::sort(EXEC_POL_ADD(eps) locations.begin(), locations.end()); auto beginLocationIterator = locations.begin(); tree.addNodes(nodeRoot, rootKey, beginLocationIterator, locations.end(), MortonNodeID{ 0 }, maxDepthNo); if constexpr (SPLIT_DEPTH_INCREASEMENT > 0) { // Eliminate duplicates. Not all sub-nodes will be created due to the maxElementNoInNode, which cause duplicates in the parent nodes. - auto epsp = TExecutionPolicy{}; // GCC 11.3 - std::for_each(epsp, tree.m_nodes.begin(), tree.m_nodes.end(), [](auto& pairOfKeyAndNode) { + EXEC_POL_DEF(epsp); // GCC 11.3 + std::for_each(EXEC_POL_ADD(epsp) tree.m_nodes.begin(), tree.m_nodes.end(), [](auto& pairOfKeyAndNode) { auto& node = pairOfKeyAndNode.second; std::ranges::sort(node.Entities); node.Entities.erase(std::unique(node.Entities.begin(), node.Entities.end()), node.Entities.end()); @@ -3409,7 +3428,7 @@ namespace OrthoTree private: // Collision detection between the stored elements from bottom to top logic - template + EXEC_POL_TEMPLATE_DECL std::vector> collisionDetection(TContainer const& boxes, FCollisionDetector&& collisionDetector) const noexcept { using CollisionDetectionContainer = std::vector>; @@ -3428,9 +3447,9 @@ namespace OrthoTree for (autoc entityID : node.Entities) entityIDNodeMap[entityID].emplace_back(nodeKey); }); - - auto ep = TExecutionPolicy{}; // GCC 11.3 - std::for_each(ep, entityIDNodeMap.begin(), entityIDNodeMap.end(), [](auto& keys) { + + EXEC_POL_DEF(ep); // GCC 11.3 + std::for_each(EXEC_POL_ADD(ep) entityIDNodeMap.begin(), entityIDNodeMap.end(), [](auto& keys) { if constexpr (Base::IS_LINEAR_TREE) std::ranges::sort(keys.second); else @@ -3462,11 +3481,11 @@ namespace OrthoTree } } - auto ep = TExecutionPolicy{}; // GCC 11.3 + EXEC_POL_DEF(ep); // GCC 11.3 // Collision detection node-by-node without duplication auto collidedEntityPairsInsideNodes = std::vector(this->m_nodes.size()); - std::transform(ep, this->m_nodes.begin(), this->m_nodes.end(), collidedEntityPairsInsideNodes.begin(), [&](autoc& pairKeyNode) -> CollisionDetectionContainer { + std::transform(EXEC_POL_ADD(ep) this->m_nodes.begin(), this->m_nodes.end(), collidedEntityPairsInsideNodes.begin(), [&](autoc& pairKeyNode) -> CollisionDetectionContainer { auto collidedEntityPairsInsideNode = CollisionDetectionContainer{}; autoc & [nodeKey, node] = pairKeyNode; @@ -3641,20 +3660,20 @@ namespace OrthoTree public: // Collision detection between the stored elements from bottom to top logic - template + EXEC_POL_TEMPLATE_DECL inline std::vector> CollisionDetection(TContainer const& boxes) const noexcept { - return collisionDetection(boxes, [](TEntityID id1, TBox const& e1, TEntityID id2, TBox const& e2) { + return EXEC_POL_TEMPLATE_ADDF(collisionDetection)(boxes, [](TEntityID id1, TBox const& e1, TEntityID id2, TBox const& e2) { return AD::AreBoxesOverlappedStrict(e1, e2); }); } // Collision detection between the stored elements from bottom to top logic - template + EXEC_POL_TEMPLATE_DECL inline std::vector> CollisionDetection(TContainer const& boxes, FCollisionDetector&& collisionDetector) const noexcept { - return collisionDetection(boxes, [collisionDetector](TEntityID id1, TBox const& e1, TEntityID id2, TBox const& e2) { + return EXEC_POL_TEMPLATE_ADDF(collisionDetection)(boxes, [collisionDetector](TEntityID id1, TBox const& e1, TEntityID id2, TBox const& e2) { return AD::AreBoxesOverlappedStrict(e1, e2) && collisionDetector(id1, e1, id2, e2); }); } diff --git a/octree_container.h b/octree_container.h index 55a1758..85c4410 100644 --- a/octree_container.h +++ b/octree_container.h @@ -63,10 +63,16 @@ namespace OrthoTree requires(OrthoTreeCore::IS_CONTIGOUS_CONTAINER) : m_geometryCollection(geometryCollection.begin(), geometryCollection.end()) { - if (isParallelCreation) +#ifdef __cpp_lib_execution + if (isParallelCreation){ OrthoTreeCore::template Create(m_tree, m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); - else - OrthoTreeCore::Create(m_tree, m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + return; + } +#else + assert(!isParallelCreation); // Parallel creation is based on execution policies. __cpp_lib_execution is required. +#endif + + OrthoTreeCore::Create(m_tree, m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); } OrthoTreeContainerBase( @@ -77,10 +83,16 @@ namespace OrthoTree bool isParallelCreation = false) noexcept : m_geometryCollection(geometryCollection) { - if (isParallelCreation) +#ifdef __cpp_lib_execution + if (isParallelCreation) { OrthoTreeCore::template Create(m_tree, m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); - else - OrthoTreeCore::Create(m_tree, m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + return; + } +#else + assert(!isParallelCreation); // Parallel creation is based on execution policies. __cpp_lib_execution is required. +#endif + + OrthoTreeCore::Create(m_tree, m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); } OrthoTreeContainerBase( @@ -91,10 +103,16 @@ namespace OrthoTree bool isParallelCreation = false) noexcept : m_geometryCollection(std::move(geometryCollection)) { - if (isParallelCreation) +#ifdef __cpp_lib_execution + if (isParallelCreation) { OrthoTreeCore::template Create(m_tree, geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); - else - OrthoTreeCore::Create(m_tree, geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + return; + } +#else + assert(!isParallelCreation); // Parallel creation is based on execution policies. __cpp_lib_execution is required. +#endif + + OrthoTreeCore::Create(m_tree, geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); } @@ -230,7 +248,7 @@ namespace OrthoTree using base::base; // inherits all constructors public: // Edit functions - template + EXEC_POL_TEMPLATE_DECL static OrthoTreeContainerPoint Create( std::span const& geometryCollectionSpan, depth_t maxDepthNo = 0, @@ -240,11 +258,11 @@ namespace OrthoTree { auto otc = OrthoTreeContainerPoint(); otc.m_geometryCollection = std::vector(geometryCollectionSpan.begin(), geometryCollectionSpan.end()); - OrthoTreeCore::template Create(otc.m_tree, otc.m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + OrthoTreeCore:: EXEC_POL_TEMPLATE_ADD(Create)(otc.m_tree, otc.m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); return otc; } - template + EXEC_POL_TEMPLATE_DECL static OrthoTreeContainerPoint Create( TContainer const& geometryCollection, depth_t maxDepthNo = 0, @@ -253,11 +271,11 @@ namespace OrthoTree { auto otc = OrthoTreeContainerPoint(); otc.m_geometryCollection = geometryCollection; - OrthoTreeCore::template Create(otc.m_tree, geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + OrthoTreeCore:: EXEC_POL_TEMPLATE_ADD(Create)(otc.m_tree, geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); return otc; } - template + EXEC_POL_TEMPLATE_DECL static OrthoTreeContainerPoint Create( TContainer&& geometryCollection, depth_t maxDepthNo = 0, @@ -266,16 +284,16 @@ namespace OrthoTree { auto otc = OrthoTreeContainerPoint(); otc.m_geometryCollection = std::move(geometryCollection); - OrthoTreeCore::template Create(otc.m_tree, geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + OrthoTreeCore:: EXEC_POL_TEMPLATE_ADD(Create)(otc.m_tree, geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); return otc; } - template + EXEC_POL_TEMPLATE_DECL void Move(TVector const& vMove) noexcept { - this->m_tree.template Move(vMove); - auto ep = TExecutionPolicy{}; // GCC 11.3 - std::for_each(ep, this->m_geometryCollection.begin(), this->m_geometryCollection.end(), [&vMove](auto& data) { + this->m_tree. EXEC_POL_TEMPLATE_ADD(Move)(vMove); + EXEC_POL_DEF(ep); // GCC 11.3 + std::for_each(EXEC_POL_ADD(ep) this->m_geometryCollection.begin(), this->m_geometryCollection.end(), [&vMove](auto& data) { detail::setValuePart(data, AD::Add(detail::getValuePart(data), vMove)); }); } @@ -330,7 +348,7 @@ namespace OrthoTree using base::base; // inherits all constructors public: // Edit functions - template + EXEC_POL_TEMPLATE_DECL static OrthoTreeContainerBox Create( std::span const& geometryCollection, std::optional maxDepthNo = std::nullopt, @@ -340,11 +358,11 @@ namespace OrthoTree { auto otc = OrthoTreeContainerBox(); otc.m_geometryCollection = std::vector(geometryCollection.begin(), geometryCollection.end()); - OrthoTreeCore::template Create(otc.m_tree, otc.m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + OrthoTreeCore:: EXEC_POL_TEMPLATE_ADD(Create)(otc.m_tree, otc.m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); return otc; } - template + EXEC_POL_TEMPLATE_DECL static OrthoTreeContainerBox Create( TContainer const& geometryCollection, std::optional maxDepthNo = std::nullopt, @@ -353,11 +371,11 @@ namespace OrthoTree { auto otc = OrthoTreeContainerBox(); otc.m_geometryCollection = geometryCollection; - OrthoTreeCore::template Create(otc.m_tree, otc.m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + OrthoTreeCore:: EXEC_POL_TEMPLATE_ADD(Create)(otc.m_tree, otc.m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); return otc; } - template + EXEC_POL_TEMPLATE_DECL static OrthoTreeContainerBox Create( TContainer&& geometryCollection, std::optional maxDepthNo = std::nullopt, @@ -366,16 +384,16 @@ namespace OrthoTree { auto otc = OrthoTreeContainerBox(); otc.m_geometryCollection = std::move(geometryCollection); - OrthoTreeCore::template Create(otc.m_tree, otc.m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); + OrthoTreeCore:: EXEC_POL_TEMPLATE_ADD(Create)(otc.m_tree, otc.m_geometryCollection, maxDepthNo, boxSpace, maxElementNoInNode); return otc; } - template + EXEC_POL_TEMPLATE_DECL void Move(TVector const& moveVector) noexcept { - this->m_tree.template Move(moveVector); - auto ep = TExecutionPolicy{}; // GCC 11.3 - std::for_each(ep, this->m_geometryCollection.begin(), this->m_geometryCollection.end(), [&moveVector](auto& data) { + this->m_tree. EXEC_POL_TEMPLATE_ADD(Move)(moveVector); + EXEC_POL_DEF(ep); // GCC 11.3 + std::for_each(EXEC_POL_ADD(ep) this->m_geometryCollection.begin(), this->m_geometryCollection.end(), [&moveVector](auto& data) { auto box = detail::getValuePart(data); AD::MoveBox(box, moveVector); detail::setValuePart(data, box); @@ -399,10 +417,10 @@ namespace OrthoTree public: // Collision detection // Collision detection between the contained elements - template + EXEC_POL_TEMPLATE_DECL inline std::vector> CollisionDetection() const noexcept { - return this->m_tree.template CollisionDetection(this->m_geometryCollection); + return this->m_tree. EXEC_POL_TEMPLATE_ADD(CollisionDetection)(this->m_geometryCollection); } // Collision detection with another tree diff --git a/unittests/compile_test.h b/unittests/compile_test.h index 9f191d2..3792568 100644 --- a/unittests/compile_test.h +++ b/unittests/compile_test.h @@ -24,7 +24,7 @@ // Enforce the compilation of all template function -template +template void testCompilePoint() { using Point = OrthoTree::PointND; @@ -102,19 +102,19 @@ void testCompilePoint() tree.Update(2, vpt[2], vpt[3]); tree.Update(3, vpt[4]); tree.UpdateIndexes({ {1, std::nullopt }, {3, 4} }); - tree.template Move({ 1.0, 1.0 }); + tree.EXEC_POL_TEMPLATE_ADD(Move)({ 1.0, 1.0 }); tree.Clear(); tree.Reset(); tree.Init(boxes[0], 3, 12); tree.Reset(); - OT::template Create(tree, vpt, 4); + OT:: EXEC_POL_TEMPLATE_ADD(Create)(tree, vpt, 4); } } -template +template void testCompilePointMap() { using Point = OrthoTree::PointND; @@ -211,18 +211,18 @@ void testCompilePointMap() {11, std::nullopt}, {3, 4} }); - tree.template Move({ 1.0, 1.0 }); + tree. EXEC_POL_TEMPLATE_ADD(Move)({ 1.0, 1.0 }); tree.Clear(); tree.Reset(); tree.Init(boxes[0], 3, 12); tree.Reset(); - OT::template Create(tree, vpt, 4); + OT:: EXEC_POL_TEMPLATE_ADD(Create)(tree, vpt, 4); } } -template +template void testCompileBox() { using Vector = OrthoTree::VectorND; @@ -267,7 +267,7 @@ void testCompileBox() autoc nodes = tree.GetNodes(); autoc grid = tree.GetResolutionMax(); - autoc vidCollision = tree.template CollisionDetection(boxes); + autoc vidCollision = tree. EXEC_POL_TEMPLATE_ADD(CollisionDetection)(boxes); autoc vidCollisionTree = tree.CollisionDetection(boxes, tree, boxes); autoc aidPick = tree.PickSearch({}, boxes); @@ -304,18 +304,18 @@ void testCompileBox() tree.Update(2, boxes[2], boxes[3]); tree.Update(3, boxes[4]); tree.UpdateIndexes({ {1, std::nullopt }, {3, 4} }); - tree.template Move({ 1.0, 1.0 }); + tree. EXEC_POL_TEMPLATE_ADD(Move)({ 1.0, 1.0 }); tree.Clear(); tree.Reset(); tree.Init(boxes[0], 3, 12); tree.Reset(); - OT::template Create(tree, boxes, 4); + OT:: EXEC_POL_TEMPLATE_ADD(Create)(tree, boxes, 4); } } -template +template void testCompileBoxMap() { using Vector = OrthoTree::VectorND; @@ -360,7 +360,7 @@ void testCompileBoxMap() autoc nodes = tree.GetNodes(); autoc grid = tree.GetResolutionMax(); - autoc vidCollision = tree.template CollisionDetection(boxes); + autoc vidCollision = tree. EXEC_POL_TEMPLATE_ADD(CollisionDetection)(boxes); autoc vidCollisionTree = tree.CollisionDetection(boxes, tree, boxes); autoc aidPick = tree.PickSearch({}, boxes); @@ -410,19 +410,19 @@ void testCompileBoxMap() {17, std::nullopt}, {23, 22} }); - tree.template Move({ 1.0, 1.0 }); + tree. EXEC_POL_TEMPLATE_ADD(Move)({ 1.0, 1.0 }); tree.Clear(); tree.Reset(); tree.Init(boxes.at(13), 3, 12); tree.Reset(); - OT::template Create(tree, boxes, 4); + OT:: EXEC_POL_TEMPLATE_ADD(Create)(tree, boxes, 4); } } -template +template void testCompilePointC() { using Point = OrthoTree::PointND; @@ -442,8 +442,10 @@ void testCompilePointC() }; auto tree = OT(vpt, 3, std::nullopt, 2, false); - auto treePar = OT(vpt, 3, std::nullopt, 2, true); - +#ifdef __cpp_lib_execution + [[maybe_unused]] auto treePar = OT(vpt, 3, std::nullopt, 2, true); +#endif + // const member functions { autoc& treeCore = tree.GetCore(); @@ -472,19 +474,19 @@ void testCompilePointC() tree.Add(vpt[2]); tree.Erase(2); tree.Update(3, vpt[4]); - tree.template Move({ 1.0, 1.0 }); + tree. EXEC_POL_TEMPLATE_ADD(Move)({ 1.0, 1.0 }); tree.Clear(); tree.Reset(); tree.Init(boxes[0], 3, 12); tree.Reset(); - tree = OT::template Create(vpt, 4); - tree = OT::template Create(std::vector{ Point{ 0.0 }, Point{ 1.0 }, Point{ 2.0 }, Point{ 3.0 }, Point{ 4.0 } }, 4); + tree = OT:: EXEC_POL_TEMPLATE_ADD(Create)(vpt, 4); + tree = OT:: EXEC_POL_TEMPLATE_ADD(Create)(std::vector{ Point{ 0.0 }, Point{ 1.0 }, Point{ 2.0 }, Point{ 3.0 }, Point{ 4.0 } }, 4); } } -template +template void testCompilePointMapC() { using Point = OrthoTree::PointND; @@ -510,8 +512,9 @@ void testCompilePointMapC() }; auto tree = OT(vpt, 3, std::nullopt, 2, false); - auto treePar = OT(vpt, 3, std::nullopt, 2, true); - +#ifdef __cpp_lib_execution + [[maybe_unused]] auto treePar = OT(vpt, 3, std::nullopt, 2, true); +#endif // const member functions { autoc& treeCore = tree.GetCore(); @@ -548,15 +551,15 @@ void testCompilePointMapC() tree.Add(60, vpt.at(20)); tree.Erase(20); tree.Update(30, vpt.at(40)); - tree.template Move({ 1.0, 1.0 }); + tree. EXEC_POL_TEMPLATE_ADD(Move)({ 1.0, 1.0 }); tree.Clear(); tree.Reset(); tree.Init(boxes[0], 3, 12); tree.Reset(); - tree = OT::template Create(vpt, 4); - tree = OT::template Create( + tree = OT:: EXEC_POL_TEMPLATE_ADD(Create)(vpt, 4); + tree = OT:: EXEC_POL_TEMPLATE_ADD(Create)( Map{ { 11, Point{ 0.0 } }, { 21, Point{ 1.0 } }, @@ -569,7 +572,7 @@ void testCompilePointMapC() } -template +template void testCompileBoxC() { using BoundingBox = OrthoTree::BoundingBoxND; @@ -586,8 +589,10 @@ void testCompileBoxC() }; auto tree = OT(boxes, 3, std::nullopt, 2, false); - auto treePar = OT(boxes, 3, std::nullopt, 2, true); - +#ifdef __cpp_lib_execution + [[maybe_unused]] auto treePar = OT(boxes, 3, std::nullopt, 2, true); +#endif + // const member functions { autoc& treeCore = tree.GetCore(); @@ -598,7 +603,7 @@ void testCompileBoxC() autoc aidBoxesInRangeF = tree.template RangeSearch(boxes[0]); autoc aidBoxesInRangeT = tree.template RangeSearch(boxes[0]); - autoc vidCollision = tree.template CollisionDetection(); + autoc vidCollision = tree. EXEC_POL_TEMPLATE_ADD(CollisionDetection)(); autoc vidCollisionTree = tree.CollisionDetection(tree); autoc idBoxesIntersectedAll = tree.RayIntersectedAll({}, { 1.0, 1.0 }, 0); @@ -622,15 +627,15 @@ void testCompileBoxC() tree.Add(boxes[0]); tree.Erase(2); tree.Update(3, boxes[4]); - tree.template Move({ 1.0, 1.0 }); + tree. EXEC_POL_TEMPLATE_ADD(Move)({ 1.0, 1.0 }); tree.Clear(); tree.Reset(); tree.Init(boxes[0], 3, 12); tree.Reset(); - tree = OT::template Create(boxes, 4); - tree = OT::template Create( + tree = OT:: EXEC_POL_TEMPLATE_ADD(Create)(boxes, 4); + tree = OT:: EXEC_POL_TEMPLATE_ADD(Create)( std::vector { BoundingBox{ { 0.0, 0.0 }, { 1.0, 1.0 } }, @@ -645,7 +650,7 @@ void testCompileBoxC() } -template +template void testCompileBoxMapC() { using BoundingBox = OrthoTree::BoundingBoxND; @@ -662,8 +667,11 @@ void testCompileBoxMapC() }; auto tree = OT(boxes, 3, std::nullopt, 2, false); - auto treePar = OT(boxes, 3, std::nullopt, 2, true); +#ifdef __cpp_lib_execution + [[maybe_unused]] auto treePar = OT(boxes, 3, std::nullopt, 2, true); +#endif + // const member functions { autoc& treeCore = tree.GetCore(); @@ -674,7 +682,7 @@ void testCompileBoxMapC() autoc aidBoxesInRangeF = tree.template RangeSearch(boxes.at(30)); autoc aidBoxesInRangeT = tree.template RangeSearch(boxes.at(30)); - autoc vidCollision = tree.template CollisionDetection(); + autoc vidCollision = tree. EXEC_POL_TEMPLATE_ADD(CollisionDetection)(); autoc vidCollisionTree = tree.CollisionDetection(tree); autoc idBoxesIntersectedAll = tree.RayIntersectedAll({}, { 1.0, 1.0 }, 0); @@ -705,15 +713,15 @@ void testCompileBoxMapC() tree.Add(11, boxes.at(10)); tree.Erase(20); tree.Update(40, boxes.at(30)); - tree.template Move({ 1.0, 1.0 }); + tree. EXEC_POL_TEMPLATE_ADD(Move)({ 1.0, 1.0 }); tree.Clear(); tree.Reset(); tree.Init(boxes.at(5), 3, 12); tree.Reset(); - tree = OT::template Create(boxes, 4); - tree = OT::template Create( + tree = OT:: EXEC_POL_TEMPLATE_ADD(Create)(boxes, 4); + tree = OT:: EXEC_POL_TEMPLATE_ADD(Create)( Map{ { 10, BoundingBox{{ 0.0, 0.0 }, { 1.0, 1.0 }}}, { 15, BoundingBox{{ 1.0, 1.0 }, { 2.0, 2.0 }}}, @@ -817,10 +825,15 @@ void testCompileBoxBatchDimension() template void testCompileBoxBatchExPol() { +#ifdef __cpp_lib_execution testCompileBoxBatchDimension(); testCompileBoxBatchDimension(); testCompileBoxBatchDimension(); testCompileBoxBatchDimension(); +#else + struct ExecPolDummy{}; + testCompileBoxBatchDimension(); +#endif }