CudaMechanicalObject.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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 }
00044
00045 }
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
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 }
00092
00093 }
00094
00095 #endif