-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
59 lines (55 loc) · 1.89 KB
/
Copy pathsetup.py
File metadata and controls
59 lines (55 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from Cython.Build import cythonize
import pybind11
import numpy
import sys
# OpenMP linkage
# Note: different platforms and compilers require different arguments for OMP linkage.
# For example, on windows with the MSVC compiler, it requires argument '/openmp',
# while on macOS it might require '-Xclang -fopenmp -lomp' (plus additional external
# installations of the OpenMP runtime library), and under some clang versions on
# linux, might require additional linkage to 'libomp'.
# For simplicity, this skips linkage to OpenMP on platforms other than windows and linux
# (i.e. will not use OpenMP on macOS). Note that compiling on windows with the mingw
# compiler requires changing the argument from '/openmp' to '-fopenmp'.
# Docs: https://scikit-learn.org/stable/developers/advanced_installation.html#platform-specific-instructions
args_openmp = []
if sys.platform == "linux":
args_openmp = ["-fopenmp"]
elif sys.platform == "win32":
args_openmp = ["/openmp"]
# === 1. Pybind11 Extension ===
pybind11_ext = Extension(
"utils_pybind",
["utils_pybind.cpp"],
include_dirs=[
pybind11.get_include(),
numpy.get_include(),
".",
],
extra_compile_args=args_openmp,
extra_link_args=args_openmp,
language="c++"
)
# === 2. Cython Extension ===
cython_exts = cythonize([
Extension(
"utils_cython",
["utils_cython.pyx"],
include_dirs=[
numpy.get_include()
],
extra_compile_args=args_openmp,
extra_link_args=args_openmp,
language="c++"
)
])
# === 3. Setup ===
setup(
name="syrk_gemv_acceleration",
version="0.1",
description="Project combining pybind11 and Cython extensions",
ext_modules=[pybind11_ext] + cython_exts,
zip_safe=False,
)