(git:27c966b)
Loading...
Searching...
No Matches
grid_library.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* CP2K: A general program to perform molecular dynamics simulations */
3/* Copyright 2000-2026 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
11extern "C" {
12#endif
13
14#include "grid_constants.h"
15#include "grid_sphere_cache.h"
16#include <stdbool.h>
17#include <stddef.h>
18
19/*******************************************************************************
20 * \brief Initializes the grid library.
21 * \author Ole Schuett
22 ******************************************************************************/
23void grid_library_init(void);
24
25/*******************************************************************************
26 * \brief Finalizes the grid library.
27 * \author Ole Schuett
28 ******************************************************************************/
29void grid_library_finalize(void);
30
31/*******************************************************************************
32 * \brief Configuration of the grid library.
33 * \author Ole Schuett
34 ******************************************************************************/
35typedef struct {
36 enum grid_backend
37 backend; // Selectes the backend to be used by the grid library.
38 bool validate; // When true the reference backend runs in shadow mode.
39 bool apply_cutoff; // only important for the dgemm and gpu backends
41
42/*******************************************************************************
43 * \brief Configures the grid library.
44 * \author Ole Schuett
45 ******************************************************************************/
46void grid_library_set_config(const enum grid_backend backend,
47 const bool validate, const bool apply_cutoff);
48
49/*******************************************************************************
50 * \brief Returns the library config.
51 * \author Ole Schuett
52 ******************************************************************************/
54
55/*******************************************************************************
56 * \brief Prints statistics gathered by the grid library.
57 * \author Ole Schuett
58 ******************************************************************************/
59void grid_library_print_stats(const int fortran_comm,
60 void (*print_func)(const char *, int, int),
61 int output_unit);
62
63/*******************************************************************************
64 * \brief Various kernels provided by the grid library.
65 * \author Ole Schuett
66 ******************************************************************************/
73
74/*******************************************************************************
75 * \brief Returns a pointer to the thread local sphere cache.
76 * \author Ole Schuett
77 ******************************************************************************/
79
80/*******************************************************************************
81 * \brief Returns a pointer to a thread local scratch buffer with at least the
82 * given size. The buffer grows on demand and is reused across calls.
83 * It stays valid until the next call on the same thread.
84 ******************************************************************************/
85void *grid_library_get_scratch(const size_t bytes);
86
87/*******************************************************************************
88 * \brief Adds given increment to counter specified by lp, backend, and kernel.
89 * \author Ole Schuett
90 ******************************************************************************/
91void grid_library_counter_add(const int lp, const enum grid_backend backend,
92 const enum grid_library_kernel kern,
93 const int increment);
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif // GRID_LIBRARY_H
100
101// EOF
static void print_func(const char *msg, int msglen, int output_unit)
Wrapper for printf, passed to dbm_library_print_stats.
Definition dbm_miniapp.c:26
grid_backend
void apply_cutoff(void *ptr)
void grid_library_finalize(void)
Finalizes the grid library.
void * grid_library_get_scratch(const size_t bytes)
Returns a pointer to a thread local scratch buffer with at least the given size. The buffer grows on ...
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.
void grid_library_print_stats(const int fortran_comm, void(*print_func)(const char *, int, int), int output_unit)
Prints statistics gathered by the grid library.
grid_sphere_cache * grid_library_get_sphere_cache(void)
Returns a pointer to the thread local sphere cache.
grid_library_kernel
Various kernels provided by the grid library.
@ GRID_INTEGRATE_GENERAL
@ GRID_COLLOCATE_ORTHO
@ GRID_COLLOCATE_GENERAL
@ GRID_INTEGRATE_ORTHO
void grid_library_init(void)
Initializes the grid library.
grid_library_config grid_library_get_config(void)
Returns the library config.
void grid_library_set_config(const enum grid_backend backend, const bool validate, const bool apply_cutoff)
Configures the grid library.
Configuration of the grid library.
enum grid_backend backend
Struct holding the entire sphere cache, ie. for all grids.