1 #ifndef HALIDE_INTROSPECTION_H
2 #define HALIDE_INTROSPECTION_H
18 namespace Introspection {
39 #define HALIDE_DUMP_STACK_FRAME \
41 static bool check = Halide::Internal::Introspection::dump_stack_frame(); \
51 static T *introspection_helper =
nullptr;
52 return &introspection_helper;
63 bool (*test_a)(
const void *,
const std::string &),
74 #ifndef COMPILING_HALIDE
78 static bool check_introspection(
const void *var,
const std::string &type,
79 const std::string &correct_name,
80 const std::string &correct_file,
int line) {
81 std::string correct_loc = correct_file +
":" + std::to_string(line);
84 return name == correct_name && loc == correct_loc;
95 static void offset_marker() {
96 std::cerr <<
"You should not have called this function\n";
103 int private_member = 17;
109 a_float = private_member * 2.0f;
119 bool test(
const std::string &my_name);
122 static bool test_a(
const void *a_ptr,
const std::string &my_name) {
123 const A *a = (
const A *)a_ptr;
125 success &= Halide::Internal::check_introspection(&a->
an_int,
"int", my_name +
".an_int", __FILE__, __LINE__);
126 success &= Halide::Internal::check_introspection(&a->
a_b,
"HalideIntrospectionCanary::A::B", my_name +
".a_b", __FILE__, __LINE__);
127 success &= Halide::Internal::check_introspection(&a->
a_b.
parent,
"HalideIntrospectionCanary::A \\*", my_name +
".a_b.parent", __FILE__, __LINE__);
128 success &= Halide::Internal::check_introspection(&a->
a_b.
a_float,
"float", my_name +
".a_b.a_float", __FILE__, __LINE__);
129 success &= Halide::Internal::check_introspection(a->
a_b.
parent,
"HalideIntrospectionCanary::A", my_name, __FILE__, __LINE__);
133 static bool test(
bool (*f)(
const void *,
const std::string &)) {
137 return f(&a1,
"a1") && f(&a2,
"a2");
142 struct TestCompilationUnit {
143 TestCompilationUnit() {
149 static TestCompilationUnit test_object;
void test_compilation_unit(bool(*test)(bool(*)(const void *, const std::string &)), bool(*test_a)(const void *, const std::string &), void(*calib)())
void register_heap_object(const void *obj, size_t size, const void *helper)
Register an untyped heap object.
void deregister_heap_object(const void *obj, size_t size)
Deregister a heap object.
std::string get_variable_name(const void *, const std::string &expected_type)
Get the name of a stack variable from its address.
std::string get_source_location()
Get the source location in the call stack, skipping over calls in the Halide namespace.
bool dump_stack_frame()
Dump the contents of the stack frame of the calling function.
const void * get_introspection_helper()
Return the address of a global with type T *.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
bool test(const std::string &my_name)