This source file includes following definitions.
- halide_print
- main
#include "Halide.h"
#include <stdio.h>
#include "test/common/gpu_object_lifetime_tracker.h"
using namespace Halide;
Internal::GpuObjectLifetimeTracker tracker;
void halide_print(void *user_context, const char *str) {
printf("%s", str);
tracker.record_gpu_debug(str);
}
int main(int argc, char **argv) {
Internal::JITHandlers handlers;
handlers.custom_print = halide_print;
Internal::JITSharedRuntime::set_default_handlers(handlers);
Target target = get_jit_target_from_environment();
target.set_feature(Target::Debug);
{
Halide::Runtime::Buffer<float> buf(100, 100);
{
Halide::Runtime::Buffer<float> shallow_copy = buf;
Halide::Buffer<float> copy(std::move(shallow_copy));
Func f;
Var x, y;
f(x, y) = copy(x, y);
if (target.has_gpu_feature()) {
Var xi, yi;
f.gpu_tile(x, y, xi, yi, 8, 8);
} else if (target.features_any_of({Target::HVX_64, Target::HVX_128})) {
f.hexagon();
}
f.set_custom_print(halide_print);
f.realize(50, 50, target);
if (target.has_gpu_feature()) {
assert(copy.has_device_allocation());
}
}
Halide::Internal::JITSharedRuntime::release_all();
assert(!buf.has_device_allocation());
if (tracker.validate_gpu_object_lifetime(true ,
true ,
1 )) {
return -1;
}
}
printf("Success!\n");
return 0;
}