Skip to content
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

Remove Introspection #8273

Merged
merged 6 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ WITH_D3D12 ?= not-empty
WITH_VULKAN ?= not-empty
WITH_SPIRV ?= not-empty
WITH_WEBGPU ?= not-empty
WITH_INTROSPECTION ?= not-empty
WITH_EXCEPTIONS ?=
WITH_LLVM_INSIDE_SHARED_LIBHALIDE ?= not-empty

Expand Down Expand Up @@ -173,7 +172,6 @@ AARCH64_LLVM_CONFIG_LIB=$(if $(WITH_AARCH64), aarch64, )
RISCV_CXX_FLAGS=$(if $(WITH_RISCV), -DWITH_RISCV, )
RISCV_LLVM_CONFIG_LIB=$(if $(WITH_RISCV), riscv, )

INTROSPECTION_CXX_FLAGS=$(if $(WITH_INTROSPECTION), -DWITH_INTROSPECTION, )
EXCEPTIONS_CXX_FLAGS=$(if $(WITH_EXCEPTIONS), -DHALIDE_WITH_EXCEPTIONS -fexceptions, )

HEXAGON_CXX_FLAGS=$(if $(WITH_HEXAGON), -DWITH_HEXAGON, )
Expand Down Expand Up @@ -218,7 +216,6 @@ CXX_FLAGS += $(METAL_CXX_FLAGS)
CXX_FLAGS += $(D3D12_CXX_FLAGS)
CXX_FLAGS += $(WEBGPU_CXX_FLAGS)
CXX_FLAGS += $(POWERPC_CXX_FLAGS)
CXX_FLAGS += $(INTROSPECTION_CXX_FLAGS)
CXX_FLAGS += $(EXCEPTIONS_CXX_FLAGS)
CXX_FLAGS += $(AMDGPU_CXX_FLAGS)
CXX_FLAGS += $(RISCV_CXX_FLAGS)
Expand Down Expand Up @@ -512,7 +509,6 @@ SOURCE_FILES = \
InlineReductions.cpp \
IntegerDivisionTable.cpp \
Interval.cpp \
Introspection.cpp \
IR.cpp \
IREquality.cpp \
IRMatch.cpp \
Expand Down Expand Up @@ -712,7 +708,6 @@ HEADER_FILES = \
InlineReductions.h \
IntegerDivisionTable.h \
Interval.h \
Introspection.h \
IntrusivePtr.h \
IR.h \
IREquality.h \
Expand Down
4 changes: 1 addition & 3 deletions python_bindings/src/halide/halide_/PyScheduleMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ HALIDE_NEVER_INLINE void add_schedule_methods(PythonClass &class_instance) {
// Templated function; specializing only on ImageParam for now
return t.template prefetch<ImageParam>(image, at, from, offset, strategy);
},
py::arg("image"), py::arg("at"), py::arg("from"), py::arg("offset") = 1, py::arg("strategy") = PrefetchBoundStrategy::GuardWithIf)

