Skip to content

Commit

Permalink
Merge branch 'main' of github.com:LuisaGroup/luisa-compute-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
shiinamiyuki committed Sep 19, 2023
2 parents c3d317e + a33c88b commit a8a8ca0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ To see the use of `luisa-compute-rs` in a high performance offline rendering sys
- [Custom Operators](#custom-operators)
- [Callable](#callable)
- [Kernel](#kernel)
- [Debugging](#debugging)
- [Advanced Usage](#advanced-usage)
- [Safety](#safety)
- [API](#api)
Expand Down Expand Up @@ -60,7 +61,7 @@ fn main() {
let z = device.create_buffer::<f32>(1024);
x.view(..).fill_fn(|i| i as f32);
y.view(..).fill_fn(|i| 1000.0 * i as f32);
let kernel = device.create_kernel::<(Buffer<f32>,)>(&|buf_z| {
let kernel = device.create_kernel::<fn(Buffer<f32>)>(&|buf_z| {
// z is pass by arg
let buf_x = x.var(); // x and y are captured
let buf_y = y.var();
Expand Down Expand Up @@ -437,6 +438,12 @@ let pair = BufferPair{a,b};
kernel.dispatch([...], &packed);
let BufferPair{a, b} = packed; // unpack if you need to use them later
```
### Debugging
We provide logging through the `log` crate. Users can either setup their own logger or use the `init_logger()` and `init_logger_verbose()` for handy initialization.
For `debug` builds, oob checks are automatically inserted so that an assertion failure would occur if oob access is detected. On CPU backend, it will be accompanied by an informative message such as `assertion failed: i.cmplt(self.len()) at xx.rs:yy:zz`. Setting the environment variable `LUISA_BACKTRACE=1` would display a stacktrace containing the *DSL* code that records the kernel. For other backends, assertion with message is still *WIP*.

For `release` builds however, these checks are disabled by default for performance reasons. To enable them, set environment variable `LUISA_DEBUG=1` prior to launching the application.

## Advanced Usage
Note that the IR module has a public interface. If needed, user can implement their own DSL syntax sugar. Every EDSL object implements either `Aggregate` or `FromNode` trait, which allows any EDSL type to be destructured into its underlying IR nodes and reconstructed from them.

Expand Down

0 comments on commit a8a8ca0

Please sign in to comment.