Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
cuTile Rust Macros
Defines the cutile::module and various other macros to expand cuTile Rust code into
unreachable code for type checking, JITable ASTs, and safe kernel launch functions.
Debugging
export RUSTFLAGS="-Zproc-macro-backtrace -Zmacro-backtrace -Awarnings"; export RUST_BACKTRACE=1;
export DUMP_KERNEL_LAUNCHER_DIR="temp"
Description and Limitations
This crate does the following:
- Generates concrete items for structs and functions which take const generic arrays (CGAs).
- Rewrites struct types and calls to functions which take CGAs.
The procedural macro has only syntax available to it. Functions which take CGAs require the length of the CGA to be known during macro expansion.
For example:
f takes a type parameterized by a variable length const generic array. During macro expansion,
const generic arrays of each length up to N=x, where x is a known literal during macro expansion,
are generated as follows:
// CGA instance generation.
Const generic arrays are then desugared and emitted as follows:
// CGA desugaring.
Defining and expanding variable length CGAs is only available in the core module. Programmers are otherwise free to use const generic arrays with known lengths in their own cuTile Rust modules.
For example:
> = }>;
let tile_x: }> = scalar_to_tile;
tile_x.reshape.broadcast
}
The cuTile Rust macro will desugar this into the following function:
The reshape method requires distinct implementations due to its use of multiple CGAs of different rank.
A current limitation of this solution is that the types of expressions which return types which are generic over const arrays must be known during macro expansion. In some cases, this is only possible if the type information for the expression is named before providing the expression to a function which supports variable length const generic arrays.
For example:
> = }>;
let tile_a: }> = reshape;
}
The above function needs to be desugared to Rust:
> = reshape__0__2;
}
We are able to infer the rank of the shape (2), but we are unable to infer the rank of the input tile (0).
The macro only has the syntax scalar_to_tile(a). For many built-in functions, we provide hints to the macro to
infer the types of these kinds of expressions, but inference of return types more generally
is not supported.
For the above kernel function, the compiler provides the source of the problem:
> Unable to infer type for argument 0 for call to reshape. Expected Tile. Required by calls to variadic functions and methods.
These error messages can be improved to provide explicit solutions to the problem. The solution in this case is to
bind the result of scalar_to_tile(a) to a variable with static type:
> = }>;
let tile_a: }> = scalar_to_tile;
let tile_a: }> = reshape;
}
Since variable length const generic arrays are only available to the core module, this is not a major limitation to programmers who write their own functions.
For example:
> = }>;
let tile_x: }> = scalar_to_tile;
tile_x.reshape.broadcast
}
Since user_function does not take a variable length CGA, the cuTile Rust macro does not need to rewrite it.
In other words, the expression user_function(a, y.shape()) compiles because there is only one user_function.