Skip to content

Commit 3b63391

Browse files
committed
Build script for skbuild and adding CMakeLists.txt
No need for *.cl and *.spir in MANIFEST Fix ninja problem Add 2nd level CMakeLists Add build-system to toml Adding CMakeLists for the runtime
1 parent 4d332e8 commit 3b63391

File tree

6 files changed

+221
-3
lines changed

6 files changed

+221
-3
lines changed

CMakeLists.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR)
2+
3+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
4+
cmake_policy(SET CMP0135 NEW)
5+
endif()
6+
7+
project(numba-dpex
8+
DESCRIPTION "An extension for Numba to add data-parallel offload capability"
9+
VERSION $ENV{NUMBA_DPEX_VERSION}
10+
)
11+
12+
13+
# set(CMAKE_CXX_STANDARD 17)
14+
# set(CMAKE_CXX_STANDARD_REQUIRED True)
15+
# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
16+
# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
17+
18+
# execute_process(
19+
# COMMAND python -m dpctl --cmakedir
20+
# OUTPUT_VARIABLE DPCTL_MODULE_PATH
21+
# OUTPUT_STRIP_TRAILING_WHITESPACE)
22+
23+
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_MODULE_PATH})
24+
25+
# find_package(IntelDPCPP REQUIRED)
26+
# find_package(TBB REQUIRED)
27+
# find_package(IntelDPCPP REQUIRED)
28+
29+
# set(MKL_ARCH "intel64")
30+
# set(MKL_LINK "dynamic")
31+
# set(MKL_INTERFACE_FULL "intel_ilp64")
32+
# set(MKL_THREADING "tbb_thread")
33+
# find_package(MKL REQUIRED)
34+
35+
# set(ONEDPL_PAR_BACKEND tbb)
36+
# find_package(oneDPL REQUIRED)
37+
38+
# include(GNUInstallDirs)
39+
40+
# find_package(PythonExtensions REQUIRED)
41+
# find_package(NumPy REQUIRED)
42+
43+
# find_package(Dpctl REQUIRED)
44+
45+
# message(STATUS "Dpctl_INCLUDE_DIRS=" ${Dpctl_INCLUDE_DIRS})
46+
# message(STATUS "Dpctl_TENSOR_INCLUDE_DIR=" ${Dpctl_TENSOR_INCLUDE_DIR})
47+
48+
# install(TARGETS ${PROJECT_NAME}
49+
# FILE_SET DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
50+
add_subdirectory(numba_dpex)

MANIFEST.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
include MANIFEST.in
22
include README.md setup.py LICENSE
33

4-
recursive-include numba_dpex *.cl
5-
recursive-include numba_dpex *.spir
6-
74
include versioneer.py
85
include numba_dpex/_version.py
96

numba_dpex/CMakeLists.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
install(DIRECTORY core
2+
DESTINATION numba_dpex
3+
FILES_MATCHING PATTERN "*.py")
4+
5+
install(DIRECTORY dpctl_iface
6+
DESTINATION numba_dpex
7+
FILES_MATCHING PATTERN "*.py")
8+
9+
install(DIRECTORY dpnp_iface
10+
DESTINATION numba_dpex
11+
FILES_MATCHING PATTERN "*.py")
12+
13+
install(DIRECTORY examples
14+
DESTINATION numba_dpex
15+
FILES_MATCHING PATTERN "*.py")
16+
17+
install(DIRECTORY numba_patches
18+
DESTINATION numba_dpex
19+
FILES_MATCHING PATTERN "*.py")
20+
21+
install(DIRECTORY ocl
22+
DESTINATION numba_dpex
23+
FILES_MATCHING PATTERN "*.py")
24+
25+
install(DIRECTORY tests
26+
DESTINATION numba_dpex
27+
FILES_MATCHING PATTERN "*.py")
28+
29+
install(DIRECTORY utils
30+
DESTINATION numba_dpex
31+
FILES_MATCHING PATTERN "*.py")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
project(_dpexrt_python
2+
DESCRIPTION "A Python C extension for numba-dpex runtime."
3+
VERSION $ENV{NUMBA_DPEX_VERSION}
4+
)

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,12 @@ VCS = "git"
4444
style = "pep440"
4545
versionfile_source = "numba_dpex/_version.py"
4646
parentdir_prefix = ""
47+
48+
[build-system]
49+
requires = [
50+
"setuptools>=42",
51+
"scikit-build>=0.13",
52+
"cmake>=3.18",
53+
"ninja",
54+
]
55+
build-backend = "setuptools.build_meta"

