Swarm-NG  1.1
swarm::gpu::bppt::generic< Propagator, Monitor, Gravitation > Class Template Reference

Generic integrator for rapid creation of new integrators. More...

#include <generic_gpu_bppt_integrator.hpp>

Inheritance diagram for swarm::gpu::bppt::generic< Propagator, Monitor, Gravitation >:
swarm::gpu::bppt::integrator swarm::gpu::integrator swarm::integrator

Public Member Functions

 generic (const config &cfg)
 The integrator is initialized from the configuration The generic integrator does not require any configuration parameters. More...
 
virtual void launch_integrator ()
 launch the integrator
 
template<class T >
GPUAPI void kernel (T compile_time_param)
 Integrator the system using the provided Propagator and Monitor. More...
 
- Public Member Functions inherited from swarm::gpu::bppt::integrator
 integrator (const config &cfg)
 Constructor.
 
const int & override_system_per_block () const
 User specified value of system_per_block. More...
 
- Public Member Functions inherited from swarm::gpu::integrator
 integrator (const config &cfg)
 Pass on constructor.
 
virtual void integrate ()
 Interfaces function to integrate, for use by general user. More...
 
virtual void core_integrate ()
 To integrate without any bookkeeping. More...
 
virtual void set_log_manager (log::Pmanager &l)
 Read the GPU log object from log manager and set it.
 
void set_log (gpulog::device_log *log)
 Set the GPU log object used for loggin output.
 
gpulog::device_log * get_device_log ()
 Get the GPU log object used for logging output.
 
void set_ensemble (defaultEnsemble &ens)
 Set the ensemble, only provide an ensemble on host. This cals automatically creates a copy of ensemble on GPU and keeps it in sync. Refer to set_ensemble(host_ens,device_ens) if you wish to manage the GPU memory allocation.
 
void set_ensemble (defaultEnsemble &host_ens, deviceEnsemble &device_ens)
 Set two host and device ensembles, two ensembles should match. More...
 
void upload_ensemble ()
 Synchronize device ensemble with host ensemble.
 
void download_ensemble ()
 Synchronize host ensemble with device ensemble.
 
- Public Member Functions inherited from swarm::integrator
 integrator (const config &cfg)
 Inetgrator class should be configurable. Derived instances should also have a constructor with similar signature and pass on the config parameter.
 
virtual void flush_log ()
 Flush the host log.
 
virtual defaultEnsembleget_ensemble ()
 Access the ensemble subject to integration.
 
virtual void set_destination_time (const double &destination_time)
 Set the time marker to end the integration.
 

Static Public Member Functions

template<class T >
static GENERIC int thread_per_system (T compile_time_param)
 Define the number of thread per system.
 
template<class T >
static GENERIC int shmem_per_system (T compile_time_param)
 Define the amount of shared memory per system.
 
- Static Public Member Functions inherited from swarm::gpu::bppt::integrator
template<class T >
static GENERIC int thread_per_system (T compile_time_param)
 Calculate number of worker threads needed for each system. More...
 
template<class T >
static GENERIC int shmem_per_system (T compile_time_param)
 Helper Function: Logical amount of shared memory needed for force calculations per thread This value is calculated from number of bodies, if this is used in a kernel, the actual amount of shared memory allocated might be different. More...
 

Additional Inherited Members

- Static Public Attributes inherited from swarm::integrator
static const int _default_max_iterations = 10000000
 Default value for maximum number of iterations. c.f. _max_iterations.
 
static const int _default_max_attempts = 1000000
 Default value for maximum number of attempts. c.f. _max_attempts.
 
- Protected Attributes inherited from swarm::gpu::bppt::integrator
int _override_system_per_block
 Number of systems allocated in a block. Should be a multiple of SHMEM_CHUNK_SIZE for better coalescing.
 

Detailed Description

template<template< class T, class G > class Propagator, class Monitor, template< class T > class Gravitation>
class swarm::gpu::bppt::generic< Propagator, Monitor, Gravitation >

Generic integrator for rapid creation of new integrators.

The common functionality for a body-pair-per-thread GPU integrator is put in this class. The core functionality of integration is provided by Propagator template and the core functionality for logging and deactivation is provided by Monitor. Inside the integration loop, Propagator and Monitor are used for the action work.

Both Propagator and Monitor are supposed to have a struct "params". The params will be initialized with the config. During integration, params is passed to the Propagator or Monitor to set up initial values.

Propagator is expected to expose three methods:

  • init: called before the integration loop (Usually empty)
  • advance: called inside the integration loop (Supposed to advance position, velocity and time)
  • shutdown: called after the integration loop (Usually empty)

Monitor is expected to implement the "operator()" and act like a function object. It is called inside the integration loop and is supposed to examine the state of the system. Write notes to the log if necessary and deactivate the system if it does not need to integrated anymore.

For an example of how to use this Generic integrator refer to Euler integrator.

An extention of this class proposed to take a Gravitation class as a template. It Is not implemented yet.

one suggestion for the template line is: template< template<class T, class G> class Propagator, template<class L> class Monitor, class G > and G is supposed to be the Gravitation class.

Definition at line 76 of file generic_gpu_bppt_integrator.hpp.

Constructor & Destructor Documentation

template<template< class T, class G > class Propagator, class Monitor , template< class T > class Gravitation>
swarm::gpu::bppt::generic< Propagator, Monitor, Gravitation >::generic ( const config cfg)
inline

The integrator is initialized from the configuration The generic integrator does not require any configuration parameters.

The configuration parameters are passed to Monitor::params and Propagator::params.

Definition at line 101 of file generic_gpu_bppt_integrator.hpp.

Member Function Documentation

template<template< class T, class G > class Propagator, class Monitor , template< class T > class Gravitation>
template<class T >
GPUAPI void swarm::gpu::bppt::generic< Propagator, Monitor, Gravitation >::kernel ( compile_time_param)
inline

Integrator the system using the provided Propagator and Monitor.

This is the meat of things. We put all the common functionality in here It basically initializes shared memory. Creates a gravitation object. Finds the system to integrate. Runs the main integration loop. Inside the loop, Propagator and Monitor are called alternatively

Setting up Monitor

Setting up Propagator

Definition at line 138 of file generic_gpu_bppt_integrator.hpp.

References swarm::gpu::integrator::_dens, swarm::integrator::_destination_time, swarm::gpu::integrator::_log, swarm::integrator::_max_iterations, peyton::constants::c, swarm::EnsembleBase< _CHUNK_SIZE, _NUM_BODY_ATTRIBUTES, _NUM_SYS_ATTRIBUTES >::nsys(), swarm::gpu::bppt::sysid(), swarm::log::system(), swarm::gpu::bppt::system_shared_data_pointer(), swarm::gpu::bppt::thread_body_idx(), swarm::gpu::bppt::thread_component_idx(), and swarm::gpu::bppt::thread_in_system().


The documentation for this class was generated from the following file: