Skip to content

Commit

Permalink
Merge pull request #46 from EnzymeAD/more-env-config
Browse files Browse the repository at this point in the history
add env to print mod after enzyme
  • Loading branch information
ZuseZ4 authored Sep 19, 2023
2 parents 03f3cb0 + 03e5534 commit ad877f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ cargo +enzyme test --examples
```

## Enzyme Config
To help with debugging, Enzyme can be configured using four environment variables.
To help with debugging, Enzyme can be configured using environment variables.
```bash
export ENZYME_PRINT_TA=1
export ENZYME_PRINT_AA=1
export ENZYME_PRINT=1
export ENZYME_PRINT_MOD=1
export ENZYME_PRINT_MOD_AFTER=1
```
The first three will print TypeAnalysis, ActivityAnalysis and the llvm-ir on a function basis, respectively.
The last variable can be used to print the whole module directly before Enzyme starts
differentiating functions.
The last two variables will print the whole module directly before and after Enzyme differented the functions.

We want to make sure that we have EnzymeStrictAliasing=0 all the time to make sure
that Enzyme handles enums correctly. Other flags might be enabled for debug purpose.
When experimenting with flags please make sure that EnzymeStrictAliasing=0
is not changed, since it is required for Enzyme to handle enums correctly.



Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ pub(crate) unsafe fn differentiate(

if std::env::var("ENZYME_PRINT_MOD").is_ok() {
unsafe {LLVMDumpModule(llmod);}

}
for item in diff_items {
let res = enzyme_ad(llmod, llcx, item);
Expand All @@ -772,6 +771,9 @@ pub(crate) unsafe fn differentiate(
break;
}
}
if std::env::var("ENZYME_PRINT_MOD_AFTER").is_ok() {
unsafe {LLVMDumpModule(llmod);}
}

Ok(())
}
Expand Down

0 comments on commit ad877f0

Please sign in to comment.