Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into abadams/vectorized_as…
Browse files Browse the repository at this point in the history
…serts
  • Loading branch information
abadams committed Dec 7, 2023
2 parents d0d44e0 + 17b7366 commit 787516b
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 58 deletions.
20 changes: 0 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
# For correctness and performance tests this include halide build time and run time. For
# the tests in test/generator/ this times only the halide build time.

# Halide project version
HALIDE_VERSION_MAJOR ?= 17
HALIDE_VERSION_MINOR ?= 0
HALIDE_VERSION_PATCH ?= 0
HALIDE_VERSION=$(HALIDE_VERSION_MAJOR).$(HALIDE_VERSION_MINOR).$(HALIDE_VERSION_PATCH)

# Disable built-in makefile rules for all apps to avoid pointless file-system
# scanning and general weirdness resulting from implicit rules.
MAKEFLAGS += --no-builtin-rules
Expand Down Expand Up @@ -146,12 +140,6 @@ WITH_LLVM_INSIDE_SHARED_LIBHALIDE ?= not-empty
HL_TARGET ?= host
HL_JIT_TARGET ?= host

HL_VERSION_FLAGS = \
-DHALIDE_VERSION="$(HALIDE_VERSION)" \
-DHALIDE_VERSION_MAJOR=$(HALIDE_VERSION_MAJOR) \
-DHALIDE_VERSION_MINOR=$(HALIDE_VERSION_MINOR) \
-DHALIDE_VERSION_PATCH=$(HALIDE_VERSION_PATCH)

X86_CXX_FLAGS=$(if $(WITH_X86), -DWITH_X86, )
X86_LLVM_CONFIG_LIB=$(if $(WITH_X86), x86, )

Expand Down Expand Up @@ -222,7 +210,6 @@ LLVM_CXX_FLAGS_LIBCPP := $(findstring -stdlib=libc++, $(LLVM_CXX_FLAGS))
endif

CXX_FLAGS = $(CXXFLAGS) $(CXX_WARNING_FLAGS) $(RTTI_CXX_FLAGS) -Woverloaded-virtual $(FPIC) $(OPTIMIZE) -fno-omit-frame-pointer -DCOMPILING_HALIDE
CXX_FLAGS += $(HL_VERSION_FLAGS)
CXX_FLAGS += $(LLVM_CXX_FLAGS)
CXX_FLAGS += $(PTX_CXX_FLAGS)
CXX_FLAGS += $(ARM_CXX_FLAGS)
Expand All @@ -248,13 +235,8 @@ CXX_FLAGS += $(WEBASSEMBLY_CXX_FLAGS)
ifneq (,$(shell which flatc))
CXX_FLAGS += -DWITH_SERIALIZATION -I $(BUILD_DIR) -I $(shell which flatc | sed 's/bin.flatc/include/')
# Note: if updating here, be sure to update in CMakeLists.txt as well
HALIDE_SERIALIZATION_VERSION_MAJOR ?= 0
HALIDE_SERIALIZATION_VERSION_MINOR ?= 1
HALIDE_SERIALIZATION_VERSION_PATCH ?= 0
HALIDE_SERIALIZATION_VERSION=$(HALIDE_SERIALIZATION_VERSION_MAJOR).$(HALIDE_SERIALIZATION_VERSION_MINOR).$(HALIDE_SERIALIZATION_VERSION_PATCH)
CXX_FLAGS += -DHALIDE_SERIALIZATION_VERSION_MAJOR=$(HALIDE_SERIALIZATION_VERSION_MAJOR)
CXX_FLAGS += -DHALIDE_SERIALIZATION_VERSION_MINOR=$(HALIDE_SERIALIZATION_VERSION_MINOR)
CXX_FLAGS += -DHALIDE_SERIALIZATION_VERSION_PATCH=$(HALIDE_SERIALIZATION_VERSION_PATCH)
endif

# This is required on some hosts like powerpc64le-linux-gnu because we may build
Expand Down Expand Up @@ -307,7 +289,6 @@ TEST_LD_FLAGS = -L$(BIN_DIR) -lHalide $(COMMON_LD_FLAGS)

