-
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
Check results of all runtime function calls #6389
Changes from all commits
b05bd61
cc1fca7
3153c9a
c315347
490ddfc
0f86c0f
8fc06c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,7 +162,12 @@ int main(int argc, char **argv) { | |
{ | ||
Buffer<int> copy(raw_buf); | ||
} | ||
halide_device_free(nullptr, &raw_buf); | ||
// Note that a nonzero result should be impossible here (in theory) | ||
int result = halide_device_free(nullptr, &raw_buf); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Failure should be impossible in this specific context again. The point of this test is to create a trace of debug events so that we can check for lifetime issues. I guess this is a secondary test of if the buffer becomes malformed or something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
if (result != 0) { | ||
printf("Error! halide_device_free() returned: %d\n", result); | ||
return -1; | ||
} | ||
} | ||
|
||
// Test coverage for Halide::Runtime::Buffer construction from halide_buffer_t, taking ownership | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,11 @@ int main(int argc, char **argv) { | |
printf("argmin expected value\n stack peak: %d\n", argmin_stack_peak); | ||
printf("\n"); | ||
|
||
halide_do_par_for(nullptr, launcher_task, 0, num_launcher_tasks, nullptr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. launcher_task unconditionally returns zero, so this call also unconditionally returns zero, and the check is just confusing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented. |
||
// Note that launcher_task() always returns zero, thus halide_do_par_for() | ||
// should always return zero, but since this is a test, let's verify that. | ||
int result = halide_do_par_for(nullptr, launcher_task, 0, num_launcher_tasks, nullptr); | ||
assert(result == 0); | ||
(void)result; | ||
|
||
halide_profiler_state *state = halide_profiler_get_state(); | ||
assert(state != nullptr); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,10 +39,15 @@ int main(int argc, char **argv) { | |
|
||
// Hijack halide's runtime to run a bunch of instances of this function | ||
// in parallel. | ||
halide_do_par_for(nullptr, launcher_task, 0, num_launcher_tasks, nullptr); | ||
// Note that launcher_task() always returns zero, thus halide_do_par_for() | ||
// should always return zero, but since this is a test, let's verify that. | ||
int result = halide_do_par_for(nullptr, launcher_task, 0, num_launcher_tasks, nullptr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same concern applies here. There's no way for this call to return a non-zero value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented. |
||
assert(result == 0); | ||
(void)result; | ||
|
||
for (int i = 0; i < num_launcher_tasks; ++i) | ||
for (int i = 0; i < num_launcher_tasks; ++i) { | ||
assert(got_context[i] == true); | ||
} | ||
|
||
printf("Success!\n"); | ||
return 0; | ||
|
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.
The only way this could possibly fail is if the allocation of a 64x64 image failed above, but we already wrote into that allocation in the buffer constructor so it would have crashed already. I think we may disagree, but I don't think it's good practice to check return codes when failure is impossible in this context. It's just confusing for anyone reading the code. So I wouldn't want to see this in user code.
That said, this is a test to ensure that halide_buffer_copy does the right thing, and returning a non-zero value in a situation where it should be impossible for it to return a non-zero value is a good test.
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.
Done