Crates.io | kronos-compute |
lib.rs | kronos-compute |
version | 0.1.6-rc3 |
created_at | 2025-08-24 23:42:39.750553+00 |
updated_at | 2025-08-29 23:42:53.285636+00 |
description | A high-performance compute-only Vulkan implementation with cutting-edge GPU optimizations |
homepage | https://github.com/LynnColeArt/kronos-compute |
repository | https://github.com/LynnColeArt/kronos-compute |
max_upload_size | |
id | 1808899 |
size | 829,815 |
π¦ Release Candidate 3 (v0.1.6-rc3): AMD ICD discovery fixed and diagnostics improved!
library_path
is now resolved robustly (as-provided and manifest-relative), and loader logs are more actionable. Hardware drivers are detected automatically withoutVK_ICD_FILENAMES
.
A high-performance, compute-only Vulkan implementation in Rust, featuring state-of-the-art GPU compute optimizations.
Kronos Compute is a streamlined Vulkan implementation that removes all graphics functionality to achieve maximum GPU compute performance. This Rust port not only provides memory-safe abstractions over the C API but also implements cutting-edge optimizations that deliver:
VK_ICD_FILENAMES
configuration neededlibrary_path
as provided (via dynamic linker search) and relative to the manifest directoryVkPhysicalDeviceFeatures
: 32 bytes (vs 220 in standard Vulkan)VkBufferCreateInfo
: Reordered fields for better packingVkMemoryTypeCache
: O(1) memory type lookupskronos/
βββ src/
β βββ lib.rs # Main library entry point
β βββ sys/ # Low-level FFI types
β βββ core/ # Core Kronos types
β βββ ffi/ # C-compatible function signatures
β βββ implementation/ # Kronos optimizations
βββ benches/ # Performance benchmarks
βββ examples/ # Usage examples
βββ tests/ # Integration and unit tests
βββ shaders/ # SPIR-V compute shaders
βββ scripts/ # Build and validation scripts
βββ docs/ # Documentation
βββ architecture/ # Design documents
β βββ OPTIMIZATION_SUMMARY.md
β βββ VULKAN_COMPARISON.md
β βββ ICD_SUCCESS.md
β βββ COMPATIBILITY.md
βββ benchmarks/ # Performance results
β βββ BENCHMARK_RESULTS.md
βββ qa/ # Quality assurance
β βββ QA_REPORT.md
β βββ MINI_REVIEW.md
β βββ TEST_RESULTS.md
βββ EPIC.md # Project epic and vision
βββ TODO.md # Development roadmap
cargo add kronos-compute
See Development Setup Guide for detailed installation instructions.
# Clone the repository
git clone https://github.com/LynnColeArt/kronos-compute
cd kronos-compute
# Build SPIR-V shaders (optional, pre-built shaders included)
./scripts/build_shaders.sh
# Build with optimizations enabled
cargo build --release --features implementation
# Run tests
cargo test --features implementation
# Run benchmarks
cargo bench --features implementation
# Run validation scripts
./scripts/validate_bench.sh # Run all validation tests
./scripts/amd_bench.sh # AMD-specific validation
Kronos includes comprehensive benchmarks for common compute workloads:
Each benchmark tests multiple configurations:
# Run specific benchmark
cargo bench --bench compute_workloads --features implementation
# Run with custom parameters
cargo bench --bench compute_workloads -- --warm-up-time 5 --measurement-time 10
use kronos_compute::api::{ComputeContext, PipelineConfig, BufferBinding};
// No unsafe code needed!
let ctx = ComputeContext::new()?;
// Load shader and create pipeline
let shader = ctx.load_shader("compute.spv")?;
let pipeline = ctx.create_pipeline(&shader)?;
// Create buffers
let input = ctx.create_buffer(&data)?;
let output = ctx.create_buffer_uninit(size)?;
// Dispatch compute work
ctx.dispatch(&pipeline)
.bind_buffer(0, &input)
.bind_buffer(1, &output)
.workgroups(1024, 1, 1)
.execute()?;
// Read results
let results: Vec<f32> = output.read()?;
All optimizations work transparently through the safe API!
use kronos_compute::*;
unsafe {
// Traditional Vulkan-style API also available
initialize_kronos()?;
let mut instance = VkInstance::NULL;
vkCreateInstance(&create_info, ptr::null(), &mut instance);
// ... etc
}
Based on Mini's optimization targets:
Metric | Baseline Vulkan | Kronos | Improvement |
---|---|---|---|
Descriptor updates/dispatch | 3-5 | 0 | 100% β¬οΈ |
Barriers/dispatch | 3 | β€0.5 | 83% β¬οΈ |
CPU submit time | 100% | 50-70% | 30-50% β¬οΈ |
Memory allocations | Continuous | 0* | 100% β¬οΈ |
Structure size (avg) | 100% | 86.1% | 13.9% β¬οΈ |
*After initial warm-up
Kronos can be configured via environment variables:
KRONOS_ICD_SEARCH_PATHS
: Custom Vulkan ICD search pathsVK_ICD_FILENAMES
: Standard Vulkan ICD overrideRUST_LOG
: Logging level (info, debug, trace)Enable detailed logs to debug ICD discovery and loading:
RUST_LOG=kronos_compute=info,kronos_compute::implementation::icd_loader=debug cargo run
Logs include:
Runtime configuration through the API:
// Set timeline batch size
kronos::implementation::timeline_batching::set_batch_size(32)?;
// Configure memory pools
kronos::implementation::pool_allocator::set_slab_size(512 * 1024 * 1024)?;
Traditional Vulkan requires updating descriptor sets for each dispatch. Kronos pre-allocates all storage buffer descriptors in Set0 and uses push constants for parameters:
// Traditional: 3-5 descriptor updates per dispatch
vkUpdateDescriptorSets(device, 5, writes, 0, nullptr);
vkCmdBindDescriptorSets(cmd, COMPUTE, layout, 0, 1, &set, 0, nullptr);
// Kronos: 0 descriptor updates
vkCmdPushConstants(cmd, layout, COMPUTE, 0, 128, ¶ms);
vkCmdDispatch(cmd, x, y, z);
Kronos tracks buffer usage patterns and inserts only the minimum required barriers:
// Traditional: 3 barriers per dispatch
vkCmdPipelineBarrier(cmd, TRANSFER, COMPUTE, ...); // uploadβcompute
vkCmdPipelineBarrier(cmd, COMPUTE, COMPUTE, ...); // computeβcompute
vkCmdPipelineBarrier(cmd, COMPUTE, TRANSFER, ...); // computeβdownload
// Kronos: β€0.5 barriers per dispatch (automatic)
Instead of submitting each command buffer individually:
// Traditional: N submits, N fences
for cmd in commands {
vkQueueSubmit(queue, 1, &submit, fence);
}
// Kronos: 1 submit, 1 timeline semaphore
kronos::BatchBuilder::new(queue)
.add_command_buffer(cmd1)
.add_command_buffer(cmd2)
.submit()?;
Comprehensive documentation is available in the docs/
directory:
API Documentation:
Architecture: Design decisions, optimization details, and comparisons
Quality Assurance: Test results and validation reports
Benchmarks: Performance measurements and analysis
Contributions are welcome! Areas of interest:
Please read our Contributing Guide for details.
This crate uses unsafe
for FFI compatibility but provides safe abstractions where possible:
// Unsafe C-style API (required for compatibility)
let result = unsafe {
vkCreateBuffer(device, &info, ptr::null(), &mut buffer)
};
// Safe Rust wrapper (future work)
let buffer = device.create_buffer(&info)?;
All unsafe functions include comprehensive safety documentation.
implementation
- Enable Kronos optimizations and ICD forwardingvalidation
- Enable additional safety checks (default)compare-ash
- Enable comparison benchmarks with ashSee TODO.md for the complete roadmap and contribution opportunities.
This project is dual-licensed under MIT OR Apache-2.0. See LICENSE-MIT and LICENSE-APACHE for details.
Built with β€οΈ and π¦ for maximum GPU compute performance.
If you use Kronos in your research, please cite:
@software{kronoscompute2025,
author = {Cole, Lynn},
title = {Kronos Compute: A High-Performance Compute-Only Vulkan Implementation},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
url = {https://github.com/LynnColeArt/kronos-compute}
}