(git:374b731)
Loading...
Searching...
No Matches
grid_gpu_task_list.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* CP2K: A general program to perform molecular dynamics simulations */
3/* Copyright 2000-2024 CP2K developers group <https://cp2k.org> */
4/* */
5/* SPDX-License-Identifier: BSD-3-Clause */
6/*----------------------------------------------------------------------------*/
7#ifndef GRID_GPU_TASK_LIST_H
8#define GRID_GPU_TASK_LIST_H
9
10#include "../../offload/offload_runtime.h"
11#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_GRID)
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#include "../../offload/offload_buffer.h"
18#include "../common/grid_basis_set.h"
19#include "../common/grid_constants.h"
20#include <stdbool.h>
21
22/*******************************************************************************
23 * \brief Internal representation of a task.
24 * \author Ole Schuett
25 ******************************************************************************/
26typedef struct grid_gpu_task_struct {
27 bool use_orthorhombic_kernel;
28 bool block_transposed;
29 double radius;
30 double radius2;
31 double ra[3];
32 double rb[3];
33 double rp[3];
34 double rab[3];
35 double gp[3];
36 double rab2;
37 double zeta;
38 double zetb;
39 double zetp;
40 double prefactor;
41 double off_diag_twice;
42 double dh_max;
43
44 // angular momentum range of basis set
45 int la_max_basis;
46 int lb_max_basis;
47 int la_min_basis;
48 int lb_min_basis;
49
50 // size of entire spherical basis
51 int nsgfa;
52 int nsgfb;
53
54 // size of spherical set
55 int nsgf_seta;
56 int nsgf_setb;
57
58 // strides of the sphi transformation matrices
59 int maxcoa;
60 int maxcob;
61
62 // offset of the pab and hab block relative to buffer pointer.
63 int ab_block_offset;
64
65 // atoms to which the forces and virial should be added
66 int iatom;
67 int jatom;
68
69 // pointers basis set matrices
70 const double *sphia;
71 const double *sphib;
72
73 // Stuff for the ortho kernel.
74 double disr_radius;
75 int cube_center_shifted[3];
76 double cube_offset[3];
77
78 // Stuff for the general kernel.
79 int index_min[3];
80 int index_max[3];
81 int bounds_i[2];
82 int bounds_j[2];
83 int bounds_k[2];
84} grid_gpu_task;
85
86/*******************************************************************************
87 * \brief Internal representation of a grid layout.
88 * \author Ole Schuett
89 ******************************************************************************/
90typedef struct {
91 int npts_global[3];
92 int npts_local[3];
93 int shift_local[3];
94 int border_width[3];
95 double dh[3][3];
96 double dh_inv[3][3];
97} grid_gpu_layout;
98
99/*******************************************************************************
100 * \brief Internal representation of a task list.
101 * \author Ole Schuett
102 ******************************************************************************/
103typedef struct {
104 bool orthorhombic;
105 int ntasks;
106 int nlevels;
107 int natoms;
108 int nkinds;
109 int nblocks;
110 grid_gpu_layout *layouts;
111 int *tasks_per_level;
112 offloadStream_t *level_streams;
113 offloadStream_t main_stream;
114 int lmax;
115 int stats[2][20]; // [has_border_mask][lp]
116 // device pointers
117 double **sphis_dev;
118 grid_gpu_task *tasks_dev;
119} grid_gpu_task_list;
120
121/*******************************************************************************
122 * \brief Allocates a task list for the GPU backend.
123 * See grid_task_list.h for details.
124 * \author Ole Schuett
125 ******************************************************************************/
126void grid_gpu_create_task_list(
127 const bool orthorhombic, const int ntasks, const int nlevels,
128 const int natoms, const int nkinds, const int nblocks,
129 const int block_offsets[], const double atom_positions[][3],
130 const int atom_kinds[], const grid_basis_set *basis_sets[],
131 const int level_list[], const int iatom_list[], const int jatom_list[],
132 const int iset_list[], const int jset_list[], const int ipgf_list[],
133 const int jpgf_list[], const int border_mask_list[],
134 const int block_num_list[], const double radius_list[],
135 const double rab_list[][3], const int npts_global[][3],
136 const int npts_local[][3], const int shift_local[][3],
137 const int border_width[][3], const double dh[][3][3],
138 const double dh_inv[][3][3], grid_gpu_task_list **task_list);
139
140/*******************************************************************************
141 * \brief Deallocates given task list, basis_sets have to be freed separately.
142 * \author Ole Schuett
143 ******************************************************************************/
144void grid_gpu_free_task_list(grid_gpu_task_list *task_list);
145
146/*******************************************************************************
147 * \brief Collocate all tasks of in given list onto given grids.
148 * See grid_task_list.h for details.
149 * \author Ole Schuett
150 ******************************************************************************/
151void grid_gpu_collocate_task_list(const grid_gpu_task_list *task_list,
152 const enum grid_func func, const int nlevels,
153 const offload_buffer *pab_blocks,
154 offload_buffer *grids[]);
155
156/*******************************************************************************
157 * \brief Integrate all tasks of in given list onto given grids.
158 * See grid_task_list.h for details.
159 * \author Ole Schuett
160 ******************************************************************************/
161void grid_gpu_integrate_task_list(const grid_gpu_task_list *task_list,
162 const bool compute_tau, const int natoms,
163 const int nlevels,
164 const offload_buffer *pab_blocks,
165 const offload_buffer *grids[],
166 offload_buffer *hab_blocks,
167 double forces[][3], double virial[3][3]);
168
169#ifdef __cplusplus
170}
171#endif
172
173#endif // defined(__OFFLOAD) && !defined(__NO_OFFLOAD_GRID)
174#endif
175
176// EOF
grid_func
static void const int const int const int const int const int const double const int const int const int npts_local[3]
integer, parameter lmax
Internal representation of a basis set.
Internal representation of a buffer.