55 template<
int Begin,
int End,
int Step = 1>
57 template<
typename Action>
58 __device__
static void step(
const Action& action) {
65 template<
int End,
int Step>
67 template<
typename Action>
68 __device__
static void step(
const Action& action) { }
97 template<
template<
int>
class T,
int N,
int MAXN,
class B,
class P>
99 B operator ()(
const int& n,
const P&
x){
101 return T<N>::choose(x);
102 else if(n <= MAXN && n > N)
117 const static int n = i;
124 template<
class implementation,
class T>
126 integ->kernel(compile_time_param);
132 template<
class implementation,
class T>
133 void launch_template(implementation* integ, implementation* gpu_integ, T compile_time_param)
135 if(integ->get_ensemble().nbod() == T::n)
136 generic_kernel<<<integ->gridDim(), integ->threadDim(), integ->shmemSize() >>>(gpu_integ,compile_time_param);
138 ERROR(
"Error launching kernel. Active ensemble has " + inttostr(integ->get_ensemble().nbod()) +
" bodies per system.\n");
169 template<
class integ_pair>
170 static void choose(integ_pair p){
172 typename integ_pair::first_type integ = p.first;
174 int sys_p_block = integ->override_system_per_block();
175 const int nsys = integ->get_ensemble().nsys();
176 const int tps = integ->thread_per_system(ctp);
177 const int shm = integ->shmem_per_system(ctp);
178 if(sys_p_block == 0){
183 const int nblocks = ( nsys + sys_p_block - 1 ) / sys_p_block;
184 const int shmemSize = sys_p_block * shm;
190 threadDim.x = sys_p_block;
193 int blocksize = threadDim.x * threadDim.y;
195 throw runtime_error(
"The block size settings exceed CUDA requirements");
198 generic_kernel<<<gridDim, threadDim, shmemSize>>>(p.second, ctp);
216 template<
class implementation>
219 if(integ->get_ensemble().nbod() <= MAX_NBODIES){
220 implementation* gpu_integ;
221 cudaErrCheck ( cudaMalloc(&gpu_integ,
sizeof(implementation)) );
222 cudaErrCheck ( cudaMemcpy(gpu_integ,integ,
sizeof(implementation),cudaMemcpyHostToDevice) );
224 typedef std::pair<implementation*,implementation*> integ_pair ;
225 integ_pair p ( integ, gpu_integ );
226 int nbod = integ->get_ensemble().nbod();
234 snprintf(b,100,
"Invalid number of bodies. (Swarm-NG was compiled with MAX_NBODIES = %d bodies per system.)",MAX_NBODIES);