|
1 |
| -# The Rust Programming Language |
| 1 | +# The Rust Programming Language +Enzyme |
2 | 2 |
|
3 | 3 | [](https://www.rust-lang.org/community)
|
4 | 4 |
|
5 | 5 | This is the main source code repository for [Rust]. It contains the compiler,
|
6 |
| -standard library, and documentation. |
| 6 | +standard library, and documentation. It is modified to use Enzyme for AutoDiff. |
| 7 | + |
| 8 | +Please configure this fork using the following command: |
| 9 | + |
| 10 | +``` |
| 11 | +mkdir build |
| 12 | +cd build |
| 13 | +../configure --enable-llvm-link-shared --enable-llvm-plugins --enable-llvm-enzyme --release-channel=nightly --enable-llvm-assertions --enable-clang --enable-lld --enable-option-checking --enable-ninja --disable-docs |
| 14 | +``` |
| 15 | + |
| 16 | +Afterwards you can build rustc using: |
| 17 | +``` |
| 18 | +../x.py build --stage 1 library/std library/proc_macro library/test tools/rustdoc |
| 19 | +``` |
| 20 | + |
| 21 | +Afterwards rustc toolchain link will allow you to use it through cargo: |
| 22 | +``` |
| 23 | +rustup toolchain link enzyme `pwd`/build/`rustup target list --installed`/stage1 |
| 24 | +rustup toolchain install nightly # enables -Z unstable-options |
| 25 | +``` |
| 26 | + |
| 27 | +You can then look at examples in the `library/autodiff/examples/*` folder and run them with |
| 28 | + |
| 29 | +```bash |
| 30 | +# rosenbrock forward iteration |
| 31 | +cargo +enzyme run --example rosenbrock_fwd_iter --release |
| 32 | + |
| 33 | +# or all of them |
| 34 | +cargo +enzyme test --examples |
| 35 | +``` |
| 36 | + |
| 37 | +## Enzyme Config |
| 38 | +To help with debugging, Enzyme can be configured using environment variables. |
| 39 | +```bash |
| 40 | +export ENZYME_PRINT_TA=1 |
| 41 | +export ENZYME_PRINT_AA=1 |
| 42 | +export ENZYME_PRINT=1 |
| 43 | +export ENZYME_PRINT_MOD=1 |
| 44 | +export ENZYME_PRINT_MOD_AFTER=1 |
| 45 | +``` |
| 46 | +The first three will print TypeAnalysis, ActivityAnalysis and the llvm-ir on a function basis, respectively. |
| 47 | +The last two variables will print the whole module directly before and after Enzyme differented the functions. |
| 48 | + |
| 49 | +When experimenting with flags please make sure that EnzymeStrictAliasing=0 |
| 50 | +is not changed, since it is required for Enzyme to handle enums correctly. |
| 51 | + |
| 52 | +## Bug reporting |
| 53 | +Bugs are pretty much expected at this point of the development process. |
| 54 | +In order to help us please minimize the Rust code as far as possible. |
| 55 | +This tool might be a nicer helper: https://github.com/Nilstrieb/cargo-minimize |
| 56 | +If you have some knowledge of LLVM-IR we also greatly appreciate it if you could help |
| 57 | +us by compiling your minimized Rust code to LLVM-IR and reducing it further. |
| 58 | + |
| 59 | +The only exception to this strategy is error based on "Can not deduce type of X", |
| 60 | +where reducing your example will make it harder for us to understand the origin of the bug. |
| 61 | +In this case please just try to inline all dependencies into a single crate or even file, |
| 62 | +without deleting used code. |
| 63 | + |
| 64 | + |
| 65 | + |
7 | 66 |
|
8 | 67 | [Rust]: https://www.rust-lang.org/
|
9 | 68 |
|
|
0 commit comments