Expand description
Persistent Message Traits for Type-Based Kernel Dispatch
This module provides traits and types for user-defined message dispatch within persistent GPU kernels. It enables multiple analytics types (fraud detection, aggregations, pattern detection) to run within a single persistent kernel with type-based routing to specialized handlers.
§Architecture
Host GPU (Persistent Kernel)
┌──────────────┐ ┌─────────────────────────────────────┐
│ send_message │──────▶│ H2K Queue │
│ <FraudCheck> │ │ ↓ │
│ │ │ Type Dispatcher (switch on type_id) │
│ │ │ ├─▶ handle_fraud_check() │
│ │ │ ├─▶ handle_aggregate() │
│ │ │ └─▶ handle_pattern_detect() │
│ │ │ ↓ │
│ poll_typed │◀──────│ K2H Queue │
│ <FraudResult>│ └─────────────────────────────────────┘
└──────────────┘§Example
ⓘ
use ringkernel_core::persistent_message::{PersistentMessage, DispatchTable};
use ringkernel_derive::{RingMessage, PersistentMessage};
#[derive(RingMessage, PersistentMessage)]
#[message(type_id = 1001)]
#[persistent_message(handler_id = 1, requires_response = true)]
pub struct FraudCheckRequest {
pub transaction_id: u64,
pub amount: f32,
pub account_id: u32,
}
// Runtime usage
sim.send_message(FraudCheckRequest { ... })?; // ~0.03µs
let results: Vec<FraudCheckResult> = sim.poll_typed();Modules§
- message_
flags - Flags for extended H2K messages.
Structs§
- Dispatch
Table - Dispatch table mapping handler IDs to functions.
- Handler
Registration - Handler registration entry for the dispatch table.
Constants§
- MAX_
INLINE_ PAYLOAD_ SIZE - Maximum size for inline payload in extended messages. Messages larger than this must use external buffer references.
Traits§
- Persistent
Message - Trait for messages that can be dispatched within a persistent GPU kernel.