(git:0d88fc2)
Loading...
Searching...
No Matches
offload_mempool.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 OFFLOAD_MEMPOOL_H
8#define OFFLOAD_MEMPOOL_H
9
10#include <stddef.h>
11#include <stdint.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/*******************************************************************************
18 * \brief Internal routine for allocating host memory from the pool.
19 * \author Ole Schuett
20 ******************************************************************************/
21void *offload_mempool_host_malloc(size_t size);
22
23/*******************************************************************************
24 * \brief Internal routine for allocating device memory from the pool.
25 * \author Ole Schuett
26 ******************************************************************************/
27void *offload_mempool_device_malloc(size_t size);
28
29/*******************************************************************************
30 * \brief Internal routine for releasing memory back to the pool.
31 * \author Ole Schuett
32 ******************************************************************************/
33void offload_mempool_host_free(const void *memory);
34
35/*******************************************************************************
36 * \brief Internal routine for releasing memory back to the pool.
37 * \author Ole Schuett
38 ******************************************************************************/
39void offload_mempool_device_free(const void *memory);
40
41/*******************************************************************************
42 * \brief Internal routine for freeing all memory in the pool.
43 * \author Ole Schuett
44 ******************************************************************************/
45void offload_mempool_clear(void);
46
47/*******************************************************************************
48 * \brief Internal struct for pool statistics.
49 * \author Hans Pabst
50 ******************************************************************************/
52 // Memory consumption (entire pool).
54 // Memory currently used.
56 // Memory peak consumption.
58 // Number of allocations.
61
62/*******************************************************************************
63 * \brief Internal routine to query statistics.
64 * \author Hans Pabst
65 ******************************************************************************/
67
68/*******************************************************************************
69 * \brief Print allocation statistics.
70 * \author Hans Pabst
71 ******************************************************************************/
72void offload_mempool_stats_print(int fortran_comm,
73 void (*print_func)(const char *, int, int),
74 int output_unit);
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif
81
82// 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:25
subroutine, public offload_mempool_stats_print(mpi_comm, output_unit)
Print allocation statistics.
void offload_mempool_host_free(const void *memory)
Internal routine for releasing memory back to the pool.
void offload_mempool_clear(void)
Internal routine for freeing all memory in the pool.
void offload_mempool_device_free(const void *memory)
Internal routine for releasing memory back to the pool.
void offload_mempool_stats_get(offload_mempool_stats_t *memstats)
Internal routine to query statistics.
void * offload_mempool_device_malloc(size_t size)
Internal routine for allocating device memory from the pool.
void * offload_mempool_host_malloc(size_t size)
Internal routine for allocating host memory from the pool.
Internal struct for pool statistics.