Hi all,
I’ve been trying to use some classes on the GPU lately. It works if I just use one, but if I try to use an array of classes it doesn’t. Here’s the code that works:
typedef GPU_AbstractSubsystem** GPU_AbstractSubsystemPtr;
global void
TakeAScan(float4* newPos, float4* newVel,float4* oldPos, float4* oldVel,float* volts,
int numIons,float* randomNumbers,float* randomGaussians,int offSet1,int offSet2,
float4* acquisitionBuffer,GPU_AbstractSubsystemPtr g_subsystem)
{
// get the index of this ion
int index = __mul24(blockIdx.x,blockDim.x) + threadIdx.x;
// fetch the current position and velocity from for this ion
float4 pos = oldPos[index];
float4 vel = oldVel[index];
float4 acquire = {0.0,0.0,0.0,0.0};
// if ion is within boundaries
if(1)//RecordData(pos,vel,acquire))
{
(*g_subsystem)->AdvanceParticle(pos,vel,volts);
}
// store new values
newPos[index] = pos;
newVel[index] = vel;
acquisitionBuffer[index] = acquire;
}
I thought I should be able to simply change the function to use GPU_AbstractSubsystemPtr* instead of GPU_AbstractSubsystemPtr, and then call the function with: (*g_subsystem[0])->AdvanceParticle(pos,vel,volts);
And then I pass in a reference to the array of classes &d_subsystem[0] for g_subsystem.
Eventually I would iterate through each subsystem, you know. Is this basic idea not correct? I’m not sure if the syntax is screwing me up, or some other error. Anyone have an idea? I appreciate any advice.
Thanks!