changes to makefile

This commit is contained in:
Evghenii
2014-01-30 14:17:00 +01:00
parent b79915c0c2
commit 0a83f9ab6e
2 changed files with 30 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
PROG=nbody PROG=nbody
ISPC_SRC=nbody.ispc ISPC_SRC=nbody.ispc
#CU_SRC=nbody.cu #CU_SRC=nbody.cu
CXX_SRC=nbody.cpp nbody_serial.cpp CXX_SRC=nbody.cpp
PTXCC_REGMAX=32 PTXCC_REGMAX=32
LLVM_GPU=1 LLVM_GPU=1

View File

@@ -3,11 +3,32 @@ typedef double real;
typedef real<3> real3; typedef real<3> real3;
typedef real<4> real4; typedef real<4> real4;
static uniform real * uniform accx; static uniform real * uniform accx = NULL;
static uniform real * uniform accy; static uniform real * uniform accy;
static uniform real * uniform accz; static uniform real * uniform accz;
static uniform real * uniform gpotList; static uniform real * uniform gpotList;
export
void openNbody(const uniform int n)
{
assert(accx == NULL);
accx = uniform new uniform real[n];
accy = uniform new uniform real[n];
accz = uniform new uniform real[n];
gpotList = uniform new uniform real[n];
}
export
void closeNbody()
{
assert(accx != NULL);
delete accx;
delete accy;
delete accz;
delete gpotList;
}
static inline static inline
real4 ppForce(real3 ipos, real3 jpos, real jmass) real4 ppForce(real3 ipos, real3 jpos, real jmass)
{ {
@@ -137,7 +158,6 @@ void nbodyIntegrate(
uniform real velz[], uniform real velz[],
uniform real energies[]) uniform real energies[])
{ {
uniform int nTasks = num_cores()*4; uniform int nTasks = num_cores()*4;
#ifdef __NVPTX__ #ifdef __NVPTX__
nTasks = nbodies/(4*programCount); nTasks = nbodies/(4*programCount);
@@ -154,7 +174,13 @@ void nbodyIntegrate(
sync; sync;
} }
//energies[0] = gpot; if (energies != NULL)
{
real gpotLoc = 0;
foreach (i = 0 ... nTasks)
gpotLoc += gpotList[i];
energies[0] = reduce_add(gpotLoc);
}
} }