joule_profiler_source_rapl/lib.rs
1//! Intel RAPL metric source for Joule Profiler.
2//!
3//! This module provides several implementations of [`MetricReader`] for
4//! collecting energy metrics from Intel RAPL (Running Average Power Limit) domains.
5//!
6//! # Backends
7//!
8//! This module supports **two backends** for reading energy metrics:
9//! - [`powercap`] - uses the Linux `powercap` interface for energy readings.
10//! - [`perf`] - uses `perf_event` counters (`perf_event_open`) for RAPL domains.
11
12use joule_profiler_core::unit::{MetricUnit, Unit, UnitPrefix};
13
14mod domain_type;
15mod error;
16
17#[cfg(feature = "backend-perf")]
18pub mod perf;
19
20#[cfg(feature = "backend-powercap")]
21pub mod powercap;
22
23mod snapshot;
24mod util;
25
26pub use error::RaplError;
27
28/// Custom result type for Rapl
29type Result<T> = std::result::Result<T, RaplError>;
30
31const MICRO_JOULE_UNIT: MetricUnit = MetricUnit {
32 prefix: UnitPrefix::Micro,
33 unit: Unit::Joule,
34};
35
36const RAPL_SOURCE_ID: &str = "rapl";