-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Disallow async nestings that violate read after write dependencies #7868
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9c6c062
Disallow async nestings that violate read after write dependencies
abadams 4ccbe8d
Add test
abadams 4f60796
Add another failure case, and improve error message
abadams 50d9470
Add some more tests
vksnk 3a2f087
Update test
abadams fc45139
Add new test to cmakelists
abadams 33fa8a6
Fix for llvm trunk
abadams 1342c4d
Merge remote-tracking branch 'origin/main' into abadams/fix_7867
abadams 14c7d73
Always acquire the folding semaphore, even if unused
abadams 22c0565
Merge branch 'abadams/fix_riscv_vx_vi' into abadams/fix_7867
abadams eb73a44
Merge remote-tracking branch 'origin/main' into abadams/fix_7867
abadams 5ade4c6
Merge remote-tracking branch 'origin/main' into abadams/fix_7867
abadams edcc260
Merge remote-tracking branch 'origin/main' into abadams/fix_7867
abadams 34d1832
Skip async_order test under wasm
abadams 6c278e1
Merge branch 'main' into abadams/fix_7867
steven-johnson fb72bad
Merge branch 'main' into abadams/fix_7867
steven-johnson 4181f3e
Merge branch 'main' into abadams/fix_7867
steven-johnson 153709b
trigger buildbots
steven-johnson 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 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 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 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 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,94 @@ | ||
#include "Halide.h" | ||
#include <stdio.h> | ||
|
||
using namespace Halide; | ||
|
||
int main(int argc, char **argv) { | ||
if (get_jit_target_from_environment().arch == Target::WebAssembly) { | ||
printf("[SKIP] WebAssembly does not support async() yet.\n"); | ||
return 0; | ||
} | ||
|
||
{ | ||
Func producer1, producer2, consumer; | ||
Var x, y; | ||
|
||
producer1(x, y) = x + y; | ||
producer2(x, y) = producer1(x, y); | ||
consumer(x, y) = producer1(x, y - 1) + producer2(x, y + 1); | ||
|
||
consumer.compute_root(); | ||
|
||
producer1.compute_at(consumer, y); | ||
producer2.compute_at(consumer, y).async(); | ||
|
||
consumer.bound(x, 0, 16).bound(y, 0, 16); | ||
|
||
Buffer<int> out = consumer.realize({16, 16}); | ||
|
||
out.for_each_element([&](int x, int y) { | ||
int correct = 2 * (x + y); | ||
if (out(x, y) != correct) { | ||
printf("out(%d, %d) = %d instead of %d\n", | ||
x, y, out(x, y), correct); | ||
exit(-1); | ||
} | ||
}); | ||
} | ||
{ | ||
Func producer1, producer2, consumer; | ||
Var x, y; | ||
|
||
producer1(x, y) = x + y; | ||
producer2(x, y) = producer1(x, y); | ||
consumer(x, y) = producer1(x, y - 1) + producer2(x, y + 1); | ||
|
||
consumer.compute_root(); | ||
|
||
producer1.compute_root(); | ||
producer2.store_root().compute_at(consumer, y).async(); | ||
|
||
consumer.bound(x, 0, 16).bound(y, 0, 16); | ||
|
||
Buffer<int> out = consumer.realize({16, 16}); | ||
|
||
out.for_each_element([&](int x, int y) { | ||
int correct = 2 * (x + y); | ||
if (out(x, y) != correct) { | ||
printf("out(%d, %d) = %d instead of %d\n", | ||
x, y, out(x, y), correct); | ||
exit(-1); | ||
} | ||
}); | ||
} | ||
|
||
{ | ||
Func producer1, producer2, consumer; | ||
Var x, y; | ||
|
||
producer1(x, y) = x + y; | ||
producer2(x, y) = producer1(x, y); | ||
consumer(x, y) = producer1(x, y - 1) + producer2(x, y + 1); | ||
|
||
consumer.compute_root(); | ||
|
||
producer1.store_root().compute_at(consumer, y).async(); | ||
producer2.store_root().compute_at(consumer, y).async(); | ||
|
||
consumer.bound(x, 0, 16).bound(y, 0, 16); | ||
|
||
Buffer<int> out = consumer.realize({16, 16}); | ||
|
||
out.for_each_element([&](int x, int y) { | ||
int correct = 2 * (x + y); | ||
if (out(x, y) != correct) { | ||
printf("out(%d, %d) = %d instead of %d\n", | ||
x, y, out(x, y), correct); | ||
exit(-1); | ||
} | ||
}); | ||
} | ||
|
||
printf("Success!\n"); | ||
return 0; | ||
} |
This file contains 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 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,31 @@ | ||
|
||
#include "Halide.h" | ||
|
||
using namespace Halide; | ||
|
||
int main(int argc, char **argv) { | ||
|
||
Func f{"f"}, g{"g"}, h{"h"}; | ||
Var x; | ||
|
||
f(x) = cast<uint8_t>(x + 7); | ||
g(x) = f(x); | ||
h(x) = g(x); | ||
|
||
// The schedule below is an error. It should really be: | ||
// f.store_root().compute_at(g, Var::outermost()); | ||
// So that it's nested inside the consumer h. | ||
f.store_root().compute_at(h, x); | ||
g.store_root().compute_at(h, x).async(); | ||
|
||
Buffer<uint8_t> buf = h.realize({32}); | ||
for (int i = 0; i < buf.dim(0).extent(); i++) { | ||
uint8_t correct = i + 7; | ||
if (buf(i) != correct) { | ||
printf("buf(%d) = %d instead of %d\n", i, buf(i), correct); | ||
return 1; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains 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,23 @@ | ||
#include "Halide.h" | ||
|
||
using namespace Halide; | ||
|
||
// From https://github.com/halide/Halide/issues/5201 | ||
int main(int argc, char **argv) { | ||
Func producer1, producer2, consumer; | ||
Var x, y; | ||
|
||
producer1(x, y) = x + y; | ||
producer2(x, y) = producer1(x, y); | ||
consumer(x, y) = producer2(x, y - 1) + producer2(x, y + 1); | ||
|
||
consumer.compute_root(); | ||
|
||
producer1.compute_at(consumer, y).async(); | ||
producer2.store_root().compute_at(consumer, y).async(); | ||
|
||
consumer.bound(x, 0, 16).bound(y, 0, 16); | ||
|
||
Buffer<int> out = consumer.realize({16, 16}); | ||
return 0; | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"to the producer" -> "in the producer"?