Skip to content

Commit 3f2478e

Browse files
alxbilgerepernod
andauthored
[Simulation] Move all files related to tasks into a dedicated folder (#5777)
* [Simulation] Move all files related to tasks into a dedicated folder * move TaskSchedulerUser into Sofa.Simulation.Core * change namespace * compatibility layer in Simulation.Core * compatibility layer in MultiThreading --------- Co-authored-by: erik pernod <erik.pernod@gmail.com>
1 parent 07cd7a4 commit 3f2478e

File tree

69 files changed

+487
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+487
-130
lines changed

Sofa/Component/AnimationLoop/src/sofa/component/animationloop/FreeMotionAnimationLoop.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
#include <sofa/simulation/UpdateMappingVisitor.h>
4141
#include <sofa/simulation/UpdateMappingEndEvent.h>
4242
#include <sofa/simulation/UpdateBoundingBoxVisitor.h>
43-
#include <sofa/simulation/TaskScheduler.h>
43+
#include <sofa/simulation/task/TaskScheduler.h>
4444
#include <sofa/simulation/CollisionVisitor.h>
4545
#include <sofa/simulation/SolveVisitor.h>
46-
#include <sofa/simulation/MainTaskSchedulerFactory.h>
46+
#include <sofa/simulation/task/MainTaskSchedulerFactory.h>
4747
#include <sofa/component/constraint/lagrangian/solver/ProjectedGaussSeidelConstraintSolver.h>
4848

4949
#include <sofa/simulation/mechanicalvisitor/MechanicalVInitVisitor.h>

Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/BuiltConstraintSolver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include <sofa/component/constraint/lagrangian/solver/BuiltConstraintSolver.h>
2424

2525
#include <sofa/helper/ScopedAdvancedTimer.h>
26-
#include <sofa/simulation/MainTaskSchedulerFactory.h>
27-
#include <sofa/simulation/ParallelForEach.h>
26+
#include <sofa/simulation/task/MainTaskSchedulerFactory.h>
27+
#include <sofa/simulation/task/ParallelForEach.h>
2828
#include <Eigen/Eigenvalues>
2929

3030
namespace sofa::component::constraint::lagrangian::solver
@@ -197,4 +197,4 @@ void BuiltConstraintSolver::ComplianceWrapper::assembleMatrix() const
197197
}
198198
}
199199

200-
}
200+
}

Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/GenericConstraintSolver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
#include <sofa/core/behavior/MultiMatrixAccessor.h>
2929
#include <sofa/component/constraint/lagrangian/solver/visitors/ConstraintStoreLambdaVisitor.h>
3030
#include <sofa/core/behavior/MultiVec.h>
31-
#include <sofa/simulation/DefaultTaskScheduler.h>
31+
#include <sofa/simulation/task/DefaultTaskScheduler.h>
3232
#include <sofa/helper/ScopedAdvancedTimer.h>
33-
#include <sofa/simulation/MainTaskSchedulerFactory.h>
34-
#include <sofa/simulation/ParallelForEach.h>
33+
#include <sofa/simulation/task/MainTaskSchedulerFactory.h>
34+
#include <sofa/simulation/task/ParallelForEach.h>
3535

3636
#include <sofa/simulation/mechanicalvisitor/MechanicalVOpVisitor.h>
3737
using sofa::simulation::mechanicalvisitor::MechanicalVOpVisitor;

Sofa/Component/Constraint/Lagrangian/Solver/src/sofa/component/constraint/lagrangian/solver/GenericConstraintSolver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <sofa/core/behavior/BaseLagrangianConstraint.h>
2929
#include <sofa/helper/map.h>
3030

31-
#include <sofa/simulation/CpuTask.h>
31+
#include <sofa/simulation/task/CpuTask.h>
3232
#include <sofa/helper/OptionsGroup.h>
3333
#include <sofa/component/constraint/lagrangian/solver/visitors/MechanicalGetConstraintResolutionVisitor.h>
3434
#include <sofa/helper/SelectableItem.h>

Sofa/Component/LinearSolver/Direct/src/sofa/component/linearsolver/direct/SparseLDLSolver.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#include <fstream>
3232
#include <iomanip> // std::setprecision
3333
#include <string>
34-
#include <sofa/simulation/MainTaskSchedulerFactory.h>
35-
#include <sofa/simulation/ParallelForEach.h>
34+
#include <sofa/simulation/task/MainTaskSchedulerFactory.h>
35+
#include <sofa/simulation/task/ParallelForEach.h>
3636

3737

3838
namespace sofa::component::linearsolver::direct

Sofa/Component/LinearSystem/src/sofa/component/linearsystem/ConstantSparsityProjectionMethod.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include <Eigen/Sparse>
2626
#include <sofa/helper/ScopedAdvancedTimer.h>
27-
#include <sofa/simulation/MainTaskSchedulerFactory.h>
27+
#include <sofa/simulation/task/MainTaskSchedulerFactory.h>
2828
#include <sofa/simulation/ParallelSparseMatrixProduct.h>
2929

3030
namespace sofa::component::linearsystem

Sofa/Component/LinearSystem/src/sofa/component/linearsystem/MatrixLinearSystem.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#include <sofa/core/behavior/BaseLocalForceFieldMatrix.h>
3737
#include <sofa/core/behavior/BaseLocalMassMatrix.h>
3838
#include <sofa/core/MechanicalParams.h>
39-
#include <sofa/simulation/MainTaskSchedulerFactory.h>
40-
#include <sofa/simulation/ParallelForEach.h>
39+
#include <sofa/simulation/task/MainTaskSchedulerFactory.h>
40+
#include <sofa/simulation/task/ParallelForEach.h>
4141

4242
#include <sofa/simulation/mechanicalvisitor/MechanicalIdentityBlocksInJacobianVisitor.h>
4343
using sofa::simulation::mechanicalvisitor::MechanicalIdentityBlocksInJacobianVisitor;

Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <sofa/helper/OptionsGroup.h>
3333

3434
#include <sofa/helper/ColorMap.h>
35-
#include <sofa/simulation/ParallelForEach.h>
35+
#include <sofa/simulation/task/ParallelForEach.h>
3636

3737
// corotational tetrahedron from
3838
// @InProceedings{NPF05,

