From 82c4ea2a35689fd14b893a330fd5f3920f69c95d Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Sun, 29 Dec 2024 04:08:56 +0900 Subject: [PATCH] [Multithreading] Apply new factory registration mechanism (#5178) * apply new register mechanism to multithreading * fix test * Apply suggestions from code review (update descriptions) Co-authored-by: Hugo --------- Co-authored-by: Hugo --- .../src/MultiThreading/DataExchange.cpp | 34 ++++----- .../src/MultiThreading/MeanComputation.cpp | 16 +++-- .../AnimationLoopParallelScheduler.cpp | 8 ++- .../algorithm/ParallelBVHNarrowPhase.cpp | 9 +-- .../ParallelBruteForceBroadPhase.cpp | 10 +-- .../iterative/ParallelCGLinearSolver.cpp | 11 +-- .../mapping/linear/BeamLinearMapping_mt.cpp | 10 +-- .../ParallelHexahedronFEMForceField.cpp | 12 ++-- .../ParallelTetrahedronFEMForceField.cpp | 10 +-- .../ParallelTetrahedronFEMForceField.h | 2 +- .../ParallelTetrahedronFEMForceField.inl | 2 +- .../spring/ParallelMeshSpringForceField.cpp | 11 +-- .../spring/ParallelSpringForceField.cpp | 15 ++-- .../src/MultiThreading/config.h.in | 9 ++- .../src/MultiThreading/initMultiThreading.cpp | 70 ++++++++++++++++++- .../ParallelImplementationsRegistry_test.cpp | 3 +- 16 files changed, 161 insertions(+), 71 deletions(-) diff --git a/applications/plugins/MultiThreading/src/MultiThreading/DataExchange.cpp b/applications/plugins/MultiThreading/src/MultiThreading/DataExchange.cpp index 1a7e71ce619..dbe0d4f11cf 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/DataExchange.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/DataExchange.cpp @@ -33,25 +33,25 @@ namespace sofa::core SOFA_EVENT_CPP(DataExchangeEvent) -// Register in the Factory -int DataExchangeClass = core::RegisterObject("DataExchange") -.add< DataExchange< sofa::type::vector > >(true) -.add< DataExchange< sofa::type::vector > >() -.add< DataExchange< sofa::type::vector > >() -.add< DataExchange< sofa::type::Vec3d > >() -.add< DataExchange< double > >() - -.add< DataExchange< sofa::type::vector > >() -.add< DataExchange< sofa::type::vector > >() -.add< DataExchange< sofa::type::vector > >() -.add< DataExchange< sofa::type::Vec3f > >() -.add< DataExchange< float > >() +void registerDataExchange(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Component for data memory sharing in the context of multi-threading applications") + .add< DataExchange< sofa::type::vector > >(true) + .add< DataExchange< sofa::type::vector > >() + .add< DataExchange< sofa::type::vector > >() + .add< DataExchange< sofa::type::Vec3d > >() + .add< DataExchange< double > >() -.add< DataExchange< sofa::type::vector > >() -.add< DataExchange< sofa::type::vector > >() -.add< DataExchange< bool > >() -; + .add< DataExchange< sofa::type::vector > >() + .add< DataExchange< sofa::type::vector > >() + .add< DataExchange< sofa::type::vector > >() + .add< DataExchange< sofa::type::Vec3f > >() + .add< DataExchange< float > >() + .add< DataExchange< sofa::type::vector > >() + .add< DataExchange< sofa::type::vector > >() + .add< DataExchange< bool > >()); +} template class SOFA_MULTITHREADING_PLUGIN_API DataExchange< sofa::type::vector >; template class SOFA_MULTITHREADING_PLUGIN_API DataExchange< sofa::type::vector >; diff --git a/applications/plugins/MultiThreading/src/MultiThreading/MeanComputation.cpp b/applications/plugins/MultiThreading/src/MultiThreading/MeanComputation.cpp index 4fb6c374091..3d4fcbac040 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/MeanComputation.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/MeanComputation.cpp @@ -29,13 +29,15 @@ namespace sofa::component::engine { -int MeanComputationEngineClass = core::RegisterObject("Compute the mean of the input elements") - .add< MeanComputation >(true) // default template - .add< MeanComputation >() - .add< MeanComputation >() - .add< MeanComputation >() - .add< MeanComputation >() - ; +void registerMeanComputationEngine(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("Compute the mean of the input elements.") + .add< MeanComputation >(true) // default template + .add< MeanComputation >() + .add< MeanComputation >() + .add< MeanComputation >() + .add< MeanComputation >()); +} template class SOFA_MULTITHREADING_PLUGIN_API MeanComputation< defaulttype::Vec3Types >; template class SOFA_MULTITHREADING_PLUGIN_API MeanComputation< defaulttype::Vec1Types >; diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/animationloop/AnimationLoopParallelScheduler.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/animationloop/AnimationLoopParallelScheduler.cpp index 1698d38bc96..636f04472d5 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/animationloop/AnimationLoopParallelScheduler.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/animationloop/AnimationLoopParallelScheduler.cpp @@ -39,9 +39,11 @@ namespace multithreading::component::animationloop { -int AnimationLoopParallelSchedulerClass = sofa::core::RegisterObject("parallel animation loop, using intel tbb library") - .add< AnimationLoopParallelScheduler >() - ; +void registerAnimationLoopParallelScheduler(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parallel animation loop, using the Intel tbb library.") + .add< AnimationLoopParallelScheduler >()); +} AnimationLoopParallelScheduler::AnimationLoopParallelScheduler(sofa::simulation::Node* _gnode) : Inherit() diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp index 3cf5782a58d..db0659a8504 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp @@ -36,13 +36,14 @@ namespace multithreading::component::collision::detection::algorithm const bool isParallelBVHNarrowPhaseImplementationRegistered = multithreading::ParallelImplementationsRegistry::addEquivalentImplementations("BVHNarrowPhase", "ParallelBVHNarrowPhase"); +void registerParallelBVHNarrowPhase(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parallel version of the narrow phase collision detection based on boundary volume hierarchy.") + .add< ParallelBVHNarrowPhase >()); +} using sofa::helper::ScopedAdvancedTimer; -int ParallelBVHNarrowPhaseClass = sofa::core::RegisterObject("Narrow phase collision detection based on boundary volume hierarchy") - .add< ParallelBVHNarrowPhase >() -; - ParallelBVHNarrowPhase::ParallelBVHNarrowPhase() {} diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBruteForceBroadPhase.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBruteForceBroadPhase.cpp index 72cf9d8b848..242d543a303 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBruteForceBroadPhase.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBruteForceBroadPhase.cpp @@ -34,11 +34,13 @@ namespace multithreading::component::collision::detection::algorithm const bool isParallelParallelBruteForceBroadPhaseImplementationRegistered = multithreading::ParallelImplementationsRegistry::addEquivalentImplementations("BruteForceBroadPhase", "ParallelBruteForceBroadPhase"); -using sofa::helper::ScopedAdvancedTimer; +void registerParallelBruteForceBroadPhase(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parallel version of the collision detection using extensive pair-wise tests performed concurrently.") + .add< ParallelBruteForceBroadPhase >()); +} -int ParallelBruteForceBroadPhaseClass = sofa::core::RegisterObject("Collision detection using extensive pair-wise tests performed in parallel") - .add< ParallelBruteForceBroadPhase >() -; +using sofa::helper::ScopedAdvancedTimer; ParallelBruteForceBroadPhase::ParallelBruteForceBroadPhase() : BruteForceBroadPhase() diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/linearsolver/iterative/ParallelCGLinearSolver.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/linearsolver/iterative/ParallelCGLinearSolver.cpp index 22cd5f3569b..5838bb7295c 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/linearsolver/iterative/ParallelCGLinearSolver.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/linearsolver/iterative/ParallelCGLinearSolver.cpp @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** * SOFA, Simulation Open-Framework Architecture * * (c) 2006 INRIA, USTL, UJF, CNRS, MGH * * * @@ -59,9 +59,12 @@ ParallelCGLinearSolver< ParallelCompressedRowSparseMatrixMechanical, sofa template class SOFA_MULTITHREADING_PLUGIN_API ParallelCGLinearSolver< ParallelCompressedRowSparseMatrixMechanical>, sofa::linearalgebra::FullVector >; -int ParallelCGLinearSolverClass = sofa::core::RegisterObject("Linear system solver using the conjugate gradient iterative algorithm in parallel") - .add< ParallelCGLinearSolver< ParallelCompressedRowSparseMatrixMechanical, sofa::linearalgebra::FullVector > >(true) - .add< ParallelCGLinearSolver< ParallelCompressedRowSparseMatrixMechanical>, sofa::linearalgebra::FullVector > >(); +void registerParallelCGLinearSolver(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parallel version of the linear solver using the conjugate gradient iterative algorithm.") + .add< ParallelCGLinearSolver< ParallelCompressedRowSparseMatrixMechanical, sofa::linearalgebra::FullVector > >(true) + .add< ParallelCGLinearSolver< ParallelCompressedRowSparseMatrixMechanical>, sofa::linearalgebra::FullVector > >()); +} const bool isParallelCGLinearSolverImplementationRegistered = ParallelImplementationsRegistry::addEquivalentImplementations("CGLinearSolver", "ParallelCGLinearSolver"); diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/mapping/linear/BeamLinearMapping_mt.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/mapping/linear/BeamLinearMapping_mt.cpp index dbd167d2989..20013a22c14 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/mapping/linear/BeamLinearMapping_mt.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/mapping/linear/BeamLinearMapping_mt.cpp @@ -32,11 +32,11 @@ namespace multithreading::component::mapping::linear const bool isBeamLinearMapping_mtImplementationRegistered = multithreading::ParallelImplementationsRegistry::addEquivalentImplementations("BeamLinearMapping", "BeamLinearMapping_mt"); -//using namespace defaulttype; -// Register in the Factory -int BeamLinearMapping_mtClass = sofa::core::RegisterObject("Set the positions and velocities of points attached to a beam using linear interpolation between DOFs") - .add< BeamLinearMapping_mt< Rigid3Types, Vec3Types > >() - ; +void registerBeamLinearMapping_mt(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Set the positions and velocities of points attached to a beam using linear interpolation between DOFs.") + .add< BeamLinearMapping_mt< Rigid3Types, Vec3Types > >()); +} template class BeamLinearMapping_mt< Rigid3Types, Vec3Types >; diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelHexahedronFEMForceField.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelHexahedronFEMForceField.cpp index e8f55a188f7..e1d5b7c737a 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelHexahedronFEMForceField.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelHexahedronFEMForceField.cpp @@ -29,14 +29,16 @@ namespace multithreading::component::forcefield::solidmechanics::fem::elastic { +using namespace sofa::defaulttype; + const bool isParallelHexahedronFEMForceFieldImplementationRegistered = multithreading::ParallelImplementationsRegistry::addEquivalentImplementations("HexahedronFEMForceField", "ParallelHexahedronFEMForceField"); -using namespace sofa::defaulttype; - -// Register in the Factory -int ParallelHexahedronFEMForceFieldClass = sofa::core::RegisterObject("Parallel hexahedral finite elements") - .add < ParallelHexahedronFEMForceField < Vec3Types > > (); +void registerParallelHexahedronFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parallel implementation of a linear elastic material using hexahedral finite elements.") + .add < ParallelHexahedronFEMForceField < Vec3Types > > ()); +} template class SOFA_MULTITHREADING_PLUGIN_API ParallelHexahedronFEMForceField; diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.cpp index bf73f5b1fa1..cc0d876f5fa 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.cpp @@ -26,7 +26,7 @@ #include -namespace multithreading::component::solidmechanics::fem::elastic +namespace multithreading::component::forcefield::solidmechanics::fem::elastic { using namespace sofa::defaulttype; @@ -34,9 +34,11 @@ using namespace sofa::defaulttype; const bool isParallelTetrahedronFEMForceFieldImplementationRegistered = multithreading::ParallelImplementationsRegistry::addEquivalentImplementations("TetrahedronFEMForceField", "ParallelTetrahedronFEMForceField"); -// Register in the Factory -int ParallelTetrahedronFEMForceFieldClass = sofa::core::RegisterObject("Parallel tetrahedral finite elements") - .add < ParallelTetrahedronFEMForceField < Vec3Types > > (); +void registerParallelTetrahedronFEMForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parallel implementation of a linear elastic material using tetrahedral finite elements..") + .add < ParallelTetrahedronFEMForceField < Vec3Types > > ()); +} template class SOFA_MULTITHREADING_PLUGIN_API ParallelTetrahedronFEMForceField; diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.h b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.h index 0e9cb332cbd..be6a9186b19 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.h +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.h @@ -30,7 +30,7 @@ #include -namespace multithreading::component::solidmechanics::fem::elastic +namespace multithreading::component::forcefield::solidmechanics::fem::elastic { /** diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.inl b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.inl index e144a95b764..f2f620b5505 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.inl +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/fem/elastic/ParallelTetrahedronFEMForceField.inl @@ -27,7 +27,7 @@ #include #include -namespace multithreading::component::solidmechanics::fem::elastic +namespace multithreading::component::forcefield::solidmechanics::fem::elastic { template diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/spring/ParallelMeshSpringForceField.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/spring/ParallelMeshSpringForceField.cpp index dcfd24c396a..132a645626e 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/spring/ParallelMeshSpringForceField.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/spring/ParallelMeshSpringForceField.cpp @@ -25,10 +25,13 @@ namespace multithreading::component::solidmechanics::spring { -int ParallelMeshSpringForceFieldClass = sofa::core::RegisterObject("Parallel stiff springs acting along the edges of a mesh") - .add< ParallelMeshSpringForceField >() - .add< ParallelMeshSpringForceField >() - .add< ParallelMeshSpringForceField >(); +void registerParallelMeshSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parallel stiff springs acting along the edges of a mesh.") + .add< ParallelMeshSpringForceField >() + .add< ParallelMeshSpringForceField >() + .add< ParallelMeshSpringForceField >()); +} template class SOFA_MULTITHREADING_PLUGIN_API ParallelMeshSpringForceField; template class SOFA_MULTITHREADING_PLUGIN_API ParallelMeshSpringForceField; diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/spring/ParallelSpringForceField.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/spring/ParallelSpringForceField.cpp index 6c2b2d858b0..682b67ae414 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/spring/ParallelSpringForceField.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/solidmechanics/spring/ParallelSpringForceField.cpp @@ -25,12 +25,15 @@ namespace multithreading::component::solidmechanics::spring { -int ParallelSpringForceFieldClass = sofa::core::RegisterObject("Parallel stiff springs") - .add< ParallelSpringForceField >() - .add< ParallelSpringForceField >() - .add< ParallelSpringForceField >() - .add< ParallelSpringForceField >() - .add< ParallelSpringForceField >(); +void registerParallelSpringForceField(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(sofa::core::ObjectRegistrationData("Parallel stiff springs.") + .add< ParallelSpringForceField >() + .add< ParallelSpringForceField >() + .add< ParallelSpringForceField >() + .add< ParallelSpringForceField >() + .add< ParallelSpringForceField >()); +} template class SOFA_MULTITHREADING_PLUGIN_API ParallelSpringForceField; template class SOFA_MULTITHREADING_PLUGIN_API ParallelSpringForceField; diff --git a/applications/plugins/MultiThreading/src/MultiThreading/config.h.in b/applications/plugins/MultiThreading/src/MultiThreading/config.h.in index e00cd0f836f..8b2f185328b 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/config.h.in +++ b/applications/plugins/MultiThreading/src/MultiThreading/config.h.in @@ -19,8 +19,7 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#ifndef MULTITHREADING_CONFIG_H -#define MULTITHREADING_CONFIG_H +#pragma once #include @@ -31,7 +30,11 @@ # define SOFA_MULTITHREADING_PLUGIN_API SOFA_IMPORT_DYNAMIC_LIBRARY #endif -#endif +namespace multithreading +{ + constexpr const char* MODULE_NAME = "@PROJECT_NAME@"; + constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@"; +} // namespace multithreading #ifdef SOFA_BUILD_MULTITHREADING #define SOFA_ATTRIBUTE_DISABLED__TASKSCHEDULERUSER_DATANAME(msg) diff --git a/applications/plugins/MultiThreading/src/MultiThreading/initMultiThreading.cpp b/applications/plugins/MultiThreading/src/MultiThreading/initMultiThreading.cpp index d14bb740f10..853e1ddfc68 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/initMultiThreading.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/initMultiThreading.cpp @@ -24,16 +24,63 @@ #include +#include +#include + +namespace sofa::core +{ +extern void registerDataExchange(sofa::core::ObjectFactory* factory); +} + +namespace sofa::component::engine +{ +extern void registerMeanComputationEngine(sofa::core::ObjectFactory* factory); +} + namespace multithreading { +namespace component::animationloop +{ +extern void registerAnimationLoopParallelScheduler(sofa::core::ObjectFactory* factory); +} + +namespace component::collision::detection::algorithm +{ +extern void registerParallelBVHNarrowPhase(sofa::core::ObjectFactory* factory); +extern void registerParallelBruteForceBroadPhase(sofa::core::ObjectFactory* factory); +} + +namespace component::linearsolver::iterative +{ +extern void registerParallelCGLinearSolver(sofa::core::ObjectFactory* factory); +} + +namespace component::mapping::linear +{ +extern void registerBeamLinearMapping_mt(sofa::core::ObjectFactory* factory); +} + +namespace component::forcefield::solidmechanics::fem::elastic +{ +extern void registerParallelHexahedronFEMForceField(sofa::core::ObjectFactory* factory); +extern void registerParallelTetrahedronFEMForceField(sofa::core::ObjectFactory* factory); +} + +namespace component::solidmechanics::spring +{ +extern void registerParallelMeshSpringForceField(sofa::core::ObjectFactory* factory); +extern void registerParallelSpringForceField(sofa::core::ObjectFactory* factory); +} + extern "C" { SOFA_MULTITHREADING_PLUGIN_API void initExternalModule(); SOFA_MULTITHREADING_PLUGIN_API const char* getModuleName(); SOFA_MULTITHREADING_PLUGIN_API const char* getModuleVersion(); SOFA_MULTITHREADING_PLUGIN_API const char* getModuleLicense(); SOFA_MULTITHREADING_PLUGIN_API const char* getModuleDescription(); +SOFA_MULTITHREADING_PLUGIN_API void registerObjects(sofa::core::ObjectFactory* factory); } void init() @@ -41,6 +88,9 @@ void init() static bool first = true; if (first) { + // make sure that this plugin is registered into the PluginManager + sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME); + sofa::component::linearsolver::iterative::init(); first = false; } @@ -53,12 +103,12 @@ void initExternalModule() const char* getModuleName() { - return "MultiThreading"; + return MODULE_NAME; } const char* getModuleVersion() { - return "1.0"; + return MODULE_VERSION; } const char* getModuleLicense() @@ -71,4 +121,20 @@ const char* getModuleDescription() return "MultiThreading SOFA Framework"; } +void registerObjects(sofa::core::ObjectFactory* factory) +{ + sofa::core::registerDataExchange(factory); + sofa::component::engine::registerMeanComputationEngine(factory); + multithreading::component::animationloop::registerAnimationLoopParallelScheduler(factory); + multithreading::component::collision::detection::algorithm::registerParallelBVHNarrowPhase(factory); + multithreading::component::collision::detection::algorithm::registerParallelBruteForceBroadPhase(factory); + multithreading::component::linearsolver::iterative::registerParallelCGLinearSolver(factory); + multithreading::component::mapping::linear::registerBeamLinearMapping_mt(factory); + multithreading::component::forcefield::solidmechanics::fem::elastic::registerParallelHexahedronFEMForceField(factory); + multithreading::component::forcefield::solidmechanics::fem::elastic::registerParallelTetrahedronFEMForceField(factory); + multithreading::component::solidmechanics::spring::registerParallelMeshSpringForceField(factory); + multithreading::component::solidmechanics::spring::registerParallelSpringForceField(factory); + +} + } diff --git a/applications/plugins/MultiThreading/test/ParallelImplementationsRegistry_test.cpp b/applications/plugins/MultiThreading/test/ParallelImplementationsRegistry_test.cpp index e93fcf403df..8ecd3f7e407 100644 --- a/applications/plugins/MultiThreading/test/ParallelImplementationsRegistry_test.cpp +++ b/applications/plugins/MultiThreading/test/ParallelImplementationsRegistry_test.cpp @@ -1,4 +1,4 @@ -/****************************************************************************** +/****************************************************************************** * SOFA, Simulation Open-Framework Architecture * * (c) 2006 INRIA, USTL, UJF, CNRS, MGH * * * @@ -36,6 +36,7 @@ TEST(ParallelImplementationsRegistry, existInObjectFactory) sofa::simpleapi::importPlugin("Sofa.Component.Collision.Detection.Algorithm"); sofa::simpleapi::importPlugin("Sofa.Component.SolidMechanics.FEM.Elastic"); sofa::simpleapi::importPlugin("Sofa.Component.Mapping.Linear"); + sofa::simpleapi::importPlugin("MultiThreading"); const auto implementations = ParallelImplementationsRegistry::getImplementations();