Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add env to print mod after enzyme #46

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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