accelerInt  v0.1
Classes | Functions
van_der_pol_cu Namespace Reference

Classes

struct  mechanism_memory
 This struct is used to store memory for the CUDA RHS and Jacobian evaluation. Along with the solver_memory struct, this must be initialized and passed to the solvers the run. More...
 

Functions

__device__ void dydt (const double t, const double mu, const double *__restrict__ y, double *__restrict__ dy, const mechanism_memory *__restrict__ d_mem)
 An implementation of the RHS of the van der Pol equation. More...
 
void gpuAssert (cudaError_t code, const char *file, int line, bool abort=true)
 
size_t required_mechanism_size ()
 Calculates and returns the total memory size (in bytes) required by an individual thread for the mechanism_memory struct. More...
 
void initialize_gpu_memory (int padded, mechanism_memory **h_mem, mechanism_memory **d_mem)
 Initializes the host and device mechanism_memory structs. This is required in order to enable passing the struct to CUDA. More...
 
void free_gpu_memory (mechanism_memory **h_mem, mechanism_memory **d_mem)
 Frees the host and device mechanism_memory structs. More...
 
void set_same_initial_conditions (int NUM, double **y_host, double **var_host)
 Set same ICs for all problems. More...
 
void apply_mask (double *y_host)
 Not needed for van der Pol. More...
 
void apply_reverse_mask (double *y_host)
 Not needed for van der Pol. More...
 
__device__ void eval_jacob (const double t, const double mu, const double *__restrict__ y, double *__restrict__ jac, const mechanism_memory *__restrict__ d_mem)
 An implementation of the van der Pol jacobian. More...
 
__device__ void sparse_multiplier (const double *A, const double *Vm, double *w)
 Implements Jacobian \ vector multiplication in sparse (or unrolled) form. More...
 

Function Documentation

◆ apply_mask()

void van_der_pol_cu::apply_mask ( double *  y_host)

Not needed for van der Pol.

In pyJac, these are used to transform the input/output vectors to deal with moving the last species mass fraction

Definition at line 46 of file ics.cu.

◆ apply_reverse_mask()

void van_der_pol_cu::apply_reverse_mask ( double *  y_host)

Not needed for van der Pol.

In pyJac, these are used to transform the input/output vectors to deal with moving the last species mass fraction

Definition at line 53 of file ics.cu.

◆ dydt()

__device__ void van_der_pol_cu::dydt ( const double  t,
const double  mu,
const double *__restrict__  y,
double *__restrict__  dy,
const mechanism_memory *__restrict__  d_mem 
)

An implementation of the RHS of the van der Pol equation.

The y and dy vectors supplied here are the global state vectors. Hence the vector accesses must be done with the global thread ID. The gpu_macros.cuh file defines some useful macros to simplify indexing

See also
gpu_macros.cuh
Parameters
[in]tThe current system time
[in]muThe van der Pol parameter
[in]yThe state vector
[out]dyThe output RHS (dydt) vector
[in]d_memThe mechanism_memory struct. In future versions, this will be used to access the \(\mu\) parameter to have a consistent interface.

Definition at line 24 of file dydt.cu.

◆ eval_jacob()

__device__ void van_der_pol_cu::eval_jacob ( const double  t,
const double  mu,
const double *__restrict__  y,
double *__restrict__  jac,
const mechanism_memory *__restrict__  d_mem 
)

An implementation of the van der Pol jacobian.

Parameters
[in]tThe current system time
[in]muThe van der Pol parameter
[in]yThe state vector at time t
[out]jacThe jacobian to populate
[in]d_memThe mechanism_memory struct. In future versions, this will be used to access the \(\mu\) parameter to have a consistent interface.

The Jacobian is in Column-major (Fortran) order. As with dydt(), this function operates directly on global state vector and jacobian. Hence we use the INDEX macro defined in gpu_macros.cuh here.

See also
dydt()
Parameters
[in]tThe current system time
[in]muThe van der Pol parameter
[in]yThe state vector at time t
[out]jacThe jacobian to populate
[in]d_memThe mechanism_memory struct. In future versions, this will be used to access the \(\mu\) parameter to have a consistent interface.

jac[0, 0] = \(\frac{\partial \dot{y_1}}{\partial y_1}\)

jac[0, 1] = \(\frac{\partial \dot{y_2}}{\partial y_1}\)

jac[1, 0] = \(\frac{\partial \dot{y_1}}{\partial y_2}\)

jac[1, 1] = \(\frac{\partial \dot{y_2}}{\partial y_2}\)

Definition at line 31 of file jacob.cu.

◆ free_gpu_memory()

void van_der_pol_cu::free_gpu_memory ( mechanism_memory **  h_mem,
mechanism_memory **  d_mem 
)

Frees the host and device mechanism_memory structs.

Parameters
[in,out]h_memThe host version of the mechanism_memory struct.
[in,out]d_memThe device version of the mechanism_memory struct.

Definition at line 47 of file gpu_memory.cu.

◆ gpuAssert()

void van_der_pol_cu::gpuAssert ( cudaError_t  code,
const char *  file,
int  line,
bool  abort = true 
)
inline

Definition at line 27 of file gpu_macros.cuh.

◆ initialize_gpu_memory()

void van_der_pol_cu::initialize_gpu_memory ( int  padded,
mechanism_memory **  h_mem,
mechanism_memory **  d_mem 
)

Initializes the host and device mechanism_memory structs. This is required in order to enable passing the struct to CUDA.

Parameters
[in]paddedThe padded number of threads to be used by the CUDA solver
[in,out]h_memThe host version of the mechanism_memory struct to initialize.
[in,out]d_memThe device version of the mechanism_memory struct to copy the resulting host mechanism_memory struct to.

Definition at line 30 of file gpu_memory.cu.

◆ required_mechanism_size()

size_t van_der_pol_cu::required_mechanism_size ( )

Calculates and returns the total memory size (in bytes) required by an individual thread for the mechanism_memory struct.

Definition at line 15 of file gpu_memory.cu.

◆ set_same_initial_conditions()

void van_der_pol_cu::set_same_initial_conditions ( int  NUM,
double **  y_host,
double **  var_host 
)

Set same ICs for all problems.

Parameters
NUMThe number of initial value problems
y_hostThe state vectors to initialize
var_hostThe vector of \(mu\) parameters for the van der Pol equation
NUMThe number of initial value problems
y_hostThe state vectors to initialize
var_hostThe vector of \(\mu\) parameters for the van der Pol equation

Definition at line 25 of file ics.cu.

◆ sparse_multiplier()

__device__ void van_der_pol_cu::sparse_multiplier ( const double *  A,
const double *  Vm,
double *  w 
)

Implements Jacobian \ vector multiplication in sparse (or unrolled) form.

Parameters
[in]AThe (NSP x NSP) Jacobian matrix, see eval_jacob() for details on layout
[in]VmThe (NSP x 1) vector to multiply by
[out]wThe (NSP x 1) vector to store the result in, \(w := A * Vm\)

Definition at line 22 of file sparse_multiplier.cu.