Skip to content

Commit

Permalink
CUDA template specialization
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger committed Jan 23, 2024
1 parent 616f648 commit ab277b7
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 2 deletions.
4 changes: 4 additions & 0 deletions extensions/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ set(HEADER_FILES

set(SOURCE_FILES
src/SoftRobots.CUDA/init.cpp

src/SoftRobots.CUDA/component/forcefield/CUDAPartialRigidificationForceField.cpp
src/SoftRobots.CUDA/component/forcefield/CUDAPipeForceField.cpp
src/SoftRobots.CUDA/component/forcefield/CUDAPREquivalentStiffnessForceField.cpp
)

sofa_find_package(SoftRobots REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Plugin SoftRobots *
* *
* This plugin is also distributed under the GNU LGPL (Lesser General *
* Public License) license with the same conditions than SOFA. *
* *
* Contributors: Defrost team (INRIA, University of Lille, CNRS, *
* Ecole Centrale de Lille) *
* *
* Contact information: https://project.inria.fr/softrobot/contact/ *
******************************************************************************/
#include <SoftRobots.CUDA/config.h>
#include <SofaCUDA/sofa/gpu/cuda/CudaTypes.h>
#include <SoftRobots/component/forcefield/PREquivalentStiffnessForceField.inl>
#include <sofa/core/ObjectFactory.h>

namespace softrobots::forcefield
{
template class SOFA_SOFTROBOTS_CUDA_API PREquivalentStiffnessForceField<sofa::gpu::cuda::CudaRigid3fTypes>;

#ifdef SOFA_GPU_CUDA_DOUBLE
template class SOFA_SOFTROBOTS_CUDA_API PREquivalentStiffnessForceField<sofa::gpu::cuda::CudaRigid3dTypes>;
#endif
}

int CUDAPREquivalentStiffnessForceFieldClass = sofa::core::RegisterObject("Supports GPU-side computations using CUDA")
.add< softrobots::forcefield::PREquivalentStiffnessForceField<sofa::gpu::cuda::CudaRigid3fTypes> >()
#ifdef SOFA_GPU_CUDA_DOUBLE
.add< softrobots::forcefield::PREquivalentStiffnessForceField<sofa::gpu::cuda::CudaRigid3dTypes> >()
#endif
;

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Plugin SoftRobots *
* *
* This plugin is also distributed under the GNU LGPL (Lesser General *
* Public License) license with the same conditions than SOFA. *
* *
* Contributors: Defrost team (INRIA, University of Lille, CNRS, *
* Ecole Centrale de Lille) *
* *
* Contact information: https://project.inria.fr/softrobot/contact/ *
******************************************************************************/
#include <SoftRobots.CUDA/config.h>
#include <SofaCUDA/sofa/gpu/cuda/CudaTypes.h>
#include <SoftRobots/component/forcefield/PartialRigidificationForceField.inl>
#include <sofa/core/ObjectFactory.h>

namespace softrobots::forcefield
{
template class SOFA_SOFTROBOTS_CUDA_API PartialRigidificationForceField<sofa::gpu::cuda::CudaVec3fTypes, sofa::gpu::cuda::CudaRigid3fTypes>;

#ifdef SOFA_GPU_CUDA_DOUBLE
template class SOFA_SOFTROBOTS_CUDA_API PartialRigidificationForceField<sofa::gpu::cuda::CudaVec3dTypes, sofa::gpu::cuda::CudaRigid3dTypes>;
#endif
}

int CUDAPartialRigidificationForceFieldClass = sofa::core::RegisterObject("Supports GPU-side computations using CUDA")
.add< softrobots::forcefield::PartialRigidificationForceField<sofa::gpu::cuda::CudaVec3fTypes, sofa::gpu::cuda::CudaRigid3fTypes> >()
#ifdef SOFA_GPU_CUDA_DOUBLE
.add< softrobots::forcefield::PartialRigidificationForceField<sofa::gpu::cuda::CudaVec3dTypes, sofa::gpu::cuda::CudaRigid3dTypes> >()
#endif
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Plugin SoftRobots *
* *
* This plugin is also distributed under the GNU LGPL (Lesser General *
* Public License) license with the same conditions than SOFA. *
* *
* Contributors: Defrost team (INRIA, University of Lille, CNRS, *
* Ecole Centrale de Lille) *
* *
* Contact information: https://project.inria.fr/softrobot/contact/ *
******************************************************************************/
#include <SoftRobots.CUDA/config.h>
#include <SofaCUDA/sofa/gpu/cuda/CudaTypes.h>
#include <SoftRobots/component/forcefield/PipeForceField.inl>
#include <sofa/core/ObjectFactory.h>

namespace softrobots::forcefield
{
template class SOFA_SOFTROBOTS_CUDA_API PipeForceField<sofa::gpu::cuda::CudaVec3fTypes>;

#ifdef SOFA_GPU_CUDA_DOUBLE
template class SOFA_SOFTROBOTS_CUDA_API PipeForceField<sofa::gpu::cuda::CudaVec3dTypes>;
#endif
}

int CUDAPipeForceFieldClass = sofa::core::RegisterObject("Supports GPU-side computations using CUDA")
.add< softrobots::forcefield::PipeForceField<sofa::gpu::cuda::CudaVec3fTypes> >()
#ifdef SOFA_GPU_CUDA_DOUBLE
.add< softrobots::forcefield::PipeForceField<sofa::gpu::cuda::CudaVec3dTypes> >()
#endif
;
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public :
typedef typename DataTypes::Deriv Deriv;
typedef typename Coord::Pos Pos;
typedef typename Coord::Quat Quaternion;
typedef sofa::type::vector<Coord> VecCoord;
typedef sofa::type::vector<Deriv> VecDeriv;
typedef typename DataTypes::VecCoord VecCoord;
typedef typename DataTypes::VecDeriv VecDeriv;
typedef sofa::Data<VecCoord> DataVecCoord;
typedef sofa::Data<VecDeriv> DataVecDeriv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <fstream>

#include <SoftRobots/component/forcefield/PartialRigidificationForceField.h>
#include <sofa/core/behavior/MixedInteractionForceField.inl>

namespace softrobots::forcefield
{
Expand Down

0 comments on commit ab277b7

Please sign in to comment.