我试图从CUDA例子中理解integrate_functor
in particles_kernel.cu
:
struct integrate_functor
{
float deltaTime;
//constructor for functor
//...
template <typename Tuple>
__device__
void operator()(Tuple t)
{
volatile float4 posData = thrust::get<2>(t);
volatile float4 velData = thrust::get<3>(t);
float3 pos = make_float3(posData.x, posData.y, posData.z);
float3 vel = make_float3(velData.x, velData.y, velData.z);
// update position and velocity
// ...
// store new position and velocity
thrust::get<0>(t) = make_float4(pos, posData.w);
thrust::get<1>(t) = make_float4(vel, velData.w);
}
};
Run Code Online (Sandbox Code Playgroud)
我们打电话make_float4(pos, age)
但是make_float4
被定义vector_functions.h
为
static __inline__ __host__ __device__ float4 …
Run Code Online (Sandbox Code Playgroud)