-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of assert statements whose conditions get vectorized (#7989
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 deletions.
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,46 @@ | ||
#include "Halide.h" | ||
|
||
using namespace Halide; | ||
|
||
int error_count = 0; | ||
void my_error(JITUserContext *ucon, const char *msg) { | ||
error_count++; | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
Func f("f"), g("g"); | ||
Var x("x"); | ||
Param<int> p; | ||
|
||
f(x) = x; | ||
f(x) += 1; | ||
g(x) = f(x) + f(2 * x + p); | ||
|
||
g.vectorize(x, 8); | ||
f.bound_storage(x, 32); | ||
// No way to check this at compile time. The size of f depends on both x and | ||
// p. An assert is injected, but the assert is inside g's vectorized loop. | ||
|
||
g.jit_handlers().custom_error = my_error; | ||
|
||
g.compile_jit(); | ||
|
||
// Will trigger the assert | ||
p.set(256); | ||
g.realize({128}); | ||
if (error_count != 1) { | ||
printf("There should have been an error\n"); | ||
return 1; | ||
} | ||
|
||
// Will not trigger the assert | ||
p.set(0); | ||
g.realize({8}); | ||
if (error_count != 1) { | ||
printf("There should not have been an error\n"); | ||
return 1; | ||
} | ||
|
||
printf("Success!\n"); | ||
return 0; | ||
} |