-
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.
No longer silently hide errors in Metal completion handlers (alternat…
…ive approach) (#8240) * No longer silently hide errors in Metal completion handlers * Actually implement alternative * clang-format * Implement new API * Implement test and refine the API * Format. * Remove some debug code * Add missing includes. * Add comment noting why we manually null-terminate after strncpy * Reverse engineer Objective-C API for passing void* in a block; it turns out to be much simpler than I thought * Formatting * Don't add const-ness to declaration. --------- Co-authored-by: Steven Johnson <srj@google.com>
- Loading branch information
1 parent
6c8a491
commit f9ccd5c
Showing
7 changed files
with
296 additions
and
24 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
45 changes: 45 additions & 0 deletions
45
test/correctness/gpu_metal_completion_handler_error_check.cpp
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,45 @@ | ||
#include "Halide.h" | ||
#include <stdio.h> | ||
|
||
using namespace Halide; | ||
|
||
bool errored = false; | ||
|
||
int main(int argc, char **argv) { | ||
Target t = get_jit_target_from_environment(); | ||
if (!t.has_feature(Target::Metal)) { | ||
printf("[SKIP] Metal not enabled\n"); | ||
return 0; | ||
} | ||
|
||
Func f, g; | ||
Var c, x, ci, xi; | ||
RVar rxi; | ||
RDom r(0, 1000, -327600, 327600); | ||
|
||
// Create a function that is very costly to execute, resulting in a timeout | ||
// on the GPU | ||
f(x, c) = x + 0.1f * c; | ||
f(r.x, c) += cos(sin(tan(cosh(tanh(sinh(exp(tanh(exp(log(tan(cos(exp(f(r.x, c) / cos(cosh(sinh(sin(f(r.x, c))))) / tanh(tan(tan(f(r.x, c)))))))))) + cast<float>(cast<uint8_t>(f(r.x, c) / cast<uint8_t>(log(f(r.x, c)))))))))))); | ||
|
||
f.gpu_tile(x, c, xi, ci, 4, 4); | ||
f.update(0).gpu_tile(r.x, c, rxi, ci, 4, 4); | ||
|
||
// Metal is surprisingly resilient. Run this in a loop just to make sure we trigger the error. | ||
for (int i = 0; (i < 10) && !errored; i++) { | ||
auto out = f.realize({1000, 100}, t); | ||
int result = out.device_sync(); | ||
if (result != halide_error_code_success) { | ||
printf("Device sync failed as expected: %d\n", result); | ||
errored = true; | ||
} | ||
} | ||
|
||
if (!errored) { | ||
printf("There was supposed to be an error\n"); | ||
return 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
Oops, something went wrong.