Dynamic Load Balance 3.6.1+32-59d1
backend.h
Go to the documentation of this file.
1/*********************************************************************************/
2/* Copyright 2009-2026 Barcelona Supercomputing Center */
3/* */
4/* This file is part of the DLB library. */
5/* */
6/* DLB is free software: you can redistribute it and/or modify */
7/* it under the terms of the GNU Lesser General Public License as published by */
8/* the Free Software Foundation, either version 3 of the License, or */
9/* (at your option) any later version. */
10/* */
11/* DLB is distributed in the hope that it will be useful, */
12/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14/* GNU Lesser General Public License for more details. */
15/* */
16/* You should have received a copy of the GNU Lesser General Public License */
17/* along with DLB. If not, see <https://www.gnu.org/licenses/>. */
18/*********************************************************************************/
19
20#ifndef BACKEND_H
21#define BACKEND_H
22
23#include <stdbool.h>
24#include <stddef.h>
25#include <stdint.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
32
33/* Backends should use these error codes for returning */
37};
38
39
40typedef struct gpu_measurements {
41 int64_t useful_time;
45
46typedef struct hwc_measurements {
47 int64_t cycles;
48 int64_t instructions;
50
51/* Backend to Core communication interface */
52typedef struct {
53 uint32_t abi_version;
54 uint32_t struct_size;
55
56 struct {
57 void (*enter_runtime)(void);
58 void (*exit_runtime)(void);
59 void (*submit_measurements)(const gpu_measurements_t*);
60 } gpu;
61
62 struct {
63 void (*submit_measurements)(const hwc_measurements_t*);
64 } hwc;
65
67
68
69/* Core to Backend communication interface */
70typedef struct {
71 uint32_t abi_version;
72 uint32_t struct_size;
73
74 const char *name;
75
76 struct {
77 bool gpu:1;
78 bool gpu_amd:1;
79 bool gpu_nvidia:1;
80 bool hwc:1;
81 } capabilities;
82
83 int (*probe)(void);
84 int (*init)(const core_api_t*);
85 int (*start)(void);
86 int (*stop)(void);
87 int (*finalize)(void);
88
89 void (*flush)(void);
90
91 int (*get_gpu_affinity)(char *buffer, size_t buffer_size, bool full_uuid);
92
94
95
96/* Backends must define and export this function */
98
99
100#ifdef __cplusplus
101}
102#endif
103
104#endif /* BACKEND_H */
int get_gpu_affinity(char *buffer, size_t buffer_size, bool full_uuid)
Definition: DLB_kernel.c:844
@ DLB_BACKEND_ABI_VERSION
Definition: backend.h:31
backend_api_t * DLB_Get_Backend_API(void)
Definition: cupti.c:792
DLB_Backend_Error_codes
Definition: backend.h:34
@ DLB_BACKEND_ERROR
Definition: backend.h:36
@ DLB_BACKEND_SUCCESS
Definition: backend.h:35
Definition: backend.h:70
bool gpu_amd
Definition: backend.h:78
bool gpu
Definition: backend.h:77
bool hwc
Definition: backend.h:80
bool gpu_nvidia
Definition: backend.h:79
const char * name
Definition: backend.h:74
uint32_t struct_size
Definition: backend.h:72
uint32_t abi_version
Definition: backend.h:71
Definition: backend.h:52
uint32_t struct_size
Definition: backend.h:54
uint32_t abi_version
Definition: backend.h:53
Definition: backend.h:40
int64_t inactive_time
Definition: backend.h:43
int64_t useful_time
Definition: backend.h:41
int64_t communication_time
Definition: backend.h:42
Definition: backend.h:46
int64_t instructions
Definition: backend.h:48
int64_t cycles
Definition: backend.h:47
struct gpu_measurements gpu_measurements_t
Definition: talp_gpu.h:24
struct hwc_measurements hwc_measurements_t
Definition: talp_hwc.h:27