File tree 2 files changed +18
-6
lines changed
compiler/rustc_codegen_llvm/src/back
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,13 @@ cargo +enzyme test --examples
35
35
```
36
36
37
37
## Enzyme Config
38
- Instead of having to re-build LLVM and Enzyme every time, we can adjust the
39
- Enzyme behavior on some higher level inside the following file or using the config parameter
40
- [ compiler/rustc_codegen_llvm/src/back/write.rs] ( https://github.com/EnzymeAD/rust/blob/c7fbb43f83a224cfa290dde2a46a930dce0c5507/compiler/rustc_codegen_llvm/src/back/write.rs#L712 )
38
+ To help with debugging, Enzyme can be configured using three environment variables.
39
+ ``` bash
40
+ export ENZYME_PRINT_TA
41
+ export ENZYME_PRINT_AA
42
+ export ENZYME_PRINT
43
+ ```
44
+ These will print TypeAnalysis, ActivityAnalysis and the primal + generated function respectively.
41
45
42
46
We want to make sure that we have EnzymeStrictAliasing=0 all the time to make sure
43
47
that Enzyme handles enums correctly. Other flags might be enabled for debug purpose.
Original file line number Diff line number Diff line change @@ -671,9 +671,17 @@ pub(crate) unsafe fn enzyme_ad(
671
671
let logic_ref: EnzymeLogicRef = CreateEnzymeLogic ( opt as u8 ) ;
672
672
let type_analysis: EnzymeTypeAnalysisRef =
673
673
CreateTypeAnalysis ( logic_ref, std:: ptr:: null_mut ( ) , std:: ptr:: null_mut ( ) , 0 ) ;
674
-
674
+
675
675
llvm:: EnzymeSetCLBool ( std:: ptr:: addr_of_mut!( llvm:: EnzymeStrictAliasing ) , 0 ) ;
676
- llvm:: EnzymeSetCLBool ( std:: ptr:: addr_of_mut!( llvm:: EnzymePrintType ) , 1 ) ;
676
+ if std:: env:: var ( "ENZYME_PRINT_TA" ) . is_ok ( ) {
677
+ llvm:: EnzymeSetCLBool ( std:: ptr:: addr_of_mut!( llvm:: EnzymePrintType ) , 1 ) ;
678
+ }
679
+ if std:: env:: var ( "ENZYME_PRINT_AA" ) . is_ok ( ) {
680
+ llvm:: EnzymeSetCLBool ( std:: ptr:: addr_of_mut!( llvm:: EnzymePrintActivity ) , 1 ) ;
681
+ }
682
+ if std:: env:: var ( "ENZYME_PRINT" ) . is_ok ( ) {
683
+ llvm:: EnzymeSetCLBool ( std:: ptr:: addr_of_mut!( llvm:: EnzymePrint ) , 1 ) ;
684
+ }
677
685
678
686
let mut res: & Value = match item. attrs . mode {
679
687
DiffMode :: Forward => enzyme_rust_forward_diff (
@@ -742,7 +750,7 @@ pub(crate) unsafe fn differentiate(
742
750
let res = enzyme_ad ( llmod, llcx, item) ;
743
751
assert ! ( res. is_ok( ) ) ;
744
752
}
745
-
753
+
746
754
let mut f = LLVMGetFirstFunction ( llmod) ;
747
755
loop {
748
756
if let Some ( lf) = f {
You can’t perform that action at this time.
0 commit comments