Crate krnl

source ·
Expand description

Safe, portable, high performance compute (GPGPU) kernels.

Developed for autograph.

  • Similar functionality to CUDA and OpenCL.
  • Supports GPU’s and other Vulkan 1.2 capable devices.
  • MacOS / iOS supported via MoltenVK.
  • Kernels are written inline, entirely in Rust.
    • Simple iterator patterns can be implemented without unsafe.
    • Supports inline SPIR-V assembly.
    • DebugPrintf integration, generates backtraces for panics.
  • Buffers on the host can be accessed natively as Vecs and slices.

§krnlc

Kernel compiler for krnl.

  • Built on spirv-builder.
  • Supports dependencies defined in Cargo.toml.
  • Uses spirv-tools to validate and optimize.
  • Compiles to “krnl-cache.rs”, so the crate will build on stable Rust.

See kernel for installation and usage instructions.

§Installing

For device functionality (kernels), install Vulkan for your platform.

  • For development, it’s recomended to install the LunarG Vulkan SDK, which includes additional tools:
    • vulkaninfo
    • Validation layers
      • DebugPrintf
    • spirv-tools
      • This is used by krnlc for spirv validation and optimization.
        • krnlc builds by default without needing spirv-tools to be installed.

§Test

  • Check that vulkaninfo --summary shows your devices.
    • Instance version should be >= 1.2.
  • Alternatively, check that cargo test --test integration_tests -- --exact none shows your devices.
    • You can run all the tests with cargo test.

Re-exports§

Modules§