Skip to content

Commit

Permalink
w3
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Jun 4, 2024
1 parent 7d60d4c commit 38b0c52
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 174 deletions.
3 changes: 3 additions & 0 deletions cmake/DARTFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ else()
)
endif()

# Taskflow
dart_find_package(Taskflow)

#=======================
# Optional dependencies
#=======================
Expand Down
9 changes: 9 additions & 0 deletions cmake/DARTFindTaskflow.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2011-2024, The DART development contributors
# All rights reserved.
#
# The list of contributors can be found at:
# https://github.com/dartsim/dart/blob/main/LICENSE
#
# This file is provided under the "BSD-style" License

find_package(Taskflow)
3 changes: 2 additions & 1 deletion dart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ target_link_libraries(dart
Eigen3::Eigen
fcl
assimp
Taskflow::Taskflow
)
if(TARGET fmt::fmt-header-only)
target_link_libraries(dart PUBLIC fmt::fmt-header-only)
Expand Down Expand Up @@ -214,7 +215,7 @@ endif()
add_component_targets(${PROJECT_NAME} dart dart)
add_component_dependencies(${PROJECT_NAME} dart external-odelcpsolver)
add_component_dependency_packages(${PROJECT_NAME} dart
assimp Eigen3 fcl fmt
assimp Eigen3 fcl fmt Taskflow
)
if(TARGET octomap)
add_component_dependency_packages(${PROJECT_NAME} dart octomap)
Expand Down
43 changes: 0 additions & 43 deletions dart/common/ThreadPool.cpp

This file was deleted.

113 changes: 0 additions & 113 deletions dart/common/ThreadPool.hpp

This file was deleted.

21 changes: 6 additions & 15 deletions dart/constraint/BoxedLcpConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include "dart/common/Logging.hpp"
#include "dart/common/Profile.hpp"
#include "dart/common/ThreadPool.hpp"
#include "dart/constraint/ConstraintBase.hpp"
#include "dart/constraint/DantzigBoxedLcpSolver.hpp"
#include "dart/constraint/PgsBoxedLcpSolver.hpp"
Expand Down Expand Up @@ -230,7 +229,7 @@ DART_SUPPRESS_DEPRECATED_END

//==============================================================================
BoxedLcpConstraintSolver::BoxedLcpConstraintSolver(const Config& config)
: ConstraintSolver(), mConfig(config), mThreadPool(4)
: ConstraintSolver(), mConfig(config), mExecutor(4)
{
// Empty
}
Expand All @@ -250,7 +249,7 @@ DART_SUPPRESS_DEPRECATED_END
DART_SUPPRESS_DEPRECATED_BEGIN
BoxedLcpConstraintSolver::BoxedLcpConstraintSolver(
BoxedLcpSolverPtr boxedLcpSolver, BoxedLcpSolverPtr secondaryBoxedLcpSolver)
: ConstraintSolver(), mThreadPool(4)
: ConstraintSolver(), mExecutor(4)
{
if (boxedLcpSolver) {
setBoxedLcpSolver(std::move(boxedLcpSolver));
Expand Down Expand Up @@ -620,18 +619,10 @@ void BoxedLcpConstraintSolver::solveConstrainedGroups()

{
DART_PROFILE_SCOPED_N("Solve problems");

std::vector<std::future<void>> results;

for (auto i = 0u; i < numGroups; ++i) {
results.emplace_back(mThreadPool.enqueue(
[this, i]() { solveBoxedLcp(mProblems[i], mConstrainedGroups[i]); }));
}

// Wait for all tasks to complete
for (auto&& result : results) {
result.get();
}
mTaskflow.for_each_index(0, numGroups, 1, [&](int i) {
solveBoxedLcp(mProblems[i], mConstrainedGroups[i]);
});
mExecutor.run(mTaskflow).wait();
}
}

Expand Down
6 changes: 4 additions & 2 deletions dart/constraint/BoxedLcpConstraintSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

#include <dart/constraint/ConstraintSolver.hpp>
#include <dart/constraint/SmartPointer.hpp>
#include <dart/common/ThreadPool.hpp>

#include <taskflow/taskflow.hpp>

namespace dart {
namespace constraint {
Expand Down Expand Up @@ -249,7 +250,8 @@ class BoxedLcpConstraintSolver : public ConstraintSolver

std::vector<BoxedLcp> mProblems;

common::ThreadPool mThreadPool;
tf::Executor mExecutor;
tf::Taskflow mTaskflow;
};

} // namespace constraint
Expand Down

0 comments on commit 38b0c52

Please sign in to comment.