CudaMechanicalObject.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                               SOFA :: Modules                               *
00020 *                                                                             *
00021 * Authors: The SOFA Team and external contributors (see Authors.txt)          *
00022 *                                                                             *
00023 * Contact information: contact@sofa-framework.org                             *
00024 ******************************************************************************/
00025 #ifndef SOFA_GPU_CUDA_CUDAMECHANICALOBJECT_H
00026 #define SOFA_GPU_CUDA_CUDAMECHANICALOBJECT_H
00027 
00028 #include "CudaTypes.h"
00029 #include <sofa/component/MechanicalObject.h>
00030 
00031 namespace sofa
00032 {
00033 
00034 namespace gpu
00035 {
00036 
00037 namespace cuda
00038 {
00039 
00040 template<class DataTypes>
00041 class CudaKernelsMechanicalObject;
00042 
00043 } // namespace cuda
00044 
00045 } // namespace gpu
00046 
00047 namespace component
00048 {
00049 
00050 template<class TCoord, class TDeriv, class TReal>
00051 class MechanicalObjectInternalData< gpu::cuda::CudaVectorTypes<TCoord,TDeriv,TReal> >
00052 {
00053 public:
00054     typedef gpu::cuda::CudaVectorTypes<TCoord,TDeriv,TReal> DataTypes;
00055     typedef MechanicalObject<DataTypes> Main;
00056     typedef typename Main::VecId VecId;
00057     typedef typename Main::VMultiOp VMultiOp;
00058     typedef typename DataTypes::VecCoord VecCoord;
00059     typedef typename DataTypes::VecDeriv VecDeriv;
00060     typedef typename DataTypes::Coord Coord;
00061     typedef typename DataTypes::Deriv Deriv;
00062     typedef typename DataTypes::Real Real;
00063 
00064     typedef gpu::cuda::CudaKernelsMechanicalObject<DataTypes> Kernels;
00065 
00067     VecDeriv tmpdot;
00068 
00069     static void accumulateForce(Main* m);
00070     static void vAlloc(Main* m, VecId v);
00071     static void vOp(Main* m, VecId v, VecId a, VecId b, double f);
00072     static void vMultiOp(Main* m, const VMultiOp& ops);
00073     static double vDot(Main* m, VecId a, VecId b);
00074     static void resetForce(Main* m);
00075 };
00076 
00077 // I know using macros is bad design but this is the only way not to repeat the code for all CUDA types
00078 #define CudaMechanicalObject_DeclMethods(T) \
00079     template<> void MechanicalObject< T >::accumulateForce(); \
00080     template<> void MechanicalObject< T >::vOp(VecId v, VecId a, VecId b, double f); \
00081     template<> void MechanicalObject< T >::vMultiOp(const VMultiOp& ops); \
00082     template<> double MechanicalObject< T >::vDot(VecId a, VecId b); \
00083     template<> void MechanicalObject< T >::resetForce();
00084 
00085 CudaMechanicalObject_DeclMethods(gpu::cuda::CudaVec3fTypes);
00086 CudaMechanicalObject_DeclMethods(gpu::cuda::CudaVec3f1Types);
00087 
00088 
00089 #undef CudaMechanicalObject_DeclMethods
00090 
00091 } // namespace component
00092 
00093 } // namespace sofa
00094 
00095 #endif

Generated on Sun Nov 23 04:00:03 2008 for Sofa by  doxygen 1.5.7.1