accelerInt
v0.1
|
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... | |
void van_der_pol_cu::apply_mask | ( | double * | y_host | ) |
void van_der_pol_cu::apply_reverse_mask | ( | double * | y_host | ) |
__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
[in] | t | The current system time |
[in] | mu | The van der Pol parameter |
[in] | y | The state vector |
[out] | dy | The output RHS (dydt) vector |
[in] | d_mem | The mechanism_memory struct. In future versions, this will be used to access the \(\mu\) parameter to have a consistent interface. |
__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.
[in] | t | The current system time |
[in] | mu | The van der Pol parameter |
[in] | y | The state vector at time t |
[out] | jac | The jacobian to populate |
[in] | d_mem | The 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.
[in] | t | The current system time |
[in] | mu | The van der Pol parameter |
[in] | y | The state vector at time t |
[out] | jac | The jacobian to populate |
[in] | d_mem | The 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}\)
void van_der_pol_cu::free_gpu_memory | ( | mechanism_memory ** | h_mem, |
mechanism_memory ** | d_mem | ||
) |
Frees the host and device mechanism_memory structs.
[in,out] | h_mem | The host version of the mechanism_memory struct. |
[in,out] | d_mem | The device version of the mechanism_memory struct. |
Definition at line 47 of file gpu_memory.cu.
|
inline |
Definition at line 27 of file gpu_macros.cuh.
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.
[in] | padded | The padded number of threads to be used by the CUDA solver |
[in,out] | h_mem | The host version of the mechanism_memory struct to initialize. |
[in,out] | d_mem | The 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.
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.
void van_der_pol_cu::set_same_initial_conditions | ( | int | NUM, |
double ** | y_host, | ||
double ** | var_host | ||
) |
Set same ICs for all problems.
NUM | The number of initial value problems |
y_host | The state vectors to initialize |
var_host | The vector of \(mu\) parameters for the van der Pol equation |
NUM | The number of initial value problems |
y_host | The state vectors to initialize |
var_host | The vector of \(\mu\) parameters for the van der Pol equation |
__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.
[in] | A | The (NSP x NSP) Jacobian matrix, see eval_jacob() for details on layout |
[in] | Vm | The (NSP x 1) vector to multiply by |
[out] | w | The (NSP x 1) vector to store the result in, \(w := A * Vm\) |
Definition at line 22 of file sparse_multiplier.cu.