setup-skbuild.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import importlib.machinery as imm
2+
import os
3+
import shutil
4+
import sys
5+
import sysconfig
6+
7+
import dpctl
8+
import numba
9+
import numpy
10+
from setuptools import Extension, find_packages
11+
from skbuild import setup
12+
13+
import versioneer
14+
15+
16+
def to_cmake_format(version):
17+
version = version.strip()
18+
parts = version.split("+")
19+
tag, dist = parts[0], parts[1].split(".")[0]
20+
return tag + "." + dist
21+
22+
23+
"""
24+
Test if system is WIN
25+
"""
26+
is_windows = sys.platform.startswith("win") or sys.platform.startswith("cyg")
27+
28+
29+
"""
30+
Set compiler
31+
"""
32+
cc = "icx.exe" if is_windows else "icx"
33+
cxx = "icpx.exe" if is_windows else "icpx"
34+
35+
icx = shutil.which(cc)
36+
if icx:
37+
os.environ["CC"] = cc
38+
39+
icpx = shutil.which(cxx)
40+
if icpx:
41+
os.environ["CXX"] = cxx
42+
43+
44+
"""
45+
Get the project version
46+
"""
47+
__version__ = versioneer.get_version()
48+
os.environ["NUMBA_DPEX_VERSION"] = to_cmake_format(str(__version__))
49+
50+
51+
"""
52+
Set project auxilary data like readme and licence files
53+
"""
54+
with open("README.md") as f:
55+
__readme_file__ = f.read()
56+
57+
58+
def get_ext_modules():
59+
ext_modules = []
60+
61+
try:
62+
import dpnp
63+
except ImportError:
64+
raise ImportError("dpnp should be installed to build numba-dpex")
65+
66+
dpctl_runtime_library_dirs = []
67+
68+
if not is_windows:
69+
dpctl_runtime_library_dirs.append(os.path.dirname(dpctl.__file__))
70+
71+
ext_dpexrt_python = Extension(
72+
name="numba_dpex.core.runtime._dpexrt_python",
73+
sources=[
74+
"numba_dpex/core/runtime/_dpexrt_python.c",
75+
"numba_dpex/core/runtime/_nrt_helper.c",
76+
"numba_dpex/core/runtime/_nrt_python_helper.c",
77+
],
78+
libraries=["DPCTLSyclInterface"],
79+
library_dirs=[os.path.dirname(dpctl.__file__)],
80+
runtime_library_dirs=dpctl_runtime_library_dirs,
81+
include_dirs=[
82+
sysconfig.get_paths()["include"],
83+
numba.extending.include_path(),
84+
numpy.get_include(),
85+
dpctl.get_include(),
86+
],
87+
)
88+
89+
ext_modules += [ext_dpexrt_python]
90+
91+
return ext_modules
92+
93+
94+
setup(
95+
name="numba-dpex",
96+
version=__version__,
97+
description="An extension for Numba to add data-parallel offload capability",
98+
long_description=__readme_file__,
99+
long_description_content_type="text/markdown",
100+
license="Apache 2.0",
101+
classifiers=[
102+
"Development Status :: 4 - Beta",
103+
"Environment :: GPU",
104+
"Environment :: Plugins",
105+
"Intended Audience :: Developers",
106+
"License :: OSI Approved :: Apache 2.0",
107+
"Operating System :: OS Independent",
108+
"Programming Language :: Python :: 3",
109+
"Programming Language :: Python :: Implementation :: CPython",
110+
"Topic :: Software Development :: Compilers",
111+
],
112+
keywords="sycl python3 numba numpy intel mkl oneapi gpu dpcpp",
113+
platforms=["Linux", "Windows"],
114+
author="Intel Corporation",
115+
url="https://github.com/IntelPython/numba-dpex",
116+
install_requires=["numba >={}".format("0.57"), "dpctl", "packaging"],
117+
packages=find_packages(["numba_dpex", "numba_dpex.*"]),
118+
# package_data={
119+
# "dpnp": [
120+
# "libdpnp_backend_c.so",
121+
# "dpnp_backend_c.lib",
122+
# "dpnp_backend_c.dll",
123+
# ]
124+
# },
125+
include_package_data=True,
126+
zip_safe=False,
127+
)

0 commit comments

Comments
 (0)