| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Store arrays in MTLBuffer allocations and execute backend operations on Metal command queues. Replace host-side operation emulation with native MSL dispatch, MPSGraph FFT/inverse paths, JIT compilation, and cached compute pipelines.
Expose Metal device, queue, buffer, and command-buffer interop through the umbrella and Unified APIs. Wire the public header into generated C API sources and retain focused interop and kernel-cache coverage.
Document the native Metal computation paths, precision and OS constraints, kernel compilation and caching behavior, interop API, device selection, and Metal JIT configuration.
| Back | FazBrowse Home | New Git URL |
This pull request adds a native Metal compute backend for ArrayFire on Apple silicon using Apple's metal-cpp headers. This integrates Metal with the backend-specific and Unified APIs, with Metal preferred over OpenCL on macOS.
Description
This is a new backend feature for macOS arm64 systems, plus one small portability fix in shared API code.
The PR adds a native Metal backend targeting macOS 12 or later on Apple silicon. It introduces the AF_BUILD_METAL build option, the ArrayFire::afmetal CMake target, the public AF_BACKEND_METAL backend enum value, CMake package export support, and Unified API loading/selection support. The Unified backend priority is updated to:
as OpenCL support is deprecated on MacOS devices. The Metal backend implementation uses modular .metal source files that are embedded and compiled through ArrayFire's source-generation infrastructure. It covers core ArrayFire functionality including array operations and JIT evaluation, reductions, scans, sorting, indexing, FFT and convolution, BLAS and linear algebra, image processing and computer vision, sparse arrays, and random-number generation.
The PR also updates Metal build, usage, priority, and limitation documentation. Building the backend requires macOS 12 or later, Apple silicon (arm64, M1 or newer), Xcode or Xcode Command Line Tools, C++17, and Apple's header-only metal-cpp distribution.
The shared confidence-connected implementation is adjusted to rely on standard std::abs overload resolution instead of explicit template arguments. This keeps the code portable across Apple clang/libc++ and GCC/libstdc++ without changing the intended numerical behavior.
Initial version of code included in this PR was written manually, with the final version having been reviewed and formatted with assistance of the GPT-5.5 large language model.
Current Metal backend limitations:
Resolves #2878.
Changes to Users
Checklist