# In the tests, some of our expectations change depending on the llvm version
TEST_CXX_FLAGS += -DLLVM_VERSION=$(LLVM_VERSION_TIMES_10)
TEST_CXX_FLAGS += $(HL_VERSION_FLAGS)

# In the tests, default to exporting no symbols that aren't explicitly exported
TEST_CXX_FLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
Expand Down Expand Up @@ -1118,7 +1099,6 @@ RUNTIME_CXX_FLAGS = \
-Wno-unused-function \
-Wvla \
-Wsign-compare
RUNTIME_CXX_FLAGS += $(HL_VERSION_FLAGS)

$(BUILD_DIR)/initmod.windows_%_x86_32.ll: $(SRC_DIR)/runtime/windows_%_x86.cpp $(BUILD_DIR)/clang_ok
@mkdir -p $(@D)
Expand Down
10 changes: 3 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,6 @@ if (WITH_SERIALIZATION)
target_include_directories(Halide PRIVATE "$<BUILD_INTERFACE:${fb_dir}>")
target_link_libraries(Halide PRIVATE Halide_flatbuffers)
target_compile_definitions(Halide PRIVATE WITH_SERIALIZATION)
# Note: if updating here, be sure to update in Makefile as well
target_compile_definitions(Halide PUBLIC
HALIDE_SERIALIZATION_VERSION_MAJOR=0
HALIDE_SERIALIZATION_VERSION_MINOR=1
HALIDE_SERIALIZATION_VERSION_PATCH=0
)
endif ()

# Enable serialization testing by intercepting JIT compilation with a serialization roundtrip;
Expand Down Expand Up @@ -549,8 +543,10 @@ set_target_properties(Halide PROPERTIES
VERSION ${Halide_VERSION}
SOVERSION ${Halide_SOVERSION_OVERRIDE})

# Note that we (deliberately) redeclare these versions here, even though the macros
# with identical versions are expected to be defined in source; this allows us to
# ensure that the versions defined between all build systems are identical.
target_compile_definitions(Halide PUBLIC
HALIDE_VERSION=${Halide_VERSION}
HALIDE_VERSION_MAJOR=${Halide_VERSION_MAJOR}
HALIDE_VERSION_MINOR=${Halide_VERSION_MINOR}
HALIDE_VERSION_PATCH=${Halide_VERSION_PATCH})
Expand Down
46 changes: 22 additions & 24 deletions src/CodeGen_ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1647,48 +1647,46 @@ string CodeGen_ARM::mcpu_tune() const {
}

string CodeGen_ARM::mattrs() const {
string arch_flags;
string separator;
if (target.has_feature(Target::ARMFp16)) {
arch_flags += separator + "+fullfp16";
separator = ",";
}
if (target.has_feature(Target::ARMv81a)) {
arch_flags += separator + "+v8.1a";
separator = ",";
}
if (target.has_feature(Target::ARMDotProd)) {
arch_flags += separator + "+dotprod";
separator = ",";
}
if (target.bits == 32) {
if (target.has_feature(Target::ARMv7s)) {
return "+neon";
arch_flags += separator + "+neon";
separator = ",";
}
if (!target.has_feature(Target::NoNEON)) {
return "+neon";
arch_flags += separator + "+neon";
separator = ",";
} else {
return "-neon";
arch_flags += separator + "-neon";
separator = ",";
}
} else {
// TODO: Should Halide's SVE flags be 64-bit only?
string arch_flags;
string separator;
if (target.has_feature(Target::SVE2)) {
arch_flags = "+sve2";
separator = ",";
} else if (target.has_feature(Target::SVE)) {
arch_flags = "+sve";
separator = ",";
}

if (target.has_feature(Target::ARMv81a)) {
arch_flags += separator + "+v8.1a";
separator = ",";
}

if (target.has_feature(Target::ARMDotProd)) {
arch_flags += separator + "+dotprod";
separator = ",";
}

if (target.has_feature(Target::ARMFp16)) {
arch_flags += separator + "+fullfp16";
separator = ",";
}

if (target.os == Target::IOS || target.os == Target::OSX) {
return arch_flags + separator + "+reserve-x18";
} else {
return arch_flags;
arch_flags += separator + "+reserve-x18";
}
}
return arch_flags;
}

