Skip to content

Commit

Permalink
Add support to the makefile for serialization (halide#7762)
Browse files Browse the repository at this point in the history
* Add support to the makefile for serialization

* Fix deps

* Fix for no flatc, and for homebrew

---------

Co-authored-by: Steven Johnson <srj@google.com>
  • Loading branch information
2 people authored and ardier committed Mar 3, 2024
1 parent dce3908 commit 64623eb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ CXX_FLAGS += $(SPIRV_CXX_FLAGS)
CXX_FLAGS += $(VULKAN_CXX_FLAGS)
CXX_FLAGS += $(WEBASSEMBLY_CXX_FLAGS)

# Serialization requires flatc and flatbuffers.h
# On ubuntu, this requires packages flatbuffers-compiler and libflatbuffers-dev
ifneq (,$(shell which flatc))
CXX_FLAGS += -DWITH_SERIALIZATION -I $(BUILD_DIR) -I $(shell which flatc | sed 's/bin.flatc/include/')
endif

# This is required on some hosts like powerpc64le-linux-gnu because we may build
# everything with -fno-exceptions. Without -funwind-tables, libHalide.so fails
# to propagate exceptions and causes a test failure.
Expand Down Expand Up @@ -499,6 +505,7 @@ SOURCE_FILES = \
Deinterleave.cpp \
Derivative.cpp \
DerivativeUtils.cpp \
Deserialization.cpp \
DeviceArgument.cpp \
DeviceInterface.cpp \
Dimension.cpp \
Expand Down Expand Up @@ -578,6 +585,7 @@ SOURCE_FILES = \
Schedule.cpp \
ScheduleFunctions.cpp \
SelectGPUAPI.cpp \
Serialization.cpp \
Simplify.cpp \
Simplify_Add.cpp \
Simplify_And.cpp \
Expand Down Expand Up @@ -688,6 +696,7 @@ HEADER_FILES = \
Deinterleave.h \
Derivative.h \
DerivativeUtils.h \
Deserialization.h \
DeviceAPI.h \
DeviceArgument.h \
DeviceInterface.h \
Expand Down Expand Up @@ -778,6 +787,7 @@ HEADER_FILES = \
ScheduleFunctions.h \
Scope.h \
SelectGPUAPI.h \
Serialization.h \
Simplify.h \
SimplifyCorrelatedDifferences.h \
SimplifySpecializations.h \
Expand Down Expand Up @@ -1384,6 +1394,16 @@ $(BIN_DIR)/test_internal: $(ROOT_DIR)/test/internal.cpp $(BIN_DIR)/libHalide.$(S
@mkdir -p $(@D)
$(CXX) $(TEST_CXX_FLAGS) $< -I$(SRC_DIR) $(TEST_LD_FLAGS) -o $@

ifneq (,$(shell which flatc))
$(BUILD_DIR)/Deserialization.o : $(BUILD_DIR)/halide_ir_generated.h
$(BUILD_DIR)/Serialization.o : $(BUILD_DIR)/halide_ir_generated.h
endif

# Generated header for serialization/deserialization
$(BUILD_DIR)/halide_ir_generated.h: $(SRC_DIR)/halide_ir.fbs
@mkdir -p $(@D)
flatc -o $(BUILD_DIR) -c $^

# Correctness test that link against libHalide
$(BIN_DIR)/correctness_%: $(ROOT_DIR)/test/correctness/%.cpp $(BIN_DIR)/libHalide.$(SHARED_EXT) $(INCLUDE_DIR)/Halide.h $(RUNTIME_EXPORTED_INCLUDES)
@mkdir -p $(@D)
Expand Down

0 comments on commit 64623eb

Please sign in to comment.