-
Notifications
You must be signed in to change notification settings - Fork 149
Selective cachereads #21
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
14ccba3
Basic modref analysis, few more steps needed
timkaler 2984249
cache almost all loads
timkaler 96ab2b1
Messy, but working, selective caching of reads
timkaler b118be2
add missing files and fix minor bugs
timkaler 2d020bd
all enzyme-check tests work except the badcall tests
timkaler 79aab0c
modify the badcall tests so that they pass
timkaler 5d6669d
cleanup
timkaler 15a533f
cleanup
timkaler 98710fe
fix compiler warnings
timkaler f54dda2
make insertsort.ll expected fail again
timkaler 10f3eab
put in the more strict/correct logic for ordering instructions in sin…
timkaler 7528b5d
Check whether a loaded value is needed --- only at the top level for …
timkaler 2ac9d86
bugfix. still unsure if the logic used at topLevel for detecting when…
timkaler 95ef759
intermediate commit
timkaler a166347
separate global and local aa results for speed on large programs; add…
timkaler 9484ab9
cleanup
timkaler 532cf59
after rebase
timkaler 1352eb4
remove enzyme print from functional_c_tests
timkaler 94fddb9
remove mistaken commit
timkaler ac1857b
few changes
timkaler 9591d41
few minor changes/fixes
timkaler a6845db
rename AA/_AA arguments
timkaler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ OBJ := $(wildcard *.c) | |
|
|
||
| all: $(patsubst %.c,build/%-enzyme0,$(OBJ)) $(patsubst %.c,build/%-enzyme1,$(OBJ)) $(patsubst %.c,build/%-enzyme2,$(OBJ)) $(patsubst %.c,build/%-enzyme3,$(OBJ)) | ||
|
|
||
| POST_ENZYME_FLAGS := -mem2reg -sroa -adce -simplifycfg -enzyme_cachereads=true | ||
| POST_ENZYME_FLAGS := -mem2reg -sroa -adce -simplifycfg | ||
|
|
||
| #all: $(patsubst %.c,build/%-enzyme1,$(OBJ)) $(patsubst %.c,build/%-enzyme2,$(OBJ)) $(patsubst %.c,build/%-enzyme3,$(OBJ)) | ||
| #clean: | ||
|
|
@@ -31,7 +31,7 @@ POST_ENZYME_FLAGS := -mem2reg -sroa -adce -simplifycfg -enzyme_cachereads=true | |
|
|
||
| #EXTRA_FLAGS = -indvars -loop-simplify -loop-rotate | ||
|
|
||
| # NOTE(TFK): Optimization level 0 is broken right now. | ||
| # /efs/home/tfk/valgrind-3.12.0/vg-in-place | ||
| build/%-enzyme0: %.c | ||
| @./setup.sh $(CLANG_BIN_PATH)/clang -std=c11 -O1 $(patsubst %.c,%,$<).c -S -emit-llvm -o [email protected] | ||
| @./setup.sh $(CLANG_BIN_PATH)/opt [email protected] $(EXTRA_FLAGS) -load=$(ENZYME_PLUGIN) -enzyme $(POST_ENZYME_FLAGS) -o [email protected] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <math.h> | ||
| #include <assert.h> | ||
| #define __builtin_autodiff __enzyme_autodiff | ||
| double __enzyme_autodiff(void*, ...); | ||
|
|
||
| double f_read(double* x) { | ||
| double product = (*x) * (*x); | ||
| return product; | ||
| } | ||
|
|
||
| void g_write(double* x, double product) { | ||
| *x = (*x) * product; | ||
| } | ||
|
|
||
| double h_read(double* x) { | ||
| return *x; | ||
| } | ||
|
|
||
| double readwriteread_helper(double* x) { | ||
| double product = f_read(x); | ||
| g_write(x, product); | ||
| double ret = h_read(x); | ||
| return ret; | ||
| } | ||
|
|
||
| void readwriteread(double*__restrict x, double*__restrict ret) { | ||
| *ret = readwriteread_helper(x); | ||
| } | ||
|
|
||
| int main(int argc, char** argv) { | ||
| double ret = 0; | ||
| double dret = 1.0; | ||
| double* x = (double*) malloc(sizeof(double)); | ||
| double* dx = (double*) malloc(sizeof(double)); | ||
| *x = 2.0; | ||
| *dx = 0.0; | ||
|
|
||
| __builtin_autodiff(readwriteread, x, dx, &ret, &dret); | ||
|
|
||
|
|
||
| printf("dx is %f ret is %f\n", *dx, ret); | ||
| assert(*dx == 3*2.0*2.0); | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| #!/bin/bash | ||
|
|
||
| # NOTE(TFK): Uncomment for local testing. | ||
| export CLANG_BIN_PATH=./../../build-dbg/bin | ||
| export ENZYME_PLUGIN=./../mkdebug/Enzyme/LLVMEnzyme-7.so | ||
| export CLANG_BIN_PATH=./../../llvm/build/bin/ | ||
| export ENZYME_PLUGIN=./../build/Enzyme/LLVMEnzyme-7.so | ||
|
|
||
| mkdir -p build | ||
| $@ |
6 changes: 6 additions & 0 deletions
6
enzyme/functional_tests_c/testfiles/readwriteread-enzyme0.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ; RUN: cd %desired_wd | ||
| ; RUN: make clean-readwriteread-enzyme0 ENZYME_PLUGIN=%loadEnzyme | ||
| ; RUN: make build/readwriteread-enzyme0 ENZYME_PLUGIN=%loadEnzyme CLANG_BIN_PATH=%clangBinPath | ||
| ; RUN: build/readwriteread-enzyme0 | ||
| ; RUN: make clean-readwriteread-enzyme0 ENZYME_PLUGIN=%loadEnzyme | ||
|
|
6 changes: 6 additions & 0 deletions
6
enzyme/functional_tests_c/testfiles/readwriteread-enzyme1.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ; RUN: cd %desired_wd | ||
| ; RUN: make clean-readwriteread-enzyme1 ENZYME_PLUGIN=%loadEnzyme | ||
| ; RUN: make build/readwriteread-enzyme1 ENZYME_PLUGIN=%loadEnzyme CLANG_BIN_PATH=%clangBinPath | ||
| ; RUN: build/readwriteread-enzyme1 | ||
| ; RUN: make clean-readwriteread-enzyme1 ENZYME_PLUGIN=%loadEnzyme | ||
|
|
6 changes: 6 additions & 0 deletions
6
enzyme/functional_tests_c/testfiles/readwriteread-enzyme2.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ; RUN: cd %desired_wd | ||
| ; RUN: make clean-readwriteread-enzyme2 ENZYME_PLUGIN=%loadEnzyme | ||
| ; RUN: make build/readwriteread-enzyme2 ENZYME_PLUGIN=%loadEnzyme CLANG_BIN_PATH=%clangBinPath | ||
| ; RUN: build/readwriteread-enzyme2 | ||
| ; RUN: make clean-readwriteread-enzyme2 ENZYME_PLUGIN=%loadEnzyme | ||
|
|
6 changes: 6 additions & 0 deletions
6
enzyme/functional_tests_c/testfiles/readwriteread-enzyme3.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ; RUN: cd %desired_wd | ||
| ; RUN: make clean-readwriteread-enzyme3 ENZYME_PLUGIN=%loadEnzyme | ||
| ; RUN: make build/readwriteread-enzyme3 ENZYME_PLUGIN=%loadEnzyme CLANG_BIN_PATH=%clangBinPath | ||
| ; RUN: build/readwriteread-enzyme3 | ||
| ; RUN: make clean-readwriteread-enzyme3 ENZYME_PLUGIN=%loadEnzyme | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.