MVGAL Design Document

Version: 0.7.3 | Last Updated: August 2026


Design Goals

  1. Transparent multi-vendor GPU aggregation — applications see one logical GPU regardless of how many physical GPUs exist.
  2. Zero application changes — interception via Vulkan layer, OpenCL ICD, CUDA shim, and LD_PRELOAD.
  3. Vendor-agnostic scheduling — AMD, NVIDIA, Intel, and Moore Threads GPUs work together.
  4. Safety-first — kernel module with DRM registration, Rust safety crates for critical paths.
  5. Low overhead — target <2% frame time regression for single-GPU pass-through mode.

Architecture Decisions

Decision 1: Kernel Module as DRM Meta-Driver

Chosen approach: A Linux kernel module (mvgal.ko) that registers as a DRM client and exposes /dev/mvgal0 with 10 DRM ioctls.

Alternatives considered:

Tradeoffs:

Decision 2: C++20 Daemon with IPC over Unix Socket

Chosen approach: mvgald is a C++20 daemon communicating with clients via Unix socket (/run/mvgal/mvgal.sock) using a binary protocol with MVGL magic header and SCM_CREDENTIALS authentication.

Alternatives considered:

Tradeoffs:

Decision 3: LD_PRELOAD Interception for All APIs

Chosen approach: Transparent interception via Vulkan implicit layer, OpenCL ICD wrapper, CUDA function hooking (40+ functions), and LD_PRELOAD for OpenGL/D3D/Metal/WebGPU.

Alternatives considered:

Tradeoffs:

Decision 4: DMA-BUF Zero-Copy with Host-RAM Fallback

Chosen approach: Three-tier memory transfer: (1) DMA-BUF zero-copy between GPUs sharing the same IOMMU group, (2) PCIe P2P for GPUs on the same root complex, (3) host-RAM staging as universal fallback.

Alternatives considered:

Tradeoffs:

Decision 5: Rust for Safety-Critical Subsystems

Chosen approach: Three Rust crates (fence_manager, memory_safety, capability_model) with C FFI exports for use by the C++ daemon.

Alternatives considered:

Tradeoffs:

Decision 6: 9 Scheduling Strategies

Chosen approach: Nine built-in strategies: Single, Auto, Round-robin, AFR, SFR, Task, Compute offload, Hybrid, Custom. Auto-detect selects the best strategy based on workload type.

Alternatives considered:

Tradeoffs:


Data Flow

Application
    │
    ▼
Interception Layer (Vulkan/CL/CUDA/GL)
    │ serialize workload descriptor
    ▼
IPC Client ──── Unix Socket ────▶ IPC Server (mvgald)
                                       │
                                       ▼
                                  Scheduler
                                  ├─ Select GPU(s) based on strategy
                                  ├─ Check memory availability
                                  └─ Assign priority
                                       │
                                       ▼
                                  Memory Manager
                                  ├─ Allocate VRAM on target GPU(s)
                                  ├─ Import/export DMA-BUF
                                  └─ Fallback to host-RAM if needed
                                       │
                                       ▼
                                  Kernel Module (/dev/mvgal0)
                                  ├─ DRM ioctl submission
                                  ├─ Vendor-specific dispatch (VGDD)
                                  └─ Fence signaling
                                       │
                                       ▼
                                  GPU Hardware

Security Model


Performance Characteristics

Path Latency Notes
Single-GPU pass-through <2% overhead No cross-GPU transfer needed
DMA-BUF zero-copy ~5-10μs Kernel-level buffer mapping
PCIe P2P transfer ~50-200μs Depends on buffer size and PCIe gen
Host-RAM staging ~2-5ms CPU copy bottleneck
IPC round-trip ~2-5μs Unix socket with binary protocol
Scheduler decision ~1-10μs Priority queue with 16 levels

Limitations and Known Issues

  1. No direct upstream kernel integration — the module must be built and signed per-kernel.
  2. Anti-cheat compatibility — LD_PRELOAD interception may be flagged by kernel-level anti-cheat (EAC, BattlEye).
  3. Network GPU pooling — remote GPU support is implemented but not yet production-ready.
  4. AI scheduling — the ML-based scheduler requires training data and is not yet deployed.
  5. Collective communication — the AllReduce/AllGather/Broadcast library is a stub; no UCX/UCC integration.