Skip to content

Commit 8474ec0

Browse files
committed
1 parent 0a7b892 commit 8474ec0

File tree

4 files changed

+35
-46
lines changed

4 files changed

+35
-46
lines changed

CMakeLists.txt

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,15 @@ endif()
158158
# TBB (optional)
159159
# Must come before CGAL so it can use TBB properly
160160
if ( CCCORELIB_USE_TBB )
161-
find_package( TBB COMPONENTS tbb CONFIG )
161+
find_package( TBB COMPONENTS tbb 2022.0.0 CONFIG )
162162

163+
set( CCCORELIB_USE_QT_CONCURRENT OFF )
163164
if ( TBB_FOUND )
164-
if ( ${TBB_VERSION} VERSION_GREATER 2021.0.0 )
165-
target_link_libraries( CCCoreLib
166-
PUBLIC
167-
TBB::tbb
168-
)
169-
else()
170-
target_link_libraries( CCCoreLib
171-
PUBLIC
172-
${TBB_IMPORTED_TARGETS}
173-
)
174-
endif()
165+
target_link_libraries( CCCoreLib
166+
PUBLIC
167+
TBB::tbb
168+
)
169+
175170
target_compile_definitions( CCCoreLib
176171
PUBLIC
177172
CC_CORE_LIB_USES_TBB
@@ -192,14 +187,7 @@ if ( CCCORELIB_USE_CGAL )
192187

193188
if ( CCCORELIB_USE_TBB )
194189
if ( TBB_FOUND )
195-
# Once Linux libcgal-dev >= 5.0, target_compile_definitions replaced by:
196-
# CGAL_target_use_TBB( CCCoreLib )
197-
198-
target_compile_definitions( CCCoreLib
199-
PRIVATE
200-
CGAL_LINKED_WITH_TBB
201-
NOMINMAX
202-
)
190+
CGAL_target_use_TBB( CCCoreLib )
203191
else()
204192
message( WARNING "CGAL cannot compile with TBB (TBB not found)" )
205193
endif()
@@ -232,7 +220,7 @@ if ( CCCORELIB_USE_QT_CONCURRENT )
232220

233221
target_link_libraries( CCCoreLib
234222
PUBLIC
235-
Qt6::Concurrent
223+
Qt6::Concurrent
236224
)
237225

238226
target_compile_definitions( CCCoreLib
@@ -268,9 +256,9 @@ install(
268256
include( CMakePackageConfigHelpers )
269257

270258
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake.in
271-
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
272-
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}
273-
NO_CHECK_REQUIRED_COMPONENTS_MACRO
259+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
260+
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}
261+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
274262
)
275263