.def("source_location", &T::source_location);
py::arg("image"), py::arg("at"), py::arg("from"), py::arg("offset") = 1, py::arg("strategy") = PrefetchBoundStrategy::GuardWithIf);
}

} // namespace PythonBindings
Expand Down
2 changes: 1 addition & 1 deletion src/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class Buffer {
: contents(new Internal::BufferContents) {
contents->buf = std::move(buf);
if (name.empty()) {
contents->name = Internal::make_entity_name(this, "Halide:.*:Buffer<.*>", 'b');
contents->name = Internal::unique_name('b');
} else {
contents->name = name;
}
Expand Down
7 changes: 0 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ set(HEADER_FILES
InlineReductions.h
IntegerDivisionTable.h
Interval.h
Introspection.h
IntrusivePtr.h
IR.h
IREquality.h
Expand Down Expand Up @@ -262,7 +261,6 @@ set(SOURCE_FILES
InlineReductions.cpp
IntegerDivisionTable.cpp
Interval.cpp
Introspection.cpp
IR.cpp
IREquality.cpp
IRMatch.cpp
Expand Down Expand Up @@ -563,11 +561,6 @@ target_compile_definitions(Halide PUBLIC
target_include_directories(Halide INTERFACE "$<BUILD_INTERFACE:${Halide_BINARY_DIR}/include>")
add_dependencies(Halide HalideIncludes)

option(Halide_WITH_INTROSPECTION "Enable use of debugging symbols for default Func, Var, etc. names" ON)
if (Halide_WITH_INTROSPECTION)
target_compile_definitions(Halide PRIVATE WITH_INTROSPECTION)
endif ()

if (TARGET Halide_wabt)
target_link_libraries(Halide PRIVATE Halide_wabt)
target_compile_definitions(Halide PRIVATE WITH_WABT)
Expand Down
12 changes: 1 addition & 11 deletions src/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "IR.h"
#include "IRMutator.h"
#include "IROperator.h"
#include "Introspection.h"
#include "Var.h"

namespace Halide {
Expand All @@ -22,7 +21,6 @@ struct DefinitionContents {
std::vector<Expr> values, args;
StageSchedule stage_schedule;
std::vector<Specialization> specializations;
std::string source_location;

DefinitionContents()
: predicate(const_true()) {
Expand Down Expand Up @@ -99,7 +97,6 @@ Definition::Definition(const std::vector<Expr> &args, const std::vector<Expr> &v
contents->is_init = is_init;
contents->values = values;
contents->args = args;
contents->source_location = Introspection::get_source_location();
if (rdom.defined()) {
contents->predicate = rdom.predicate();
for (const auto &rv : rdom.domain()) {
Expand All @@ -109,15 +106,14 @@ Definition::Definition(const std::vector<Expr> &args, const std::vector<Expr> &v
}

Definition::Definition(bool is_init, const Expr &predicate, const std::vector<Expr> &args, const std::vector<Expr> &values,
const StageSchedule &schedule, const std::vector<Specialization> &specializations, const std::string &source_location)
const StageSchedule &schedule, const std::vector<Specialization> &specializations)
: contents(new DefinitionContents) {
contents->is_init = is_init;
contents->values = values;
contents->args = args;
contents->predicate = predicate;
contents->stage_schedule = schedule;
contents->specializations = specializations;
contents->source_location = source_location;
}

Definition Definition::get_copy() const {
Expand All @@ -129,7 +125,6 @@ Definition Definition::get_copy() const {
copy.contents->values = contents->values;
copy.contents->args = contents->args;
copy.contents->stage_schedule = contents->stage_schedule.get_copy();
copy.contents->source_location = contents->source_location;

// Deep-copy specializations
for (const Specialization &s : contents->specializations) {
Expand Down Expand Up @@ -204,10 +199,6 @@ const std::vector<Specialization> &Definition::specializations() const {
return contents->specializations;
}

std::string Definition::source_location() const {
return contents->source_location;
}

const Specialization &Definition::add_specialization(Expr condition) {
Specialization s;
s.condition = std::move(condition);
Expand All @@ -216,7 +207,6 @@ const Specialization &Definition::add_specialization(Expr condition) {
s.definition.contents->predicate = contents->predicate;
s.definition.contents->values = contents->values;
s.definition.contents->args = contents->args;
s.definition.contents->source_location = contents->source_location;

// The sub-schedule inherits everything about its parent except for its specializations.
s.definition.contents->stage_schedule = contents->stage_schedule.get_copy();
Expand Down
8 changes: 1 addition & 7 deletions src/Definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Definition {

/** Construct a Definition with deserialized data. */
Definition(bool is_init, const Expr &predicate, const std::vector<Expr> &args, const std::vector<Expr> &values,
const StageSchedule &schedule, const std::vector<Specialization> &specializations, const std::string &source_location);
const StageSchedule &schedule, const std::vector<Specialization> &specializations);

/** Construct an undefined Definition object. */
Definition();
Expand Down Expand Up @@ -123,12 +123,6 @@ class Definition {
std::vector<Specialization> &specializations();
const Specialization &add_specialization(Expr condition);
// @}

/** Attempt to get the source file and line where this definition
* was made using DWARF introspection. Returns an empty string if
* no debug symbols were found or the debug symbols were not
* understood. Works on OS X and Linux only. */
std::string source_location() const;
};

struct Specialization {
Expand Down
3 changes: 2 additions & 1 deletion src/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,9 @@ Definition Deserializer::deserialize_definition(const Serialize::Definition *def
const std::vector<Specialization> specializations =
deserialize_vector<Serialize::Specialization, Specialization>(definition->specializations(),
&Deserializer::deserialize_specialization);
// Deserialize and ignore this value.
const auto source_location = deserialize_string(definition->source_location());
return Definition(is_init, predicate, args, values, stage_schedule, specializations, source_location);
return Definition(is_init, predicate, args, values, stage_schedule, specializations);
}

ReductionVariable Deserializer::deserialize_reduction_variable(const Serialize::ReductionVariable *reduction_variable) {
Expand Down
8 changes: 0 additions & 8 deletions src/Error.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "Error.h"
#include "Introspection.h"
#include "Util.h" // for get_env_variable

#include <csignal>
Expand Down Expand Up @@ -155,7 +154,6 @@ ErrorReport::ErrorReport(const char *file, int line, const char *condition_strin
#endif
const char sep = use_newlines ? '\n' : ' ';

const std::string &source_loc = Introspection::get_source_location();
const char *what = (flags & Warning) ? "Warning" : "Error";
if (flags & User) {
// Only mention where inside of libHalide the error tripped if we have debug level > 0
Expand All @@ -164,15 +162,9 @@ ErrorReport::ErrorReport(const char *file, int line, const char *condition_strin
debug(1) << "Condition failed: " << condition_string << "\n";
}
msg << what << ":";
if (!source_loc.empty()) {
msg << " (at " << source_loc << ")";
}
msg << sep;
} else {
msg << "Internal " << what << " at " << file << ":" << line;
if (source_loc.empty()) {
msg << " triggered by user code at " << source_loc << ":";
}
msg << sep;
if (condition_string) {
msg << "Condition failed: " << condition_string << ":" << sep;
Expand Down
17 changes: 2 additions & 15 deletions src/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ Func::Func(const std::vector<Type> &required_types, int required_dims, const str
}

Func::Func()
: func(make_entity_name(this, "Halide:.*:Func", 'f')) {
: func(unique_name('f')) {
}

Func::Func(const Expr &e)
: func(make_entity_name(this, "Halide:.*:Func", 'f')) {
: func(unique_name('f')) {
(*this)(_) = e;
}

Expand Down Expand Up @@ -2146,14 +2146,6 @@ Stage &Stage::compute_with(const Stage &s, const VarOrRVar &var, LoopAlignStrate
return compute_with(LoopLevel(s.function, var, s.stage_index), align);
}

/** Attempt to get the source file and line where this stage was
* defined by parsing the process's own debug symbols. Returns an
* empty string if no debug symbols were found or the debug
* symbols were not understood. Works on OS X and Linux only. */
std::string Stage::source_location() const {
return definition.source_location();
}

void Stage::unscheduled() {
user_assert(!definition.schedule().touched()) << "Stage::unscheduled called on an update definition with a schedule\n";
definition.schedule().touched() = true;
Expand Down Expand Up @@ -3492,11 +3484,6 @@ vector<Argument> Func::infer_arguments() const {
return Pipeline(*this).infer_arguments();
}

std::string Func::source_location() const {
user_assert(defined()) << "A Func with no definition has no source_location\n";
return func.definition().source_location();
}

Module Func::compile_to_module(const vector<Argument> &args, const std::string &fn_name, const Target &target) {
return pipeline().compile_to_module(args, fn_name, target);
}
Expand Down
10 changes: 0 additions & 10 deletions src/Func.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,6 @@ class Stage {
}
// @}

/** Attempt to get the source file and line where this stage was
* defined by parsing the process's own debug symbols. Returns an
* empty string if no debug symbols were found or the debug
* symbols were not understood. Works on OS X and Linux only. */
std::string source_location() const;

/** Assert that this stage has intentionally been given no schedule, and
* suppress the warning about unscheduled update definitions that would
* otherwise fire. This counts as a schedule, so calling this twice on the
Expand Down Expand Up @@ -2600,10 +2594,6 @@ class Func {
*/
std::vector<Argument> infer_arguments() const;

/** Get the source location of the pure definition of this
* Func. See Stage::source_location() */
std::string source_location() const;

/** Return the current StageSchedule associated with this initial
* Stage of this Func. For introspection only: to modify schedule,
* use the Func interface. */
Expand Down
12 changes: 5 additions & 7 deletions src/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,7 @@ void execute_generator(const ExecuteGeneratorArgs &args_in) {

GeneratorParamBase::GeneratorParamBase(const std::string &name)
: name_(name) {
ObjectInstanceRegistry::register_instance(this, 0, ObjectInstanceRegistry::GeneratorParam,
this, nullptr);
ObjectInstanceRegistry::register_instance(this, 0, ObjectInstanceRegistry::GeneratorParam, this);
}

GeneratorParamBase::~GeneratorParamBase() {
Expand Down Expand Up @@ -1238,9 +1237,9 @@ std::vector<std::string> GeneratorRegistry::enumerate() {
return result;
}

GeneratorBase::GeneratorBase(size_t size, const void *introspection_helper)
GeneratorBase::GeneratorBase(size_t size)
: size(size) {
ObjectInstanceRegistry::register_instance(this, size, ObjectInstanceRegistry::Generator, this, introspection_helper);
ObjectInstanceRegistry::register_instance(this, size, ObjectInstanceRegistry::Generator, this);
}

GeneratorBase::~GeneratorBase() {
Expand Down Expand Up @@ -1851,7 +1850,7 @@ GeneratorInputBase::GeneratorInputBase(size_t array_size,
const std::vector<Type> &t,
int d)
: GIOBase(array_size, name, kind, t, d) {
ObjectInstanceRegistry::register_instance(this, 0, ObjectInstanceRegistry::GeneratorInput, this, nullptr);
ObjectInstanceRegistry::register_instance(this, 0, ObjectInstanceRegistry::GeneratorInput, this);
}

GeneratorInputBase::GeneratorInputBase(const std::string &name, ArgInfoKind kind, const std::vector<Type> &t, int d)
Expand Down Expand Up @@ -1994,8 +1993,7 @@ void GeneratorInputBase::set_estimates_impl(const Region &estimates) {
GeneratorOutputBase::GeneratorOutputBase(size_t array_size, const std::string &name, ArgInfoKind kind, const std::vector<Type> &t, int d)
: GIOBase(array_size, name, kind, t, d) {
internal_assert(kind != ArgInfoKind::Scalar);
ObjectInstanceRegistry::register_instance(this, 0, ObjectInstanceRegistry::GeneratorOutput,
this, nullptr);
ObjectInstanceRegistry::register_instance(this, 0, ObjectInstanceRegistry::GeneratorOutput, this);
}

GeneratorOutputBase::GeneratorOutputBase(const std::string &name, ArgInfoKind kind, const std::vector<Type> &t, int d)
Expand Down
6 changes: 2 additions & 4 deletions src/Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@
#include "AbstractGenerator.h"
#include "Func.h"
#include "ImageParam.h"
#include "Introspection.h"
#include "ObjectInstanceRegistry.h"
#include "Target.h"

Expand Down Expand Up @@ -3359,7 +3358,7 @@ class GeneratorBase : public NamesInterface, public AbstractGenerator {
}

protected:
GeneratorBase(size_t size, const void *introspection_helper);
GeneratorBase(size_t size);
void set_generator_names(const std::string &registered_name, const std::string &stub_name);

// Note that it is explicitly legal to override init_from_context(), so that you can (say)
Expand Down Expand Up @@ -3741,8 +3740,7 @@ template<class T>
class Generator : public Internal::GeneratorBase {
protected:
Generator()
: Internal::GeneratorBase(sizeof(T),
Internal::Introspection::get_introspection_helper<T>()) {
: Internal::GeneratorBase(sizeof(T)) {
}

public:
Expand Down
2 changes: 1 addition & 1 deletion src/ImageParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Halide {

ImageParam::ImageParam(Type t, int d)
: OutputImageParam(
Parameter(t, true, d, Internal::make_entity_name(this, "Halide:.*:ImageParam", 'p')),
Parameter(t, true, d, Internal::unique_name('p')),
Argument::InputBuffer,
Func()) {
// We must call create_func() after the super-ctor has completed.
Expand Down
Loading
Loading