Skip to content
Open
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
6 changes: 3 additions & 3 deletions cmake/HalideGeneratorHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ endfunction()

function(_Halide_set_osx_arch TARGET TRIPLE)
if (APPLE)
if (TRIPLE STREQUAL "arm-64-osx")
if (TRIPLE STREQUAL "arm-64-macos" OR TRIPLE STREQUAL "arm-64-osx")
set_property(TARGET "${TARGET}" PROPERTY OSX_ARCHITECTURES "arm64")
elseif (TRIPLE STREQUAL "x86-64-osx")
elseif (TRIPLE STREQUAL "x86-64-macos" OR TRIPLE STREQUAL "x86-64-osx")
set_property(TARGET "${TARGET}" PROPERTY OSX_ARCHITECTURES "x86_64")
else ()
message(FATAL_ERROR "Could not set OSX_ARCHITECTURES for ${TRIPLE}")
Expand Down Expand Up @@ -694,7 +694,7 @@ function(add_halide_library TARGET)
set(features_args FEATURES)
foreach (arch IN ITEMS x86 arm powerpc hexagon wasm riscv)
foreach (bits IN ITEMS 32 64)
foreach (os IN ITEMS linux windows osx android ios qurt noos fuchsia wasmrt)
foreach (os IN ITEMS linux windows macos osx android ios qurt noos fuchsia wasmrt)
list(APPEND features_args "FEATURES[${arch}-${bits}-${os}]")
endforeach ()
endforeach ()
Expand Down
2 changes: 1 addition & 1 deletion cmake/HalideTargetHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function(_Halide_target_arch_os OUT_ARCH OUT_OS raw_arch raw_os)
list(TRANSFORM arch REPLACE "^aarch(64)?$" "arm")

string(TOLOWER "${raw_os}" os)
list(TRANSFORM os REPLACE "^darwin$" "osx")
list(TRANSFORM os REPLACE "^darwin$" "macos")
list(TRANSFORM os REPLACE "^emscripten$" "wasmrt")

# Fix up emscripten usage
Expand Down
2 changes: 1 addition & 1 deletion doc/HalideCMakePackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ add_halide_library(<target> FROM <generator-target>
triple = <arch>-<bits>-<os>
arch = x86 | arm | powerpc | hexagon | wasm | riscv
bits = 32 | 64
os = linux | windows | osx | android | ios | qurt | noos | fuchsia | wasmrt
os = linux | windows | macos | android | ios | qurt | noos | fuchsia | wasmrt

extra-output = ASSEMBLY | BITCODE | COMPILER_LOG | C_SOURCE | FEATURIZATION
| HLPIPE | LLVM_ASSEMBLY | PYTHON_EXTENSION | PYTORCH_WRAPPER
Expand Down
2 changes: 1 addition & 1 deletion packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ if (NOT CPACK_PACKAGE_FILE_NAME)
set(arch_tag "${Halide_CMAKE_TARGET}")
list(REMOVE_DUPLICATES arch_tag)
list(SORT arch_tag)
if (arch_tag MATCHES "arm-64-osx;x86-64-osx")
if (arch_tag MATCHES "arm-64-macos;x86-64-macos")
set(arch_tag "universal2")
endif ()
string(REPLACE ";" "_" arch_tag "${arch_tag}")
Expand Down
23 changes: 23 additions & 0 deletions python_bindings/halide/src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from pathlib import Path

# halide-bin owns library discovery and loads its bundled libHalide before the
Expand All @@ -10,6 +11,10 @@
from . import runtime as runtime
from .halide_ import * # noqa: F403

# TargetOS comes from the star import above; name it explicitly so the
# deprecation shim below doesn't trip ruff's F405.
from .halide_ import TargetOS

# The implicit-argument placeholders are deliberately imported explicitly;
# `from .halide_ import *` skips them because they begin with an underscore.
from .halide_ import _, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9 # noqa: F401
Expand All @@ -33,5 +38,23 @@
)


class _DeprecatedEnumValue:
"""Descriptor that returns a replacement enum value, after warning."""

def __init__(self, replacement, message):
self._replacement = replacement
self._message = message

def __get__(self, obj, owner):
warnings.warn(self._message, DeprecationWarning, stacklevel=2)
return self._replacement


# TargetOS.OSX is deprecated in favor of TargetOS.MacOS; accessing it warns.
TargetOS.OSX = _DeprecatedEnumValue(
TargetOS.MacOS, "TargetOS.OSX is deprecated; use TargetOS.MacOS instead."
)


