Conversation
Remove the maybe_parallel_for wrapper and associated headers. Use tbb::parallel_for and tbb::enumerable_thread_specific directly, and update CMake and config to stop defining IPC_TOOLKIT_WITH_TBB
There was a problem hiding this comment.
Pull request overview
This PR removes the maybe_parallel_for abstraction and the IPC_TOOLKIT_WITH_TBB macro, switching affected call sites to use OneTBB APIs (tbb::parallel_for, tbb::blocked_range, tbb::enumerable_thread_specific) directly.
Changes:
- Deleted
maybe_parallel_forheaders/implementation and removed them from the utils CMake source list. - Updated smooth contact and potential implementations to use TBB primitives directly for parallel loops and thread-local storage.
- Removed the
IPC_TOOLKIT_WITH_TBBdefine from the generated config header template.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ipc/utils/maybe_parallel_for.tpp | Removes the conditional TBB wrapper implementation. |
| src/ipc/utils/maybe_parallel_for.hpp | Removes the public wrapper API and thread-storage helpers. |
| src/ipc/utils/matrix_cache.cpp | Drops the now-unused maybe_parallel_for include. |
| src/ipc/utils/CMakeLists.txt | Stops compiling/adding deleted maybe_parallel_for sources. |
| src/ipc/smooth_contact/smooth_contact_potential.cpp | Replaces wrapper usage with tbb::parallel_for + enumerable_thread_specific. |
| src/ipc/smooth_contact/smooth_collisions_builder.hpp | Switches merge signatures to take tbb::enumerable_thread_specific directly. |
| src/ipc/smooth_contact/smooth_collisions_builder.cpp | Updates merge definitions to match new TBB-based signatures. |
| src/ipc/smooth_contact/smooth_collisions.cpp | Replaces wrapper parallel loops with direct TBB parallel_for ranges. |
| src/ipc/potentials/potential.cpp | Replaces wrapper usage with direct TBB parallel_for + enumerable_thread_specific. |
| src/ipc/config.hpp.in | Removes the IPC_TOOLKIT_WITH_TBB macro definition. |
Comments suppressed due to low confidence (2)
src/ipc/smooth_contact/smooth_contact_potential.cpp:7
#include <tbb/combinable.h>appears unused in this translation unit (notbb::combinableusage). Consider removing it to avoid unused-include warnings in stricter builds.
#include <tbb/blocked_range.h>
#include <tbb/combinable.h>
#include <tbb/enumerable_thread_specific.h>
src/ipc/smooth_contact/smooth_contact_potential.cpp:187
tbb::parallel_for(size_t(0), storages.size(), ...)uses a lambda parameter of typeint. This can cause signed/unsigned warnings and becomes incorrect if the range ever exceedsINT_MAX. Usesize_t(or the same index type as the range) for the lambda parameter and downstream indexing.
tbb::parallel_for(size_t(0), storages.size(), [&](int i) {
const SparseMatrixCache& cache =
dynamic_cast<const SparseMatrixCache&>(*storages[i]->cache);
int offset = offsets[i];
std::copy(
cache.entries().begin(), cache.entries().end(),
triplets.begin() + offset);
offset += cache.entries().size();
if (cache.mat().nonZeros() > 0) {
int count = 0;
for (int k = 0; k < cache.mat().outerSize(); ++k) {
for (Eigen::SparseMatrix<double>::InnerIterator it(
cache.mat(), k);
it; ++it) {
assert(count < cache.mat().nonZeros());
triplets[offset + count++] = Eigen::Triplet<double>(
it.row(), it.col(), it.value());
}
}
}
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| tbb::parallel_for( | ||
| tbb::blocked_range<int>(0, candidates.ev_candidates.size()), | ||
| [&](const tbb::blocked_range<int>& r) { |
There was a problem hiding this comment.
tbb::blocked_range<int>(0, candidates.ev_candidates.size()) converts a size_t size to int, which can overflow for large candidate sets and may trigger signed/unsigned warnings. Prefer tbb::blocked_range<size_t> (and adjust the lambda/range types accordingly).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #214 +/- ##
==========================================
- Coverage 96.96% 96.95% -0.01%
==========================================
Files 159 158 -1
Lines 24666 24659 -7
Branches 883 882 -1
==========================================
- Hits 23917 23908 -9
- Misses 749 751 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Remove the maybe_parallel_for wrapper and associated headers. Use tbb::parallel_for and tbb::enumerable_thread_specific directly, and update CMake and config to stop defining IPC_TOOLKIT_WITH_TBB