Skip to content

Commit

Permalink
Drop support for Matlab extensions (halide#6696)
Browse files Browse the repository at this point in the history
* Drop support for Matlab extensions

Anecdotally, this hasn't been used in ~years, and the original author (@dsharletg) had suggested dropping it a while back. I'm going to propose we go ahead and drop it for Halide 15 and see who complains.

* Fixes for top-of-tree LLVM

* Update force_include_types.cpp

* trigger buildbots

* Update CodeGen_LLVM.cpp
  • Loading branch information
steven-johnson authored and ardier committed Mar 3, 2024
1 parent 9424f95 commit bdc7dad
Show file tree
Hide file tree
Showing 27 changed files with 5 additions and 1,396 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ CMakeUserPresets.json
/tutorial/figures/tmp/trace.bin
/apps/*/bin
/apps/*/cmake_build
/apps/HelloMatlab/blurred.png
/apps/HelloMatlab/iir_blur.mex
bin/*
build/*
share/*
Expand Down
24 changes: 0 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ SOURCE_FILES = \
Lower.cpp \
LowerParallelTasks.cpp \
LowerWarpShuffles.cpp \
MatlabWrapper.cpp \
Memoization.cpp \
Module.cpp \
ModulusRemainder.cpp \
Expand Down Expand Up @@ -673,7 +672,6 @@ HEADER_FILES = \
LowerParallelTasks.h \
LowerWarpShuffles.h \
MainPage.h \
MatlabWrapper.h \
Memoization.h \
Module.h \
ModulusRemainder.h \
Expand Down Expand Up @@ -773,7 +771,6 @@ RUNTIME_CPP_COMPONENTS = \
linux_clock \
linux_host_cpu_count \
linux_yield \
matlab \
metal \
metal_objc_arm \
metal_objc_x86 \
Expand Down Expand Up @@ -1201,9 +1198,6 @@ GENERATOR_AOTCPP_TESTS := $(filter-out generator_aotcpp_msan,$(GENERATOR_AOTCPP_
# https://github.com/halide/Halide/issues/2075
GENERATOR_AOTCPP_TESTS := $(filter-out generator_aotcpp_memory_profiler_mandelbrot,$(GENERATOR_AOTCPP_TESTS))

# https://github.com/halide/Halide/issues/2082
GENERATOR_AOTCPP_TESTS := $(filter-out generator_aotcpp_matlab,$(GENERATOR_AOTCPP_TESTS))

# https://github.com/halide/Halide/issues/2093
GENERATOR_AOTCPP_TESTS := $(filter-out generator_aotcpp_async_parallel,$(GENERATOR_AOTCPP_TESTS))

Expand All @@ -1222,7 +1216,6 @@ GENERATOR_BUILD_RUNGEN_TESTS = $(GENERATOR_EXTERNAL_TEST_GENERATOR:$(ROOT_DIR)/t
GENERATOR_BUILD_RUNGEN_TESTS := $(filter-out $(FILTERS_DIR)/async_parallel.rungen,$(GENERATOR_BUILD_RUNGEN_TESTS))
GENERATOR_BUILD_RUNGEN_TESTS := $(filter-out $(FILTERS_DIR)/cxx_mangling_define_extern.rungen,$(GENERATOR_BUILD_RUNGEN_TESTS))
GENERATOR_BUILD_RUNGEN_TESTS := $(filter-out $(FILTERS_DIR)/define_extern_opencl.rungen,$(GENERATOR_BUILD_RUNGEN_TESTS))
GENERATOR_BUILD_RUNGEN_TESTS := $(filter-out $(FILTERS_DIR)/matlab.rungen,$(GENERATOR_BUILD_RUNGEN_TESTS))
GENERATOR_BUILD_RUNGEN_TESTS := $(filter-out $(FILTERS_DIR)/msan.rungen,$(GENERATOR_BUILD_RUNGEN_TESTS))
GENERATOR_BUILD_RUNGEN_TESTS := $(filter-out $(FILTERS_DIR)/sanitizercoverage.rungen,$(GENERATOR_BUILD_RUNGEN_TESTS))
GENERATOR_BUILD_RUNGEN_TESTS := $(filter-out $(FILTERS_DIR)/multitarget.rungen,$(GENERATOR_BUILD_RUNGEN_TESTS))
Expand Down Expand Up @@ -1512,11 +1505,6 @@ $(FILTERS_DIR)/user_context_insanity.a: $(BIN_DIR)/user_context_insanity.generat
@mkdir -p $(@D)
$(CURDIR)/$< -g user_context_insanity $(GEN_AOT_OUTPUTS) -o $(CURDIR)/$(FILTERS_DIR) target=$(TARGET)-no_runtime-user_context

# matlab needs to be generated with matlab in TARGET
$(FILTERS_DIR)/matlab.a: $(BIN_DIR)/matlab.generator
@mkdir -p $(@D)
$(CURDIR)/$< -g matlab $(GEN_AOT_OUTPUTS) -o $(CURDIR)/$(FILTERS_DIR) target=$(TARGET)-no_runtime-matlab

# Some .generators have additional dependencies (usually due to define_extern usage).
# These typically require two extra dependencies:
# (1) Ensuring the extra _generator.cpp is built into the .generator.
Expand Down Expand Up @@ -1645,15 +1633,6 @@ $(BIN_DIR)/$(TARGET)/generator_aotcpp_nested_externs: $(ROOT_DIR)/test/generator
@mkdir -p $(@D)
$(CXX) $(GEN_AOT_CXX_FLAGS) $(filter %.cpp %.o %.a,$^) $(GEN_AOT_INCLUDES) $(GEN_AOT_LD_FLAGS) -o $@

# The matlab tests needs "-matlab" in the runtime
$(BIN_DIR)/$(TARGET)/generator_aot_matlab: $(ROOT_DIR)/test/generator/matlab_aottest.cpp $(FILTERS_DIR)/matlab.a $(FILTERS_DIR)/matlab.h $(RUNTIME_EXPORTED_INCLUDES) $(BIN_DIR)/$(TARGET)-matlab/runtime.a
@mkdir -p $(@D)
$(CXX) $(GEN_AOT_CXX_FLAGS) $(filter %.cpp %.o %.a,$^) $(GEN_AOT_INCLUDES) $(GEN_AOT_LD_FLAGS) $(TEST_LD_FLAGS) -o $@

$(BIN_DIR)/$(TARGET)/generator_aotcpp_matlab: $(ROOT_DIR)/test/generator/matlab_aottest.cpp $(FILTERS_DIR)/matlab.halide_generated.cpp $(FILTERS_DIR)/matlab.h $(RUNTIME_EXPORTED_INCLUDES) $(BIN_DIR)/$(TARGET)-matlab/runtime.a
@mkdir -p $(@D)
$(CXX) $(GEN_AOT_CXX_FLAGS) $(filter %.cpp %.o %.a,$^) $(GEN_AOT_INCLUDES) $(GEN_AOT_LD_FLAGS) $(TEST_LD_FLAGS) -o $@

# The gpu object lifetime test needs the debug runtime
$(BIN_DIR)/$(TARGET)/generator_aot_gpu_object_lifetime: $(ROOT_DIR)/test/generator/gpu_object_lifetime_aottest.cpp $(FILTERS_DIR)/gpu_object_lifetime.a $(FILTERS_DIR)/gpu_object_lifetime.h $(RUNTIME_EXPORTED_INCLUDES) $(BIN_DIR)/$(TARGET)-debug/runtime.a
@mkdir -p $(@D)
Expand Down Expand Up @@ -1978,7 +1957,6 @@ time_compilation_generator_%: $(BIN_DIR)/%.generator
$(TIME_COMPILATION) compile_times_generator.csv make -f $(THIS_MAKEFILE) $(@:time_compilation_generator_%=$(FILTERS_DIR)/%.a)

TEST_APPS=\
HelloMatlab \
bilateral_grid \
bgu \
blur \
Expand Down Expand Up @@ -2235,7 +2213,6 @@ install: $(LIB_DIR)/libHalide.a $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR
cp $(ROOT_DIR)/tutorial/*.cpp $(PREFIX)/share/halide/tutorial
cp $(ROOT_DIR)/tutorial/*.h $(PREFIX)/share/halide/tutorial
cp $(ROOT_DIR)/tutorial/*.sh $(PREFIX)/share/halide/tutorial
cp $(ROOT_DIR)/tools/mex_halide.m $(PREFIX)/share/halide/tools
cp $(ROOT_DIR)/tools/GenGen.cpp $(PREFIX)/share/halide/tools
cp $(ROOT_DIR)/tools/RunGen.h $(PREFIX)/share/halide/tools
cp $(ROOT_DIR)/tools/RunGenMain.cpp $(PREFIX)/share/halide/tools
Expand Down Expand Up @@ -2313,7 +2290,6 @@ $(DISTRIB_DIR)/lib/libHalide.$(SHARED_EXT): \
cp $(ROOT_DIR)/tutorial/*.cpp $(DISTRIB_DIR)/tutorial
cp $(ROOT_DIR)/tutorial/*.h $(DISTRIB_DIR)/tutorial
cp $(ROOT_DIR)/tutorial/*.sh $(DISTRIB_DIR)/tutorial
cp $(ROOT_DIR)/tools/mex_halide.m $(DISTRIB_DIR)/tools
cp $(ROOT_DIR)/tools/GenGen.cpp $(DISTRIB_DIR)/tools
cp $(ROOT_DIR)/tools/RunGen.h $(DISTRIB_DIR)/tools
cp $(ROOT_DIR)/tools/RunGenMain.cpp $(DISTRIB_DIR)/tools
Expand Down
1 change: 0 additions & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ enable_testing()

# add_subdirectory(HelloAndroid) # TODO(#5374): missing CMake build
# add_subdirectory(HelloAndroidCamera2) # TODO(#5374): missing CMake build
# add_subdirectory(HelloMatlab) # TODO(#5374): missing CMake build
# add_subdirectory(HelloPyTorch) # TODO(#5374): missing CMake build
# add_subdirectory(HelloWasm) # TODO(#5374): missing CMake build
# add_subdirectory(HelloiOS) # TODO(#5374): missing CMake build
Expand Down
9 changes: 0 additions & 9 deletions apps/HelloMatlab/Makefile

This file was deleted.

86 changes: 0 additions & 86 deletions apps/HelloMatlab/iir_blur.cpp

This file was deleted.

22 changes: 0 additions & 22 deletions apps/HelloMatlab/run_blur.m

This file was deleted.

22 changes: 0 additions & 22 deletions apps/HelloMatlab/run_blur.sh

This file was deleted.

1 change: 0 additions & 1 deletion python_bindings/src/PyEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ void define_enums(py::module &m) {
.value("OpenGLCompute", Target::Feature::OpenGLCompute)
.value("EGL", Target::Feature::EGL)
.value("UserContext", Target::Feature::UserContext)
.value("Matlab", Target::Feature::Matlab)
.value("Profile", Target::Feature::Profile)
.value("NoRuntime", Target::Feature::NoRuntime)
.value("Metal", Target::Feature::Metal)
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ set(HEADER_FILES
LowerParallelTasks.h
LowerWarpShuffles.h
MainPage.h
MatlabWrapper.h
Memoization.h
Module.h
ModulusRemainder.h
Expand Down Expand Up @@ -261,7 +260,6 @@ set(SOURCE_FILES
Lower.cpp
LowerParallelTasks.cpp
LowerWarpShuffles.cpp
MatlabWrapper.cpp
Memoization.cpp
Module.cpp
ModulusRemainder.cpp
Expand Down
11 changes: 3 additions & 8 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "LLVM_Runtime_Linker.h"
#include "Lerp.h"
#include "LowerParallelTasks.h"
#include "MatlabWrapper.h"
#include "Pipeline.h"
#include "Simplify.h"
#include "Util.h"
Expand Down Expand Up @@ -542,14 +541,10 @@ std::unique_ptr<llvm::Module> CodeGen_LLVM::compile(const Module &input) {
// If the Func is externally visible, also create the argv wrapper and metadata.
// (useful for calling from JIT and other machine interfaces).
if (f.linkage == LinkageType::ExternalPlusArgv || f.linkage == LinkageType::ExternalPlusMetadata) {
llvm::Function *wrapper = add_argv_wrapper(function, names.argv_name, false, buffer_args);
add_argv_wrapper(function, names.argv_name, false, buffer_args);
if (f.linkage == LinkageType::ExternalPlusMetadata) {
llvm::Function *metadata_getter = embed_metadata_getter(names.metadata_name,
names.simple_name, f.args, input.get_metadata_name_map());

if (target.has_feature(Target::Matlab)) {
define_matlab_wrapper(module.get(), wrapper, metadata_getter);
}
embed_metadata_getter(names.metadata_name,
names.simple_name, f.args, input.get_metadata_name_map());
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/LLVM_Runtime_Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ DECLARE_CPP_INITMOD(ios_io)
DECLARE_CPP_INITMOD(linux_clock)
DECLARE_CPP_INITMOD(linux_host_cpu_count)
DECLARE_CPP_INITMOD(linux_yield)
DECLARE_CPP_INITMOD(matlab)
DECLARE_CPP_INITMOD(module_aot_ref_count)
DECLARE_CPP_INITMOD(module_jit_ref_count)
DECLARE_CPP_INITMOD(msan)
Expand Down Expand Up @@ -1209,10 +1208,6 @@ std::unique_ptr<llvm::Module> get_initial_module_for_target(Target t, llvm::LLVM
}
}

if (module_type == ModuleAOT && t.has_feature(Target::Matlab)) {
modules.push_back(get_initmod_matlab(c, bits_64, debug));
}

if (module_type == ModuleAOTNoRuntime ||
module_type == ModuleJITInlined ||
t.os == Target::NoOS) {
Expand Down
72 changes: 0 additions & 72 deletions src/MatlabWrapper.cpp

This file was deleted.

Loading

0 comments on commit bdc7dad

Please sign in to comment.