-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
66 lines (53 loc) · 2.14 KB
/
Copy pathmain.cpp
File metadata and controls
66 lines (53 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* @author Marcel Breyer
* @copyright 2024-today All Rights Reserved
* @license This file is released under the MIT license.
* See the LICENSE.md file in the project root for full license information.
*/
#include "hws/version.hpp" // hws::version::version
#include "pybind11/pybind11.h" // PYBIND11_MODULE, py::module_
#include <string_view> // std::string_view
#define HWS_IS_DEFINED_HELPER(x) #x
#define HWS_IS_DEFINED(x) (std::string_view{ #x } != std::string_view{ HWS_IS_DEFINED_HELPER(x) })
namespace py = pybind11;
// forward declare binding functions
void init_event(py::module_ &);
void init_sample_category(py::module_ &);
void init_relative_event(py::module_ &);
void init_hardware_sampler(py::module_ &);
void init_system_hardware_sampler(py::module_ &);
void init_cpu_hardware_sampler(py::module_ &);
void init_gpu_nvidia_hardware_sampler(py::module_ &);
void init_gpu_amd_hardware_sampler(py::module_ &);
void init_gpu_intel_hardware_sampler(py::module_ &);
void init_version(py::module_ &);
PYBIND11_MODULE(HardwareSampling, m) {
m.doc() = "Hardware Sampling for CPUs and GPUs";
m.attr("__version__") = hws::version::version;
init_event(m);
init_sample_category(m);
init_relative_event(m);
init_hardware_sampler(m);
init_system_hardware_sampler(m);
// CPU sampling
#if defined(HWS_FOR_CPUS_ENABLED)
init_cpu_hardware_sampler(m);
#endif
m.def("has_cpu_hardware_sampler", []() { return HWS_IS_DEFINED(HWS_FOR_CPUS_ENABLED); });
// NVIDIA GPU sampling
#if defined(HWS_FOR_NVIDIA_GPUS_ENABLED)
init_gpu_nvidia_hardware_sampler(m);
#endif
m.def("has_gpu_nvidia_hardware_sampler", []() { return HWS_IS_DEFINED(HWS_FOR_NVIDIA_GPUS_ENABLED); });
// AMD GPU sampling
#if defined(HWS_FOR_AMD_GPUS_ENABLED)
init_gpu_amd_hardware_sampler(m);
#endif
m.def("has_gpu_amd_hardware_sampler", []() { return HWS_IS_DEFINED(HWS_FOR_AMD_GPUS_ENABLED); });
// Intel GPU sampling
#if defined(HWS_FOR_INTEL_GPUS_ENABLED)
init_gpu_intel_hardware_sampler(m);
#endif
m.def("has_gpu_intel_hardware_sampler", []() { return HWS_IS_DEFINED(HWS_FOR_INTEL_GPUS_ENABLED); });
init_version(m);
}