Sofa/framework/Simulation/Core/CMakeLists.txt

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ set(HEADER_FILES
1717
${SRC_ROOT}/CollisionEndEvent.h
1818
${SRC_ROOT}/CollisionVisitor.h
1919
${SRC_ROOT}/Colors.h
20-
${SRC_ROOT}/CpuTask.h
21-
${SRC_ROOT}/CpuTaskStatus.h
2220
${SRC_ROOT}/DeactivatedNodeVisitor.h
2321
${SRC_ROOT}/DefaultAnimationLoop.h
2422
${SRC_ROOT}/DefaultVisualManagerLoop.h
@@ -35,7 +33,6 @@ set(HEADER_FILES
3533
${SRC_ROOT}/MutationListener.h
3634
${SRC_ROOT}/Node.h
3735
${SRC_ROOT}/Node.inl
38-
${SRC_ROOT}/ParallelForEach.h
3936
${SRC_ROOT}/ParallelSparseMatrixProduct.h
4037
${SRC_ROOT}/PauseEvent.h
4138
${SRC_ROOT}/PipelineImpl.h
@@ -65,26 +62,19 @@ set(HEADER_FILES
6562
${SRC_ROOT}/XMLPrintVisitor.h
6663
${SRC_ROOT}/init.h
6764
${SRC_ROOT}/BaseSimulationExporter.h
68-
${SRC_ROOT}/TaskScheduler.h
69-
${SRC_ROOT}/TaskSchedulerFactory.h
70-
${SRC_ROOT}/TaskSchedulerRegistry.h
71-
${SRC_ROOT}/DefaultTaskScheduler.h
72-
${SRC_ROOT}/Task.h
73-
${SRC_ROOT}/InitTasks.h
7465
${SRC_ROOT}/Locks.h
75-
${SRC_ROOT}/MainTaskSchedulerFactory.h
76-
${SRC_ROOT}/MainTaskSchedulerRegistry.h
7766
${SRC_ROOT}/SceneCheck.h
7867
${SRC_ROOT}/SceneCheckRegistry.h
7968
${SRC_ROOT}/SceneCheckMainRegistry.h
80-
${SRC_ROOT}/WorkerThread.h
69+
8170
${SRC_ROOT}/events/BuildConstraintSystemEndEvent.h
8271
${SRC_ROOT}/events/SimulationInitDoneEvent.h
8372
${SRC_ROOT}/events/SimulationInitStartEvent.h
8473
${SRC_ROOT}/events/SimulationInitTexturesDoneEvent.h
8574
${SRC_ROOT}/events/SimulationStartEvent.h
8675
${SRC_ROOT}/events/SimulationStopEvent.h
8776
${SRC_ROOT}/events/SolveConstraintSystemEndEvent.h
77+
8878
${SRC_ROOT}/mechanicalvisitor/MechanicalAccFromFVisitor.h
8979
${SRC_ROOT}/mechanicalvisitor/MechanicalAccumulateJacobian.h
9080
${SRC_ROOT}/mechanicalvisitor/MechanicalAccumulateJacobian.h
@@ -139,6 +129,20 @@ set(HEADER_FILES
139129
${SRC_ROOT}/mechanicalvisitor/MechanicalVOpVisitor.h
140130
${SRC_ROOT}/mechanicalvisitor/MechanicalVReallocVisitor.h
141131
${SRC_ROOT}/mechanicalvisitor/MechanicalVSizeVisitor.h
132+
133+
${SRC_ROOT}/task/CpuTask.h
134+
${SRC_ROOT}/task/CpuTaskStatus.h
135+
${SRC_ROOT}/task/DefaultTaskScheduler.h
136+
${SRC_ROOT}/task/InitTasks.h
137+
${SRC_ROOT}/task/MainTaskSchedulerFactory.h
138+
${SRC_ROOT}/task/MainTaskSchedulerRegistry.h
139+
${SRC_ROOT}/task/ParallelForEach.h
140+
${SRC_ROOT}/task/Task.h
141+
${SRC_ROOT}/task/TaskScheduler.h
142+
${SRC_ROOT}/task/TaskSchedulerFactory.h
143+
${SRC_ROOT}/task/TaskSchedulerRegistry.h
144+
${SRC_ROOT}/task/TaskSchedulerUser.h
145+
${SRC_ROOT}/task/WorkerThread.h
142146
)
143147

144148
set(SOURCE_FILES
@@ -153,8 +157,6 @@ set(SOURCE_FILES
153157
${SRC_ROOT}/CollisionEndEvent.cpp
154158
${SRC_ROOT}/CollisionVisitor.cpp
155159
${SRC_ROOT}/Colors.cpp
156-
${SRC_ROOT}/CpuTask.cpp
157-
${SRC_ROOT}/CpuTaskStatus.cpp
158160
${SRC_ROOT}/DeactivatedNodeVisitor.cpp
159161
${SRC_ROOT}/DefaultAnimationLoop.cpp
160162
${SRC_ROOT}/DefaultVisualManagerLoop.cpp
@@ -165,8 +167,6 @@ set(SOURCE_FILES
165167
${SRC_ROOT}/InitVisitor.cpp
166168
${SRC_ROOT}/IntegrateBeginEvent.cpp
167169
${SRC_ROOT}/IntegrateEndEvent.cpp
168-
${SRC_ROOT}/MainTaskSchedulerRegistry.cpp
169-
${SRC_ROOT}/MainTaskSchedulerFactory.cpp
170170
${SRC_ROOT}/MechanicalOperations.cpp
171171
${SRC_ROOT}/MechanicalVPrintVisitor.cpp
172172
${SRC_ROOT}/MechanicalVisitor.cpp
@@ -202,13 +202,7 @@ set(SOURCE_FILES
202202
${SRC_ROOT}/init.cpp
203203
${SRC_ROOT}/fwd.cpp
204204
${SRC_ROOT}/BaseSimulationExporter.cpp
205-
${SRC_ROOT}/TaskScheduler.cpp
206-
${SRC_ROOT}/TaskSchedulerFactory.cpp
207-
${SRC_ROOT}/TaskSchedulerRegistry.cpp
208-
${SRC_ROOT}/DefaultTaskScheduler.cpp
209-
${SRC_ROOT}/Task.cpp
210-
${SRC_ROOT}/InitTasks.cpp
211-
${SRC_ROOT}/WorkerThread.cpp
205+
212206
${SRC_ROOT}/events/BuildConstraintSystemEndEvent.cpp
213207
${SRC_ROOT}/events/SimulationInitDoneEvent.cpp
214208
${SRC_ROOT}/events/SimulationInitStartEvent.cpp
@@ -271,6 +265,35 @@ set(SOURCE_FILES
271265
${SRC_ROOT}/mechanicalvisitor/MechanicalVOpVisitor.cpp
272266
${SRC_ROOT}/mechanicalvisitor/MechanicalVReallocVisitor.cpp
273267
${SRC_ROOT}/mechanicalvisitor/MechanicalVSizeVisitor.cpp
268+
269+
${SRC_ROOT}/task/CpuTask.cpp
270+
${SRC_ROOT}/task/CpuTaskStatus.cpp
271+
${SRC_ROOT}/task/DefaultTaskScheduler.cpp
272+
${SRC_ROOT}/task/InitTasks.cpp
273+
${SRC_ROOT}/task/MainTaskSchedulerFactory.cpp
274+
${SRC_ROOT}/task/MainTaskSchedulerRegistry.cpp
275+
${SRC_ROOT}/task/Task.cpp
276+
${SRC_ROOT}/task/TaskScheduler.cpp
277+
${SRC_ROOT}/task/TaskSchedulerFactory.cpp
278+
${SRC_ROOT}/task/TaskSchedulerRegistry.cpp
279+
${SRC_ROOT}/task/TaskSchedulerUser.cpp
280+
${SRC_ROOT}/task/WorkerThread.cpp
281+
)
282+
283+
set(DEPRECATED_DIR "compat/sofa/simulation")
284+
set(DEPRECATED_HEADER_FILES
285+
${DEPRECATED_DIR}/CpuTask.h
286+
${DEPRECATED_DIR}/CpuTaskStatus.h
287+
${DEPRECATED_DIR}/DefaultTaskScheduler.h
288+
${DEPRECATED_DIR}/InitTasks.h
289+
${DEPRECATED_DIR}/MainTaskSchedulerFactory.h
290+
${DEPRECATED_DIR}/MainTaskSchedulerRegistry.h
291+
${DEPRECATED_DIR}/ParallelForEach.h
292+
${DEPRECATED_DIR}/Task.h
293+
${DEPRECATED_DIR}/TaskScheduler.h
294+
${DEPRECATED_DIR}/TaskSchedulerFactory.h
295+
${DEPRECATED_DIR}/TaskSchedulerRegistry.h
296+
${DEPRECATED_DIR}/WorkerThread.h
274297
)
275298

276299
sofa_find_package(Sofa.Core REQUIRED)
@@ -279,6 +302,11 @@ add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
279302

280303
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Core)
281304

305+
target_include_directories(${PROJECT_NAME} PUBLIC
306+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/compat>
307+
$<INSTALL_INTERFACE:include/${PROJECT_NAME}_compat>
308+
)
309+
282310
# is this a compiler/linker version specific problem?
283311
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
284312
# target_link_options is available from CMake 3.13
@@ -296,6 +324,8 @@ sofa_create_package_with_targets(
296324
INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
297325
)
298326

327+
install(DIRECTORY compat/ DESTINATION include/${PROJECT_NAME}_compat COMPONENT headers)
328+
299329
# Tests
300330
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
301331
cmake_dependent_option(SOFA_SIMULATION_CORE_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/******************************************************************************
2+
* SOFA, Simulation Open-Framework Architecture *
3+
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify it *
6+
* under the terms of the GNU Lesser General Public License as published by *
7+
* the Free Software Foundation; either version 2.1 of the License, or (at *
8+
* your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, but WITHOUT *
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
13+
* for more details. *
14+
* *
15+
* You should have received a copy of the GNU Lesser General Public License *
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17+
*******************************************************************************
18+
* Authors: The SOFA Team and external contributors (see Authors.txt) *
19+
* *
20+
* Contact information: contact@sofa-framework.org *
21+
******************************************************************************/
22+
#pragma once
23+
#include <sofa/simulation/task/CpuTask.h>
24+
SOFA_HEADER_DEPRECATED("v25.12", "v26.06", "sofa/simulation/task/CpuTask.h")

0 commit comments

Comments
 (0)