def install_dir():
return str(Path(__file__).resolve().parent)
32 changes: 22 additions & 10 deletions python_bindings/halide/src/halide_/PyEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,28 @@ void define_enums(py::module &m) {
#pragma GCC diagnostic pop
#endif

py::enum_<Target::OS>(m, "TargetOS")
.value("OSUnknown", Target::OS::OSUnknown)
.value("Linux", Target::OS::Linux)
.value("Windows", Target::OS::Windows)
.value("OSX", Target::OS::OSX)
.value("Android", Target::OS::Android)
.value("IOS", Target::OS::IOS)
.value("QuRT", Target::OS::QuRT)
.value("NoOS", Target::OS::NoOS)
.value("wasmrt", Target::OS::WebAssemblyRuntime);
auto target_os =
py::enum_<Target::OS>(m, "TargetOS")
.value("OSUnknown", Target::OS::OSUnknown)
.value("Linux", Target::OS::Linux)
.value("Windows", Target::OS::Windows)
.value("MacOS", Target::OS::MacOS)
.value("Android", Target::OS::Android)
.value("IOS", Target::OS::IOS)
.value("QuRT", Target::OS::QuRT)
.value("NoOS", Target::OS::NoOS)
.value("wasmrt", Target::OS::WebAssemblyRuntime);

// OSX is deprecated in C++ (identical to MacOS), but the Python binding
// is kept for one release for backwards compatibility.
#if defined(__clang__) || defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
target_os.value("OSX", Target::OS::OSX);
Comment thread
alexreinking marked this conversation as resolved.
#if defined(__clang__) || defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

py::enum_<Target::Arch>(m, "TargetArch")
.value("ArchUnknown", Target::Arch::ArchUnknown)
Expand Down
8 changes: 4 additions & 4 deletions python_bindings/halide/test/correctness/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ def test_target():
assert not t2.supports_device_api(hl.DeviceAPI.CUDA)

# supports_type (deprecated version)
t1 = hl.Target(hl.TargetOS.OSX, hl.TargetArch.X86, 64, [hl.TargetFeature.Metal])
t2 = hl.Target(hl.TargetOS.OSX, hl.TargetArch.X86, 64)
t1 = hl.Target(hl.TargetOS.MacOS, hl.TargetArch.X86, 64, [hl.TargetFeature.Metal])
t2 = hl.Target(hl.TargetOS.MacOS, hl.TargetArch.X86, 64)
assert not t1.supports_type(hl.Float(64))
assert t2.supports_type(hl.Float(64))

# supports_type (preferred version)
t1 = hl.Target(hl.TargetOS.OSX, hl.TargetArch.X86, 64, [hl.TargetFeature.Metal])
t2 = hl.Target(hl.TargetOS.OSX, hl.TargetArch.X86, 64)
t1 = hl.Target(hl.TargetOS.MacOS, hl.TargetArch.X86, 64, [hl.TargetFeature.Metal])
t2 = hl.Target(hl.TargetOS.MacOS, hl.TargetArch.X86, 64)
assert not t1.supports_type(hl.Float(64), hl.DeviceAPI.Metal)
assert not t2.supports_type(hl.Float(64), hl.DeviceAPI.Metal)

Expand Down
2 changes: 1 addition & 1 deletion python_bindings/halide/tutorial/lesson_12_using_the_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def find_gpu_target():
# D3D12Compute support is only available on 64-bit systems at present.
features_to_try.append(hl.TargetFeature.D3D12Compute)
features_to_try.append(hl.TargetFeature.OpenCL)
elif target.os == hl.TargetOS.OSX:
elif target.os == hl.TargetOS.MacOS:
features_to_try.append(hl.TargetFeature.Metal)
else:
features_to_try.append(hl.TargetFeature.OpenCL)
Expand Down
2 changes: 1 addition & 1 deletion python_bindings/halide/tutorial/lesson_19_wrapper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def main():

# Select an appropriate GPU API, as we did in lesson 12.
target = hl.get_host_target()
if target.os == hl.TargetOS.OSX:
if target.os == hl.TargetOS.MacOS:
target = target.with_feature(hl.TargetFeature.Metal)
else:
target = target.with_feature(hl.TargetFeature.OpenCL)
Expand Down
8 changes: 4 additions & 4 deletions src/CPlusPlusMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ std::string simple_type_to_mangle_char(const std::string &type_name, const Targe
} else if (type_name == "uint32_t") {
return "j";
} else if (type_name == "int64_t") {
if (target.os == Target::OSX ||
if (target.os == Target::MacOS ||
target.os == Target::IOS ||
target.bits == 32) {
return "x";
} else {
return "l";
}
} else if (type_name == "uint64_t") {
if (target.os == Target::OSX ||
if (target.os == Target::MacOS ||
target.os == Target::IOS ||
target.bits == 32) {
return "y";
Expand Down Expand Up @@ -539,7 +539,7 @@ std::string mangle_type(const Type &type, const Target &target, PrevPrefixes &pr
return "i";
}
case 64:
if (target.os == Target::OSX ||
if (target.os == Target::MacOS ||
target.os == Target::IOS ||
target.bits == 32) {
return "x";
Expand All @@ -565,7 +565,7 @@ std::string mangle_type(const Type &type, const Target &target, PrevPrefixes &pr
return "j";
}
case 64:
if (target.os == Target::OSX ||
if (target.os == Target::MacOS ||
target.os == Target::IOS ||
target.bits == 32) {
return "y";
Expand Down
8 changes: 4 additions & 4 deletions src/CodeGen_ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ void CodeGen_ARM::compile_func(const LoweredFunc &f,
internal_assert(llvm_func);
bool is_streaming_task = (f.attributes & LoweredFunc::Attribute::SME_STREAMING_TASK) && target.has_feature(Target::SME2);

if (target.os != Target::IOS && target.os != Target::OSX) {
if (target.os != Target::IOS && target.os != Target::MacOS) {
// Substitute in strided loads to get vld2/3/4 emission. We don't do it
// on Apple silicon, because doing a dense load and then shuffling is
// actually faster.
Expand Down Expand Up @@ -2032,7 +2032,7 @@ void CodeGen_ARM::visit(const Shuffle *op) {
// load.
int stride = op->slice_stride();
const Load *load = op->vectors[0].as<Load>();
if (target.os != Target::IOS && target.os != Target::OSX &&
if (target.os != Target::IOS && target.os != Target::MacOS &&
load &&
op->vectors.size() == 1 &&
op->is_slice() &&
Expand Down Expand Up @@ -2932,7 +2932,7 @@ string CodeGen_ARM::mcpu_target() const {
} else {
if (target.os == Target::IOS) {
return "apple-a7";
} else if (target.os == Target::OSX) {
} else if (target.os == Target::MacOS) {
return "apple-m1";
} else if (target.has_feature(Target::SVE2)) {
return "cortex-x1";
Expand Down Expand Up @@ -3011,7 +3011,7 @@ string CodeGen_ARM::mattrs() const {
if (target.has_feature(Target::SME2)) {
attrs.emplace_back("+sme2");
}
if (target.os == Target::IOS || target.os == Target::OSX) {
if (target.os == Target::IOS || target.os == Target::MacOS) {
attrs.emplace_back("+reserve-x18");
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/LLVM_Runtime_Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ namespace {
llvm::DataLayout get_data_layout_for_target(Target target) {
if (target.arch == Target::X86) {
if (target.bits == 32) {
if (target.os == Target::OSX) {
if (target.os == Target::MacOS) {
return llvm::DataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:128-n8:16:32-S128");
} else if (target.os == Target::IOS) {
return llvm::DataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:128-n8:16:32-S128");
Expand All @@ -369,7 +369,7 @@ llvm::DataLayout get_data_layout_for_target(Target target) {
return llvm::DataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128");
}
} else { // 64-bit
if (target.os == Target::OSX) {
if (target.os == Target::MacOS) {
return llvm::DataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128");
} else if (target.os == Target::IOS) {
return llvm::DataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128");
Expand All @@ -391,7 +391,7 @@ llvm::DataLayout get_data_layout_for_target(Target target) {
} else { // 64-bit
if (target.os == Target::IOS) {
return llvm::DataLayout("e-m:o-i64:64-i128:128-n32:64-S128-Fn32");
} else if (target.os == Target::OSX) {
} else if (target.os == Target::MacOS) {
return llvm::DataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32");
} else if (target.os == Target::Windows) {
return llvm::DataLayout("e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32");
Expand Down Expand Up @@ -469,7 +469,7 @@ llvm::Triple get_triple_for_target(const Target &target) {
if (target.os == Target::Linux) {
triple.setOS(llvm::Triple::Linux);
triple.setEnvironment(llvm::Triple::GNU);
} else if (target.os == Target::OSX) {
} else if (target.os == Target::MacOS) {
triple.setVendor(llvm::Triple::Apple);
triple.setOS(llvm::Triple::MacOSX);
} else if (target.os == Target::Windows) {
Expand Down Expand Up @@ -527,7 +527,7 @@ llvm::Triple get_triple_for_target(const Target &target) {
}
} else if (target.os == Target::Fuchsia) {
triple.setOS(llvm::Triple::Fuchsia);
} else if (target.os == Target::OSX) {
} else if (target.os == Target::MacOS) {
triple.setVendor(llvm::Triple::Apple);
triple.setOS(llvm::Triple::MacOSX);
triple.setArchName("arm64");
Expand Down Expand Up @@ -676,7 +676,7 @@ void link_modules(std::vector<std::unique_ptr<llvm::Module>> &modules, Target t,
// Comdats are left in for other platforms as they are required
// for certain things on Windows and they are useful in general in
// ELF based formats.
if (t.os == Target::IOS || t.os == Target::OSX) {
if (t.os == Target::IOS || t.os == Target::MacOS) {
for (auto &global_obj : modules[0]->global_objects()) {
global_obj.setComdat(nullptr);
}
Expand Down Expand Up @@ -1016,7 +1016,7 @@ std::unique_ptr<llvm::Module> get_initial_module_for_target(Target t, llvm::LLVM
modules.push_back(get_initmod_fake_thread_pool(c, bits_64, debug));
}
modules.push_back(get_initmod_fake_get_symbol(c, bits_64, debug));
} else if (t.os == Target::OSX) {
} else if (t.os == Target::MacOS) {
add_allocator();
modules.push_back(get_initmod_posix_error_handler(c, bits_64, debug));
modules.push_back(get_initmod_posix_print(c, bits_64, debug));
Expand Down Expand Up @@ -1280,7 +1280,7 @@ std::unique_ptr<llvm::Module> get_initial_module_for_target(Target t, llvm::LLVM
if (t.arch == Target::ARM) {
if (t.os == Target::Android || t.os == Target::Linux) {
modules.push_back(get_initmod_linux_arm_cpu_features(c, bits_64, debug));
} else if (t.os == Target::OSX || t.os == Target::IOS) {
} else if (t.os == Target::MacOS || t.os == Target::IOS) {
modules.push_back(get_initmod_osx_arm_cpu_features(c, bits_64, debug));
} else if (t.bits == 64 && t.os == Target::Windows) {
modules.push_back(get_initmod_windows_aarch64_cpu_features_arm(c, bits_64, debug));
Expand Down
12 changes: 8 additions & 4 deletions src/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Target calculate_host_target() {
os = Target::Windows;
#endif
#ifdef __APPLE__
os = Target::OSX;
os = Target::MacOS;
#endif

bool use_64_bits = (sizeof(size_t) == 8);
Expand Down Expand Up @@ -456,7 +456,8 @@ const std::map<std::string, Target::OS> os_name_map = {
{"os_unknown", Target::OSUnknown},
{"linux", Target::Linux},
{"windows", Target::Windows},
{"osx", Target::OSX},
{"macos", Target::MacOS},
{"osx", Target::MacOS}, // Deprecated alias for macos.
{"android", Target::Android},
{"ios", Target::IOS},
{"qurt", Target::QuRT},
Expand All @@ -468,6 +469,9 @@ bool lookup_os(const std::string &tok, Target::OS &result) {
auto os_iter = os_name_map.find(tok);
if (os_iter != os_name_map.end()) {
result = os_iter->second;
if (tok == "osx") {
user_warning << "\"osx\" is a deprecated alias for \"macos\" in Halide target strings and will be removed in a future release.\n";
}
return true;
}
return false;
Expand Down Expand Up @@ -1248,7 +1252,7 @@ void Target::set_implied_features() {
set_feature(AVX512_SapphireRapids);
}
}
if (arch == ARM && os == OSX) {
if (arch == ARM && os == MacOS) {
// Apple silicon implements at least the ARM v8.4-A spec.
set_feature(ARMv84a);
}
Expand Down Expand Up @@ -1285,7 +1289,7 @@ void Target::unset_implied_features() {
set_feature(AVX2, false);
}
}
if (arch == ARM && os == OSX) {
if (arch == ARM && os == MacOS) {
set_feature(ARMv84a, false);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ struct Target {
OSUnknown = 0,
Linux,
Windows,
OSX,
MacOS,
OSX [[deprecated("Use Target::MacOS instead.")]] = MacOS,
Android,
IOS,
QuRT,
Expand Down
8 changes: 4 additions & 4 deletions src/autoschedulers/adams2019/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ add_halide_library(
FROM adams2019_cost_model.generator
GENERATOR cost_model
FUNCTION_NAME cost_model
FEATURES[x86-64-osx] avx2 sse41
FEATURES[arm-64-osx] arm_dot_prod-arm_fp16
FEATURES[x86-64-macos] avx2 sse41
FEATURES[arm-64-macos] arm_dot_prod-arm_fp16
)

add_halide_library(
adams2019_train_cost_model
FROM adams2019_cost_model.generator
GENERATOR train_cost_model
FUNCTION_NAME train_cost_model
FEATURES[x86-64-osx] avx2 sse41
FEATURES[arm-64-osx] arm_dot_prod-arm_fp16
FEATURES[x86-64-macos] avx2 sse41
FEATURES[arm-64-macos] arm_dot_prod-arm_fp16
USE_RUNTIME adams2019_cost_model.runtime
)

Expand Down
Loading
Loading