bool CodeGen_ARM::use_soft_float_abi() const {
Expand Down
7 changes: 4 additions & 3 deletions src/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,9 +1418,10 @@ Pipeline Deserializer::deserialize(const std::vector<uint8_t> &data) {
}

std::string deserialized_serialization_version = deserialize_string(pipeline_obj->serialization_version());
std::string serialization_version = std::to_string(HALIDE_SERIALIZATION_VERSION_MAJOR) + "." +
std::to_string(HALIDE_SERIALIZATION_VERSION_MINOR) + "." +
std::to_string(HALIDE_SERIALIZATION_VERSION_PATCH);
std::string serialization_version = std::to_string((int)Serialize::SerializationVersionMajor::Value) + "." +
std::to_string((int)Serialize::SerializationVersionMinor::Value) + "." +
std::to_string((int)Serialize::SerializationVersionPatch::Value);

if (deserialized_serialization_version != serialization_version) {
user_error << "deserialized pipeline is built with Halide serialization version " << deserialized_serialization_version
<< ", but current Halide serialization version is " << serialization_version << "\n";
Expand Down
6 changes: 3 additions & 3 deletions src/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,9 +1509,9 @@ void Serializer::serialize(const Pipeline &pipeline, std::vector<uint8_t> &resul
std::to_string(HALIDE_VERSION_MINOR) + "." +
std::to_string(HALIDE_VERSION_PATCH);

std::string serialization_version = std::to_string(HALIDE_SERIALIZATION_VERSION_MAJOR) + "." +
std::to_string(HALIDE_SERIALIZATION_VERSION_MINOR) + "." +
std::to_string(HALIDE_SERIALIZATION_VERSION_PATCH);
std::string serialization_version = std::to_string((int)Serialize::SerializationVersionMajor::Value) + "." +
std::to_string((int)Serialize::SerializationVersionMinor::Value) + "." +
std::to_string((int)Serialize::SerializationVersionPatch::Value);

auto pipeline_obj = Serialize::CreatePipeline(builder,
builder.CreateVector(funcs_serialized),
Expand Down
10 changes: 10 additions & 0 deletions src/halide_ir.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ file_identifier "HLDE";
// File extension of any written files. "hlpipe" stands for Halide Pipeline.
file_extension "hlpipe";

enum SerializationVersionMajor: int {
Value = 0
}
enum SerializationVersionMinor: int {
Value = 1
}
enum SerializationVersionPatch: int {
Value = 0
}

// from src/IR.cpp
union Stmt {
LetStmt,
Expand Down
9 changes: 9 additions & 0 deletions src/runtime/HalideRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
#include "runtime_internal.h"
#endif

// Note that the canonical Halide version is considered to be defined here
// (rather than in the build system); we redundantly define the value in
// our CMake build, so that we ensure that the in-build metadata (eg soversion)
// matches, but keeping the canonical version here makes it easier to keep
// downstream build systems (eg Blaze/Bazel) properly in sync with the source.
#define HALIDE_VERSION_MAJOR 17
#define HALIDE_VERSION_MINOR 0
#define HALIDE_VERSION_PATCH 0

#ifdef __cplusplus
// Forward declare type to allow naming typed handles.
// See Type.h for documentation.
Expand Down
1 change: 0 additions & 1 deletion test/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function(_set_target_options NAME)
target_compile_definitions(
${NAME}
PRIVATE
HALIDE_VERSION=${Halide_VERSION}
HALIDE_VERSION_MAJOR=${Halide_VERSION_MAJOR}
HALIDE_VERSION_MINOR=${Halide_VERSION_MINOR}
HALIDE_VERSION_PATCH=${Halide_VERSION_PATCH}
Expand Down

0 comments on commit 787516b

Please sign in to comment.