Hi,
I’m noob with CUDA, but I try to create my own particle simulation, and I have problem with putting particles in right order. I want put particles in cube (they should look like cube of particles), usually i use this code (I have 8k particles, 3D):
int aa= 0;
for(int xx = -10; xx <10; xx +=1 )
for(int yy = -10; yy < 10; yy +=1)
for(int zz = -10; zz < 10; zz +=1)
{
particle[aa].r = Vector(xx, yy, zz);
aa++;
}
Now my .cu file:
__device__ float3 tab[8000];
__global__ void kernel(int n)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x; //(0, 20)
int aa = 0;
if(idx < n)
{
for(int i = 0; i < 20; i++)
for(int j = 0; j < 20; j++)
tab[aa++].r = make_float3(idx, i, j);
}
}
Can someone help me, or explain me what I’m doing wrong.
Sry for my English and thx for help.