Skip to content

Commit

Permalink
[BACKEND][CPU] Make the CPU backend buildable and runnable in Mac M1. (
Browse files Browse the repository at this point in the history
…#18)

Add header for unique_ptr in CPU launcher.
  • Loading branch information
Kuigesi authored and int3 committed Aug 28, 2024
1 parent a929180 commit 5ba8381
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/triton/runtime/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import contextlib
import sys
import platform
import io
import sysconfig
import os
Expand All @@ -20,6 +21,7 @@ def quiet():

def _build(name, src, srcdir, library_dirs, include_dirs, libraries):
suffix = sysconfig.get_config_var('EXT_SUFFIX')
system = platform.system()
so = os.path.join(srcdir, '{name}{suffix}'.format(name=name, suffix=suffix))
# try to avoid setuptools if possible
cc = os.environ.get("CC")
Expand All @@ -44,6 +46,9 @@ def _build(name, src, srcdir, library_dirs, include_dirs, libraries):
include_dirs = include_dirs + [srcdir, py_include_dir, *custom_backend_dirs]
# for -Wno-psabi, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111047
cc_cmd = [cc, src, "-O3", "-shared", "-fPIC", "-Wno-psabi", "-o", so]
# Use dynamic lookup to load Python library on Mac
if system == "Darwin":
cc_cmd += ["-undefined", "dynamic_lookup"]
cc_cmd += [f'-l{lib}' for lib in libraries]
cc_cmd += [f"-L{dir}" for dir in library_dirs]
cc_cmd += [f"-I{dir}" for dir in include_dirs if dir is not None]
Expand Down
1 change: 1 addition & 0 deletions third_party/cpu/backend/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def format_of(ty):
#include <optional>
#include <stdio.h>
#include <string>
#include <memory>
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <Python.h>
Expand Down

0 comments on commit 5ba8381

Please sign in to comment.