Skip to main content

Module context

Module context 

Source
Expand description

Ring context providing GPU intrinsics facade for kernel handlers.

The RingContext provides a unified interface for GPU operations that abstracts over different backends (CUDA, Metal, WebGPU, CPU).

§Domain Support (FR-2)

RingContext supports domain-aware operations including:

  • Domain metadata access via domain()
  • Metrics collection via record_latency() and record_throughput()
  • Alert emission via emit_alert()

§Example

use ringkernel_core::prelude::*;

fn process(ctx: &mut RingContext, msg: MyMessage) {
    let start = std::time::Instant::now();

    // Process message...

    // Record metrics
    ctx.record_latency("process_message", start.elapsed().as_micros() as u64);
    ctx.record_throughput("messages", 1);

    // Emit alert if needed
    if start.elapsed().as_millis() > 100 {
        ctx.emit_alert(KernelAlert::high_latency("Slow message processing", 100));
    }
}

Structs§

ContextMetricsBuffer
Buffer for collecting metrics within a kernel context.
KernelAlert
An alert emitted from a kernel.
MetricsEntry
A single metrics entry recorded by the kernel.
RingContext
GPU intrinsics facade for kernel handlers.

Enums§

AlertRouting
Routing destination for alerts.
AlertSeverity
Severity level for kernel alerts.
ContextBackend
Backend-specific context implementation.
KernelAlertType
Type of kernel alert.
MetricType
Type of metric entry.