| Crates.io | xdl-amp |
| lib.rs | xdl-amp |
| version | 0.1.1 |
| created_at | 2025-12-31 18:33:19.025511+00 |
| updated_at | 2025-12-31 22:09:04.696196+00 |
| description | Multi-backend GPU/ML acceleration for XDL |
| homepage | https://turingworks.github.io/xdl |
| repository | https://github.com/turingworks/xdl |
| max_upload_size | |
| id | 2015118 |
| size | 439,767 |
Multi-backend GPU and ML acceleration for XDL with comprehensive platform support.
XDL AMP provides a unified interface for GPU/ML operations with 11 acceleration backends:
┌─────────────────────────────────────┐
│ XDL Applications │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ GpuContext │
│ (Automatic backend selection) │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ GpuDevice Trait │
│ (Unified GPU operations API) │
└─────────────────────────────────────┘
│
┌────────────┼────────────┬────────────┐
▼ ▼ ▼ ▼
┌────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
│ Metal │ │ CUDA │ │ Vulkan │ │ OpenCL │
│ (macOS)│ │(Linux/W)│ │ (cross) │ │ (fallbk)│
└────────┘ └─────────┘ └─────────┘ └─────────┘
use xdl_amp::{GpuContext, ops::GpuOps};
use ndarray::Array1;
// Create GPU context (automatically selects best backend)
let ctx = GpuContext::new()?;
println!("Using GPU backend: {}", ctx.backend_name());
// Create GPU operations
let gpu_ops = GpuOps::new(ctx.device().clone());
// Perform GPU-accelerated operations
let a = Array1::from_vec(vec![1.0, 2.0, 3.0, 4.0]);
let b = Array1::from_vec(vec![5.0, 6.0, 7.0, 8.0]);
let c = gpu_ops.add_1d(&a, &b)?;
println!("Result: {:?}", c);
use xdl_amp::{GpuContext, GpuBackend};
// Prefer CUDA if available
#[cfg(feature = "cuda")]
let ctx = GpuContext::with_preference(Some(GpuBackend::Cuda))?;
// Use Metal on macOS
#[cfg(target_os = "macos")]
let ctx = GpuContext::with_preference(Some(GpuBackend::Metal))?;
cargo build --release
cargo build --release --features cuda
Requires CUDA toolkit installed.
cargo build --release --features opencl
Requires OpenCL runtime installed.
cargo build --release --features vulkan
Requires Vulkan SDK or glslang installed:
brew install glslang vulkan-headers vulkan-loader# DirectX 12 (default)
cargo build --release
# Or with CUDA
cargo build --release --features cuda
| Operation | Metal | CUDA* | Vulkan | OpenCL* | DirectX 12* |
|---|---|---|---|---|---|
| add_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| mul_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| sub_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| div_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| sin_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| cos_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| exp_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| log_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| sqrt_f32 | ✅ | ✅ | ✅ | ✅ | ✅ |
| pow_f32 | ⏳ | ✅ | ✅ | ✅ | ✅ |
| matmul | ✅ | ✅ | ⏳ | ✅ | ✅ |
| sum | ⏳ | ✅ | ⏳ | ✅ | ✅ |
| max | ⏳ | ✅ | ⏳ | ✅ | ✅ |
| min | ⏳ | ✅ | ⏳ | ✅ | ✅ |
Legend: ✅ Implemented, ⏳ Planned, ❌ Not supported
*CUDA requires --features cuda and CUDA toolkit installed
*OpenCL requires --features opencl and OpenCL runtime
*DirectX 12 delegates to DirectML on Windows (--features directml)
GPU acceleration provides significant speedup for large arrays:
Actual performance depends on:
Contributions welcome! Priority areas:
GPL-2.0 - Same as parent XDL project