(git:ccc2433)
grid_library.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_LIBRARY_H
8 #define GRID_LIBRARY_H
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #include "grid_constants.h"
15 #include "grid_sphere_cache.h"
16 #include <stdbool.h>
17 
18 /*******************************************************************************
19  * \brief Initializes the grid library.
20  * \author Ole Schuett
21  ******************************************************************************/
22 void grid_library_init(void);
23 
24 /*******************************************************************************
25  * \brief Finalizes the grid library.
26  * \author Ole Schuett
27  ******************************************************************************/
28 void grid_library_finalize(void);
29 
30 /*******************************************************************************
31  * \brief Configuration of the grid library.
32  * \author Ole Schuett
33  ******************************************************************************/
34 typedef struct {
35  enum grid_backend
36  backend; // Selectes the backend to be used by the grid library.
37  bool validate; // When true the reference backend runs in shadow mode.
38  bool apply_cutoff; // only important for the dgemm and gpu backends
40 
41 /*******************************************************************************
42  * \brief Configures the grid library.
43  * \author Ole Schuett
44  ******************************************************************************/
45 void grid_library_set_config(const enum grid_backend backend,
46  const bool validate, const bool apply_cutoff);
47 
48 /*******************************************************************************
49  * \brief Returns the library config.
50  * \author Ole Schuett
51  ******************************************************************************/
53 
54 /*******************************************************************************
55  * \brief Prints statistics gathered by the grid library.
56  * \author Ole Schuett
57  ******************************************************************************/
58 void grid_library_print_stats(void (*mpi_sum_func)(long *, int), int mpi_comm,
59  void (*print_func)(char *, int), int output_unit);
60 
61 /*******************************************************************************
62  * \brief Various kernels provided by the grid library.
63  * \author Ole Schuett
64  ******************************************************************************/
70 };
71 
72 /*******************************************************************************
73  * \brief Returns a pointer to the thread local sphere cache.
74  * \author Ole Schuett
75  ******************************************************************************/
77 
78 /*******************************************************************************
79  * \brief Adds given increment to counter specified by lp, backend, and kernel.
80  * \author Ole Schuett
81  ******************************************************************************/
82 void grid_library_counter_add(const int lp, const enum grid_backend backend,
83  const enum grid_library_kernel kern,
84  const int increment);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif // GRID_LIBRARY_H
91 
92 // EOF
grid_backend
void apply_cutoff(void *ptr)
void grid_library_finalize(void)
Finalizes the grid library.
Definition: grid_library.c:83
void grid_library_counter_add(const int lp, const enum grid_backend backend, const enum grid_library_kernel kern, const int increment)
Adds given increment to counter specified by lp, backend, and kernel.
Definition: grid_library.c:129
grid_library_kernel
Various kernels provided by the grid library.
Definition: grid_library.h:65
@ GRID_INTEGRATE_GENERAL
Definition: grid_library.h:69
@ GRID_COLLOCATE_ORTHO
Definition: grid_library.h:66
@ GRID_COLLOCATE_GENERAL
Definition: grid_library.h:68
@ GRID_INTEGRATE_ORTHO
Definition: grid_library.h:67
grid_sphere_cache * grid_library_get_sphere_cache(void)
Returns a pointer to the thread local sphere cache.
Definition: grid_library.c:102
void grid_library_print_stats(void(*mpi_sum_func)(long *, int), int mpi_comm, void(*print_func)(char *, int), int output_unit)
Prints statistics gathered by the grid library.
Definition: grid_library.c:155
void grid_library_init(void)
Initializes the grid library.
Definition: grid_library.c:49
grid_library_config grid_library_get_config(void)
Returns the library config.
Definition: grid_library.c:123
void grid_library_set_config(const enum grid_backend backend, const bool validate, const bool apply_cutoff)
Configures the grid library.
Definition: grid_library.c:112
void mpi_sum_func(long *number, int mpi_comm)
Definition: grid_miniapp.c:16
void print_func(char *message, int output_unit)
Definition: grid_miniapp.c:21
Configuration of the grid library.
Definition: grid_library.h:34
Struct holding the entire sphere cache, ie. for all grids.