Hi
I have been working through the DirectCompute PDC HOL tutorials. The last example - the Game of Life was particulary relevant as I would like to implement a GPGPU version of a reaction- diffusion system in 3D. In the Game of Life periodic boundary conditions are assumed and I can see how the thread addressing can be manipulated to achieve this - see below extracted from the tutorial.
For my implementation I would need Von Neumann (reflective/no flux) boundary conditions. I am at a loss as how to implement this or change the code below to go from periodic to reflective boundaries. Any advice would be much appreciated,
Thanks in advance...
//--------------------------------------------------------------------------------------
// threadIDToCell
// given a thread DTid and group Gid, calculate the corresponding cell position
//--------------------------------------------------------------------------------------
uint3 threadIDToCell( uint3 DTid, uint3 Gid )
{
uint3 output;
output.x = DTid.x - 2 * Gid.x - 1;
output.y = DTid.y - 2 * Gid.y - 1;
output.z = DTid.z - 2 * Gid.z - 1;
return output;
}
//--------------------------------------------------------------------------------------
// getBufferIndex
// given a thread DTid and group Gid, calculate the corresponding cell index in the buffer
//--------------------------------------------------------------------------------------
uint getBufferIndex( uint3 DTid, uint3 Gid )
{
uint3 wrapped;
wrapped.x = ( DTid.x - 2 * Gid.x - 1 + BUFFER_SIZE_X ) % BUFFER_SIZE_X;
wrapped.y = ( DTid.y - 2 * Gid.y - 1 + BUFFER_SIZE_Y ) % BUFFER_SIZE_Y;
wrapped.z = ( DTid.z - 2 * Gid.z - 1 + BUFFER_SIZE_Z ) % BUFFER_SIZE_Z;
return wrapped.x + (wrapped.y * BUFFER_SIZE_X) + (wrapped.z * BUFFER_SIZE_X * BUFFER_SIZE_Y);
}
Add your 2¢