276264
write_basic_package_version_file( CCCoreLibConfigVersion.cmake

include/ParallelSort.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
#ifndef Q_MOC_RUN
2121
#if defined(emit)
2222
#undef emit
23-
#include <tbb/parallel_sort.h>
23+
#include <oneapi/tbb/parallel_sort.h>
2424
#define emit // restore the macro definition of "emit", as it was defined in gtmetamacros.h
2525
#else
26-
#include <tbb/parallel_sort.h>
26+
#include <oneapi/tbb/parallel_sort.h>
2727
#endif // defined(emit)
2828
#endif // Q_MOC_RUN
2929

30-
#define ParallelSort tbb::parallel_sort
30+
#define ParallelSort oneapi::tbb::parallel_sort
3131

3232
#else
3333

src/DgmOctree.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
#ifndef Q_MOC_RUN
3636
#if defined(emit)
3737
#undef emit
38-
#include <tbb/parallel_for.h>
38+
#include <oneapi/tbb/parallel_for.h>
3939
#define emit // restore the macro definition of "emit", as it was defined in gtmetamacros.h
4040
#else
41-
#include <tbb/parallel_for.h>
41+
#include <oneapi/tbb/parallel_for.h>
4242
#endif // defined(emit)
4343
#endif // Q_MOC_RUN
4444
#endif
@@ -3266,9 +3266,9 @@ unsigned DgmOctree::executeFunctionForAllCellsAtLevel( unsigned char level,
32663266
QThreadPool::globalInstance()->setMaxThreadCount(maxThreadCount);
32673267
QtConcurrent::blockingMap(cells, [this](const octreeCellDesc& desc) { m_MT_wrapper.launchOctreeCellFunc(desc); });
32683268
#elif defined(CC_CORE_LIB_USES_TBB)
3269-
tbb::task_scheduler_init init(maxThreadCount != 0 ? maxThreadCount : tbb::task_scheduler_init::automatic);
3270-
tbb::parallel_for(tbb::blocked_range<int>(0, cells.size()),
3271-
[&](tbb::blocked_range<int> r)
3269+
//tbb::task_scheduler_init init(maxThreadCount != 0 ? maxThreadCount : tbb::task_scheduler_init::automatic);
3270+
oneapi::tbb::parallel_for(oneapi::tbb::blocked_range<std::size_t>(0, cells.size()),
3271+
[&](oneapi::tbb::blocked_range<std::size_t> r)
32723272
{
32733273
for (auto i = r.begin(); i < r.end(); ++i)
32743274
{
@@ -3873,9 +3873,9 @@ unsigned DgmOctree::executeFunctionForAllCellsStartingAtLevel(unsigned char star
38733873
QtConcurrent::blockingMap(cells, [this](const octreeCellDesc& desc) { m_MT_wrapper.launchOctreeCellFunc(desc); } );
38743874
#elif defined(CC_CORE_LIB_USES_TBB)
38753875
// Otherwise we use TBB if we can
3876-
tbb::task_scheduler_init init(maxThreadCount != 0 ? maxThreadCount : tbb::task_scheduler_init::automatic);
3877-
tbb::parallel_for(tbb::blocked_range<int>(0, cells.size()),
3878-
[&](tbb::blocked_range<int> r)
3876+
//tbb::task_scheduler_init init(maxThreadCount != 0 ? maxThreadCount : tbb::task_scheduler_init::automatic);
3877+
oneapi::tbb::parallel_for(oneapi::tbb::blocked_range<std::size_t>(0, cells.size()),
3878+
[&](tbb::blocked_range<std::size_t> r)
38793879
{
38803880
for (auto i = r.begin(); i < r.end(); ++i)
38813881
{

src/DistanceComputationTools.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
#elif defined(CC_CORE_LIB_USES_TBB)
3131
//enables multi-threading handling with TBB
3232
#define ENABLE_CLOUD2MESH_DIST_MT
33-
#include <mutex>
33+
#include <oneapi/tbb/mutex.h>
3434
#ifndef Q_MOC_RUN
3535
#if defined(emit)
3636
#undef emit
37-
#include <tbb/parallel_for.h>
37+
#include <oneapi/tbb/parallel_for.h>
3838
#define emit // restore the macro definition of "emit", as it was defined in gtmetamacros.h
3939
#else
40-
#include <tbb/parallel_for.h>
40+
#include <oneapi/tbb/parallel_for.h>
4141
#endif // defined(emit)
4242
#endif // Q_MOC_RUN
4343
#else
@@ -934,7 +934,7 @@ namespace CCCoreLib
934934
#if defined(CC_CORE_LIB_USES_QT_CONCURRENT)
935935
QMutex currentBitMaskMutex;
936936
#elif defined(CC_CORE_LIB_USES_TBB)
937-
std::mutex currentBitMaskMutex;
937+
oneapi::tbb::mutex currentBitMaskMutex;
938938
#endif
939939
};
940940
}
@@ -956,8 +956,9 @@ static void CloudMeshDistCellFunc_MT(const DgmOctree::IndexAndCode& desc)
956956

957957
if (s_multiThreadingWrapper.normProgressCb)
958958
{
959+
#if defined(CC_CORE_LIB_USES_QT_CONCURRENT)
959960
QCoreApplication::processEvents(QEventLoop::EventLoopExec); // to allow the GUI to refresh itself
960-
961+
#endif
961962
if (!s_multiThreadingWrapper.normProgressCb->oneStep())
962963
{
963964
s_multiThreadingWrapper.cellFunc_success = false;
@@ -1565,7 +1566,7 @@ int DistanceComputationTools::computePoint2MeshDistancesWithOctree( const CCVect
15651566
return DISTANCE_COMPUTATION_RESULTS::SUCCESS;
15661567
}
15671568

1568-
int DistanceComputationTools::computeCloud2MeshDistancesWithOctree( const DgmOctree* octree,
1569+
int DistanceComputationTools::computeCloud2MeshDistancesWithOctree( const DgmOctree* octree,
15691570
const GridAndMeshIntersection& intersection,
15701571
Cloud2MeshDistancesComputationParams& params,
15711572
GenericProgressCallback* progressCb/*=nullptr*/)
@@ -1819,10 +1820,10 @@ int DistanceComputationTools::computeCloud2MeshDistancesWithOctree( const DgmOct
18191820
QThreadPool::globalInstance()->setMaxThreadCount(params.maxThreadCount);
18201821
QtConcurrent::blockingMap(cellsDescs, CloudMeshDistCellFunc_MT);
18211822
#elif defined(CC_CORE_LIB_USES_TBB)
1822-
tbb::parallel_for(tbb::blocked_range<int>(0, cellsDescs.size()),
1823-
[&](tbb::blocked_range<int> r)
1823+
oneapi::tbb::parallel_for(oneapi::tbb::blocked_range<std::size_t>(0, cellsDescs.size()),
1824+
[&](oneapi::tbb::blocked_range<std::size_t> r)
18241825
{
1825-
for (auto i = r.begin(); r.end(); ++i)
1826+
for (auto i = r.begin(); i < r.end(); ++i)
18261827
{
18271828
CloudMeshDistCellFunc_MT(cellsDescs[i]);
18281829
}
@@ -1859,7 +1860,7 @@ int DistanceComputationTools::computeCloud2MeshDistances( GenericIndexedCloudPer
18591860
DgmOctree* cloudOctree/*=nullptr*/)
18601861
{
18611862
//check the input
1862-
if (!pointCloud)
1863+
if (!pointCloud)
18631864
{
18641865
assert(false);
18651866
return DISTANCE_COMPUTATION_RESULTS::ERROR_NULL_COMPAREDCLOUD;
@@ -1921,7 +1922,7 @@ int DistanceComputationTools::computeCloud2MeshDistances( GenericIndexedCloudPer
19211922
maxBB.u[k] = std::max(meshMaxBB.u[k], cloudMaxBB.u[k]);
19221923
}
19231924

1924-
//max cubical bounding-box
1925+
//max cubical bounding-box
19251926
cubicalMinBB = minBB;
19261927
cubicalMaxBB = maxBB;
19271928

0 commit comments

Comments
 (0)