API Reference
Runtime
-
class Context
-
class Device
-
template<typename T>
class Buffer : public luisa::compute::Resource
-
template<typename T>
class Image : public luisa::compute::Resource
-
class Accel : public luisa::compute::Resource
DSL
-
template<typename T>
struct Var : public luisa::compute::detail::Ref<T> Represents a variable in the embedded DSL.
Var<T> is the core type for representing data on the device within the DSL. It inherits from Ref<T>, providing reference semantics.
Logic: When a Var<T> is constructed, it records a local variable declaration into the current FunctionBuilder’s AST. Subsequent operations on the Var are recorded as expressions targeting this local variable.
- Template Parameters:
T – The C++ type being represented in the DSL.
Public Functions
-
inline explicit Var(const Expression *expr) noexcept
Construct Var from an existing AST expression.
- Parameters:
expr – Pointer to the AST expression.
-
inline Var() noexcept
Construct a new local variable.
Logic: This allocates a new local variable slot in the current AST FunctionBuilder and applies default initialization.
-
template<typename ...Args, size_t... i>
inline Var(std::tuple<Args...> args, std::index_sequence<i...>) noexcept Construct and initialize from a tuple of arguments.
-
template<typename ...Args>
inline Var(std::tuple<Args...> args) noexcept Construct and initialize from a tuple.
-
template<typename Arg>
inline Var(Arg &&arg) noexcept Construct and initialize from a single argument.
Logic: If T is a structure and Arg is not, it tries to initialize the first member. If Arg is another DSL expression, it records an assignment.
- Template Parameters:
Arg – Type of the initializer.
-
template<typename T>
struct Expr : public luisa::compute::detail::ExprEnableStaticCast<Expr<T>>, public luisa::compute::detail::ExprEnableBitwiseCast<Expr<T>> Class of Expr<T>.
Member function’s tparam must be 0.
- Template Parameters:
T – needs to be scalar
Subclassed by luisa::compute::Var< Buffer< T > >< ScanTileStateT >
-
template<typename T>
class Callable Callable class. Callable<T> is not allowed, unless T is a function type.
-
template<size_t N, typename ...Args>
class Kernel Represents a parallelized computation task on the device.
A Kernel is an entry point for device-side execution. When a Kernel is constructed from a C++ lambda, the lambda is executed once on the host to trace the DSL operations and build an AST.
Logic:
Construction: Executes the provided lambda to record the AST.
Compilation: The AST is sent to the backend to generate a Shader.
Dispatch: The compiled Shader is launched on the device grid.
- Template Parameters:
N – Dimension of the kernel grid (1, 2, or 3).
Args – Argument types of the kernel.
Public Functions
-
template<typename Def>
inline Kernel(Def &&def) noexcept Create a Kernel from a C++ lambda or function object.
Logic: Pushes a new FunctionBuilder, defines the kernel grid dimension, creates DSL variables for arguments, and invokes the lambda to record the computation logic into the AST.
- Template Parameters:
Def – Lambda type.
- Parameters:
def – The kernel definition lambda.
-
inline const auto &function() const noexcept
- Returns:
The underlying recorded AST function.
-
template<typename...>
struct Kernel1D
-
template<typename...>
struct Kernel2D
-
template<typename...>
struct Kernel3D