rust_workspace

Documents the LuisaCompute Rust workspace covering IR, compiler transforms, CPU backend, and FFI integration.

1.0k|108|Updated Nov 20, 2020
One-click install
npx skills add https://github.com/LuisaGroup/LuisaCompute --skill rust-workspace
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust_workspace
Source: https://github.com/LuisaGroup/LuisaCompute/tree/main/.agents/skills/rust_workspace
Command: npx skills add https://github.com/LuisaGroup/LuisaCompute --skill rust-workspace

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Navigating the LuisaCompute Rust workspace is difficult because it spans seven interdependent crates, a custom C-compatible FFI layer, compiler transform pipelines, and a CPU JIT backend. This Skill gives an AI assistant the structural knowledge needed to answer questions and make changes in src/rust/ correctly.

Core Features & Use Cases

  • Crate Map & Dependency Graph: Explains the roles of luisa_compute_ir, luisa_compute_api_types, luisa_compute_backend_impl, and related crates, including how they link to C++ via staticlibs and cdylibs.
  • IR & Transform Reference: Documents the IR data structures (Node, Instruction, Module), the ~180 builtin Func ops, and transform passes such as SSA, autodiff, DCE, and reg2mem.
  • FFI & Build Integration: Covers cbindgen header generation, CArc/CBox C-compatible pointers, CMake/XMake cargo integration, and Embree setup for the CPU backend.
  • Use Case: Ask the assistant to add a new IR transform pass or expose a new FFI function, and it will follow the documented step-by-step workflows including pipeline registration and header regeneration.

Quick Start

Ask the assistant to explain how the LuisaCompute Rust IR transform pipeline works or to add a new transform pass to luisa_compute_ir.

Frequently Asked Questions about rust_workspace

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new IR transform pass in LuisaCompute?

Create a new module in luisa_compute_ir/src/transform implementing the Transform trait, export it from transform/mod.rs, and add a match arm in luisa_compute_ir_transform_pipeline_add_transform so C++ can select it by name.

How does LuisaCompute expose Rust functions to C++?

Functions are declared as #[no_mangle] extern "C" with #[repr(C)] argument and return types. The cbindgen build script then emits declarations into headers like ir.hpp and api_types.hpp under include/luisa/rust/.

How do I run cargo checks for the LuisaCompute Rust workspace?

Run cargo check inside src/rust for the default workspace. To include backends, run cargo check -p luisa_compute_backend_impl --features cpu,remote, noting that the cpu feature requires the Embree dependency to be available.

Does the LuisaCompute CPU backend require Embree?

Yes, the cpu feature of luisa_compute_backend_impl enables embree_sys for ray tracing. CMake forwards LUISA_COMPUTE_EMBREE_ZIP_PATH or EMBREE_ZIP_FILE environment variables so the Rust build script can download and build Embree.

Why is cbindgen header generation slow and how can I skip it?

cbindgen runs in build scripts to regenerate C++ headers on every build. Set LC_RS_DO_NOT_GENERATE_BINDINGS=1 to skip header generation and speed up cargo check, then unset it to force regeneration.

What is the difference between luisa_compute_ir_staticlib and luisa_compute_ir_v2?

luisa_compute_ir_staticlib re-exports the IR crate as a static library named luisa_compute_ir_static for C++ linking. luisa_compute_ir_v2 is a libloading-based wrapper around the separate IR v2 C API consumed by the backend implementation.