25 #include "../common.hpp"
27 #include "device_functions.h"
29 #define ASSUME_PROPAGATOR_USES_STD_COORDINATES 0
31 namespace swarm {
namespace gpu {
namespace bppt {
34 GENERIC const T& max3(
const T& a,
const T& b,
const T&
c){
74 template<
template<
class T,
class G>
class Propagator,
class Monitor
75 ,
template<
class T>
class Gravitation>
80 typedef Monitor monitor_t;
83 typedef typename monitor_t::params mon_params_t;
89 typedef typename Propagator< defpar_t, Gravitation<defpar_t> >::params prop_params_t;
92 mon_params_t _mon_params;
93 prop_params_t _prop_params;
101 generic(
const config& cfg):
base(cfg), _mon_params(cfg),_prop_params(cfg) {
113 const int grav = Gravitation<T>::thread_per_system();
115 const int moni = Monitor::thread_per_system(compile_time_param);
116 return max3( grav, prop, moni);
122 const int grav = Gravitation<T>::shmem_per_system();
124 const int moni = Monitor::shmem_per_system(compile_time_param);
125 return max3( grav, prop, moni);
138 GPUAPI
void kernel(T compile_time_param){
141 typedef Gravitation<T> GravitationInstance;
145 typedef typename GravitationInstance::shared_data grav_t;
149 const int nbod = T::n;
160 monitor_t montest(_mon_params,sys,*
_log) ;
163 Propagator<T,GravitationInstance> prop(_prop_params,sys,calcForces);
176 for(
int iter = 0 ; (iter <
_max_iterations) && sys.is_active() ; iter ++ ) {
182 bool thread_needs_std_coord =
false;
183 bool using_std_coord =
false;
186 #if ASSUME_PROPAGATOR_USES_STD_COORDINATES
190 #if (__CUDA_ARCH__ >= 200)
192 bool block_needs_std_coord = syncthreads_or((
int)(thread_needs_std_coord));
204 bool block_needs_std_coord =
true;
206 if(block_needs_std_coord)
208 prop.convert_internal_to_std_coord();
209 using_std_coord =
true;
221 prop.convert_std_to_internal_coord();
222 using_std_coord =
false;
227 if( sys.is_active() && prop.is_first_thread_in_system() )
230 { sys.set_inactive(); }