(git:34ef472)
offload_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 OFFLOAD_LIBRARY_H
8 #define OFFLOAD_LIBRARY_H
9 
10 #include <stddef.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 /*******************************************************************************
16  * \brief Initalize runtime.
17  * \author Rocco Meli
18  ******************************************************************************/
19 void offload_init(void);
20 
21 /*******************************************************************************
22  * \brief Returns the number of available devices.
23  * \author Ole Schuett
24  ******************************************************************************/
25 int offload_get_device_count(void);
26 
27 /*******************************************************************************
28  * \brief Selects the chosen device to be used.
29  * \author Ole Schuett
30  ******************************************************************************/
31 void offload_set_chosen_device(int device_id);
32 
33 /*******************************************************************************
34  * \brief Returns the chosen device.
35  * \author Ole Schuett
36  ******************************************************************************/
38 
39 /*******************************************************************************
40  * \brief Activates the device selected via offload_set_chosen_device()
41  * \author Ole Schuett
42  ******************************************************************************/
44 
45 /*******************************************************************************
46  * \brief Starts a timing range.
47  * \author Ole Schuett
48  ******************************************************************************/
49 void offload_timeset(const char *message);
50 
51 /*******************************************************************************
52  * \brief Ends a timing range.
53  * \author Ole Schuett
54  ******************************************************************************/
55 void offload_timestop(void);
56 
57 /*******************************************************************************
58  * \brief Gets free and total device memory.
59  * \author Ole Schuett
60  ******************************************************************************/
61 void offload_mem_info(size_t *free, size_t *total);
62 
63 /*******************************************************************************
64  * \brief Allocate pinned memory (or simple malloc when there is no gpu)
65  ******************************************************************************/
66 int offload_host_malloc(void **ptr__, const size_t size__);
67 
68 /*******************************************************************************
69  * \brief free pinned memory (or simple free when there is no gpu)
70  ******************************************************************************/
71 int offload_host_free(void *ptr__);
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif
78 
79 // EOF
int offload_get_device_count(void)
Returns the number of available devices.
void offload_mem_info(size_t *free, size_t *total)
Gets free and total device memory.
void offload_activate_chosen_device(void)
Activates the device selected via offload_set_chosen_device()
int offload_host_free(void *ptr__)
free pinned memory (or simple free when there is no gpu)
void offload_timestop(void)
Ends a timing range.
void offload_timeset(const char *message)
Starts a timing range.
int offload_get_chosen_device(void)
Returns the chosen device.
void offload_set_chosen_device(int device_id)
Selects the chosen device to be used.
void offload_init(void)
Initalize runtime.
int offload_host_malloc(void **ptr__, const size_t size__)
Allocate pinned memory (or simple malloc when there is no gpu)