Collective Variables Module - Developer Documentation
Loading...
Searching...
No Matches
colvar_gpu_calc.h
Go to the documentation of this file.
1#ifndef COLVAR_GPU_CALC_H
2#define COLVAR_GPU_CALC_H
3
4#if defined (COLVARS_CUDA) || defined (COLVARS_HIP)
5
6#include <vector>
7#include "colvar_gpu_support.h"
8
9class colvardeps;
10class colvar;
11class colvarmodule;
12
18namespace colvars_gpu {
30public:
47 cudaGraphNode_t child_graph_node;
50 };
55 public:
59 int init();
63 void dump_graph(const char* filename);
67 cudaGraph_t graph;
69 cudaGraphExec_t graph_exec;
71 std::vector<compute_node_t> nodes;
72 };
86 int init();
110 int calc_cvs(const std::vector<colvar*>& colvars, colvarmodule* colvar_module);
121 int apply_forces(const std::vector<colvar*>& colvars, colvarmodule* colvar_module);
122private:
135 std::vector<colvardeps*> forced_atom_groups;
136
137 #if defined (COLVARS_NVTX_PROFILING)
140 colvars_gpu::colvar_nvtx_prof ag_read_data_prof;
141 colvars_gpu::colvar_nvtx_prof cvc_calc_value_prof;
142 colvars_gpu::colvar_nvtx_prof cvc_calc_gradients_prof;
143 colvars_gpu::colvar_nvtx_prof ag_calc_fit_gradients_prof;
144 colvars_gpu::colvar_nvtx_prof cvc_calc_Jacobian_derivative_prof;
145 colvars_gpu::colvar_nvtx_prof cvc_calc_total_force_prof;
146 colvars_gpu::colvar_nvtx_prof cv_collect_cvc_data_prof;
147 colvars_gpu::colvar_nvtx_prof apply_forces_prof;
149 #endif
150
153 int cv_update_flags(const std::vector<colvar*>& colvars);
154 int cvc_calc_total_force(
155 const std::vector<colvar*>& colvars,
156 colvarmodule* colvar_module,
157 bool use_current_step = false);
158 int atom_group_read_data_gpu(
159 const std::vector<colvar*>& colvars,
161 colvarmodule* colvar_module);
162 int cvc_calc_value(
163 const std::vector<colvar*>& colvars,
164 colvarmodule* colvar_module);
165 int cvc_calc_gradients(
166 const std::vector<colvar*>& colvars,
167 colvarmodule* colvar_module);
168 int atom_group_calc_fit_gradients(
169 const std::vector<colvar*>& colvars,
171 colvarmodule* colvar_module);
172 int cvc_debug_gradients(
173 const std::vector<colvar*>& colvars,
174 colvarmodule* colvar_module);
175 int cvc_calc_Jacobian_derivative(
176 const std::vector<colvar*>& colvars,
177 colvarmodule* colvar_module);
178 int cv_collect_cvc_data(
179 const std::vector<colvar*>& colvars,
180 colvarmodule* colvar_module);
182};
183}
184
185#endif // defined (COLVARS_CUDA) || defined (COLVARS_HIP)
186#endif // COLVAR_GPU_CALC_H
A collective variable (main class); to be defined, it needs at least one object of a derived class of...
Definition: colvar.h:53
Parent class for a member object of a bias, cv or cvc etc. containing features and their dependencies...
Definition: colvardeps.h:34
Collective variables module (main class)
Definition: colvarmodule.h:71
Class for managing NVTX profiling ranges.
Definition: colvar_gpu_support.h:346
A struct for holding a CUDA graph and its execution object.
Definition: colvar_gpu_calc.h:54
bool graph_exec_initialized
Flag to describe whether the graph execution instance has been initialized.
Definition: colvar_gpu_calc.h:65
std::vector< compute_node_t > nodes
List of compute nodes.
Definition: colvar_gpu_calc.h:71
compute_gpu_graph_t()
Constructor.
Definition: colvar_gpu_calc.cpp:375
~compute_gpu_graph_t()
Destructor.
Definition: colvar_gpu_calc.cpp:395
void dump_graph(const char *filename)
Dump the CUDA graph to a dot file for debugging.
Definition: colvar_gpu_calc.cpp:408
cudaGraphExec_t graph_exec
CUDA graph execution instance object.
Definition: colvar_gpu_calc.h:69
int init()
(Re)initialize the CUDA graph
Definition: colvar_gpu_calc.cpp:379
cudaGraph_t graph
CUDA graph object.
Definition: colvar_gpu_calc.h:67
Class for managing the GPU calculation of CVCs.
Definition: colvar_gpu_calc.h:29
compute_gpu_graph_t calc_fit_gradients_compute
CUDA graph for calculating fit gradients.
Definition: colvar_gpu_calc.h:126
compute_gpu_graph_t read_data_compute
CUDA graph for reading data to GPU and calculating required properties.
Definition: colvar_gpu_calc.h:124
~colvarmodule_gpu_calc()
Destructor.
Definition: colvar_gpu_calc.h:80
int calc_cvs(const std::vector< colvar * > &colvars, colvarmodule *colvar_module)
Calculate the colvar {...} blocks.
Definition: colvar_gpu_calc.cpp:435
colvarmodule_gpu_calc()
Constructor.
Definition: colvar_gpu_calc.cpp:413
std::vector< colvardeps * > forced_atom_groups
A list of atom groups that require forces to be applied.
Definition: colvar_gpu_calc.h:135
int apply_forces(const std::vector< colvar * > &colvars, colvarmodule *colvar_module)
Apply the forces to the atom groups from the CVCs.
Definition: colvar_gpu_calc.cpp:473
int init()
Initialize all the GPU compute graphs.
Definition: colvar_gpu_calc.cpp:426
compute_gpu_graph_t apply_forces_compute
CUDA graph for applying forces to atom groups.
Definition: colvar_gpu_calc.h:128
A struct for holding a compute node in the CUDA graph and its corresponding atom group or CVC (child ...
Definition: colvar_gpu_calc.h:43
bool require_cpu_buffers
Whether the node requires CPU buffers.
Definition: colvar_gpu_calc.h:49
colvardeps * colvar_node
Pointer to the corresponding colvardeps object.
Definition: colvar_gpu_calc.h:45
cudaGraphNode_t child_graph_node
CUDA graph node.
Definition: colvar_gpu_calc.h:47