+1
This commit is contained in:
@@ -2,7 +2,7 @@ PROG=nbody
|
|||||||
ISPC_SRC=nbody.ispc
|
ISPC_SRC=nbody.ispc
|
||||||
#CU_SRC=nbody.cu
|
#CU_SRC=nbody.cu
|
||||||
CXX_SRC=nbody.cpp
|
CXX_SRC=nbody.cpp
|
||||||
PTXCC_REGMAX=128
|
PTXCC_REGMAX=64
|
||||||
|
|
||||||
LLVM_GPU=1
|
LLVM_GPU=1
|
||||||
NVVM_GPU=1
|
NVVM_GPU=1
|
||||||
|
|||||||
@@ -87,24 +87,27 @@ void computeForces(
|
|||||||
real iaccy = 0;
|
real iaccy = 0;
|
||||||
real iaccz = 0;
|
real iaccz = 0;
|
||||||
real igpot = 0;
|
real igpot = 0;
|
||||||
for (uniform int j = 0; j < nbodies; j++)
|
for (uniform int j = 0; j < nbodies; j += 1)
|
||||||
{
|
{
|
||||||
const real jposx = posx[j];
|
#define STEP(jk) {\
|
||||||
const real jposy = posy[j];
|
const real jposx = posx[j+jk]; \
|
||||||
const real jposz = posz[j];
|
const real jposy = posy[j+jk]; \
|
||||||
const real jmass = mass[j];
|
const real jposz = posz[j+jk]; \
|
||||||
const real dx = jposx - iposx;
|
const real jmass = mass[j+jk]; \
|
||||||
const real dy = jposy - iposy;
|
const real dx = jposx - iposx; \
|
||||||
const real dz = jposz - iposz;
|
const real dy = jposy - iposy; \
|
||||||
const real r2 = dx*dx + dy*dy + dz*dz;
|
const real dz = jposz - iposz; \
|
||||||
const real rinv = r2 > 0.0d ? rsqrt((float)r2) : 0;
|
const real r2 = dx*dx + dy*dy + dz*dz; \
|
||||||
const real mrinv = -jmass * rinv;
|
const real rinv = r2 > 0.0d ? rsqrt((float)r2) : 0; \
|
||||||
const real mrinv3 = mrinv * rinv*rinv;
|
const real mrinv = -jmass * rinv; \
|
||||||
|
const real mrinv3 = mrinv * rinv*rinv; \
|
||||||
iaccx += mrinv3 * dx;
|
\
|
||||||
iaccy += mrinv3 * dy;
|
iaccx += mrinv3 * dx; \
|
||||||
iaccz += mrinv3 * dz;
|
iaccy += mrinv3 * dy; \
|
||||||
igpot += mrinv;
|
iaccz += mrinv3 * dz; \
|
||||||
|
igpot += mrinv; \
|
||||||
|
}
|
||||||
|
STEP(0)
|
||||||
}
|
}
|
||||||
accx[i] = iaccx;
|
accx[i] = iaccx;
|
||||||
accy[i] = iaccy;
|
accy[i] = iaccy;
|
||||||
|
|||||||
Reference in New Issue
Block a user