-
Notifications
You must be signed in to change notification settings - Fork 32
scikit-build setup.py for numba-dpex #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
diptorupd
merged 2 commits into
IntelPython:main
from
chudur-budur:refac/new-setup-skbuild
Aug 22, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#[=======================================================================[.rst: | ||
numba_dpex | ||
----------- | ||
|
||
A cmake file to compile the ``_dpexrt_python`` Python C extension for | ||
``numba_dpex``. You can build this component locally in-place by invoking these | ||
commands: | ||
|
||
.. code-block:: cmake | ||
~$ cmake . | ||
~$ cmake --build . --verbose | ||
|
||
Once compiled, the _dpexrt_python library will be in ``numba_dpex/core/runtime`` | ||
folder. | ||
|
||
This ``CMakeLists.txt`` file will be used by ``setup.py``. | ||
#]=======================================================================] | ||
|
||
cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR) | ||
|
||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24") | ||
cmake_policy(SET CMP0135 NEW) | ||
endif() | ||
|
||
message(STATUS "NUMBA_DPEX_VERSION=" "${NUMBA_DPEX_VERSION}") | ||
|
||
project(numba-dpex | ||
DESCRIPTION "An extension for Numba to add data-parallel offload capability" | ||
VERSION ${NUMBA_DPEX_VERSION} | ||
) | ||
|
||
if(IS_INSTALL) | ||
install(DIRECTORY numba_dpex | ||
DESTINATION ${CMAKE_INSTALL_PREFIX} | ||
FILES_MATCHING PATTERN "*.py") | ||
endif() | ||
|
||
add_subdirectory(numba_dpex) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,5 @@ dependencies: | |
- pytest-cov | ||
- pytest-xdist | ||
- pexpect | ||
- scikit-build>=0.15* | ||
- cmake>=3.26* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
if(IS_INSTALL) | ||
install(DIRECTORY core | ||
DESTINATION numba_dpex | ||
FILES_MATCHING PATTERN "*.py") | ||
endif() | ||
|
||
add_subdirectory(core/runtime) | ||
|
||
if(IS_INSTALL) | ||
install(DIRECTORY dpctl_iface | ||
DESTINATION numba_dpex | ||
FILES_MATCHING PATTERN "*.py") | ||
endif() | ||
|
||
if(IS_INSTALL) | ||
install(DIRECTORY dpnp_iface | ||
DESTINATION numba_dpex | ||
FILES_MATCHING PATTERN "*.py") | ||
endif() | ||
|
||
if(IS_INSTALL) | ||
install(DIRECTORY examples | ||
DESTINATION numba_dpex) | ||
endif() | ||
|
||
if(IS_INSTALL) | ||
install(DIRECTORY numba_patches | ||
DESTINATION numba_dpex | ||
FILES_MATCHING PATTERN "*.py") | ||
endif() | ||
|
||
if(IS_INSTALL) | ||
install(DIRECTORY ocl | ||
DESTINATION numba_dpex | ||
FILES_MATCHING PATTERN "*.py") | ||
endif() | ||
|
||
if(IS_INSTALL) | ||
install(DIRECTORY tests | ||
DESTINATION numba_dpex | ||
FILES_MATCHING PATTERN "*.py") | ||
endif() | ||
|
||
if(IS_INSTALL) | ||
install(DIRECTORY utils | ||
DESTINATION numba_dpex | ||
FILES_MATCHING PATTERN "*.py") | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#[=======================================================================[.rst: | ||
_dpexrt_python | ||
--------------- | ||
|
||
A cmake file to compile the ``_dpexrt_python`` Python C extension for | ||
``numba_dpex``. You can build this component locally in-place by invoking these | ||
commands: | ||
|
||
.. code-block:: cmake | ||
~$ cmake . | ||
~$ cmake --build . --verbose | ||
|
||
Once compiled, the _dpexrt_python library will be in ``numba_dpex/core/runtime`` | ||
folder. | ||
#]=======================================================================] | ||
|
||
cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR) | ||
|
||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24") | ||
cmake_policy(SET CMP0135 NEW) | ||
endif() | ||
|
||
project(_dpexrt_python | ||
DESCRIPTION "A Python C extension for numba-dpex runtime." | ||
) | ||
|
||
# Get numba include path | ||
if(NOT DEFINED Numba_INCLUDE_DIRS) | ||
execute_process( | ||
COMMAND python -c "import numba; print(numba.extending.include_path());" | ||
OUTPUT_VARIABLE Numba_INCLUDE_DIRS | ||
RESULT_VARIABLE RET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
if(RET EQUAL "1") | ||
message(FATAL_ERROR "Module \'numba\' not found.") | ||
endif() | ||
endif() | ||
|
||
# Get dpctl library path | ||
if(NOT DEFINED DPCTL_LIBRARY_PATH) | ||
execute_process( | ||
COMMAND python -c "import dpctl; import os; print(os.path.dirname(dpctl.__file__));" | ||
OUTPUT_VARIABLE DPCTL_LIBRARY_PATH | ||
RESULT_VARIABLE RET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
if(RET EQUAL "1") | ||
message(FATAL_ERROR "Module \'dpctl\' not found.") | ||
endif() | ||
endif() | ||
|
||
# Update CMAKE_MODULE_PATH | ||
set(DPCTL_MODULE_PATH ${DPCTL_LIBRARY_PATH}/resources/cmake) | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_MODULE_PATH}) | ||
|
||
# Get scikit-build path | ||
if(NOT DEFINED SKBUILD_PATH) | ||
execute_process( | ||
COMMAND python -c "import skbuild; print(skbuild.__path__[0]);" | ||
OUTPUT_VARIABLE SKBUILD_PATH | ||
RESULT_VARIABLE RET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
if(RET EQUAL "1") | ||
message(FATAL_ERROR "Module \'skbuild\' not found.") | ||
endif() | ||
endif() | ||
|
||
# Update CMAKE_MODULE_PATH | ||
set(SKBUILD_MODULE_PATH ${SKBUILD_PATH}/resources/cmake) | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SKBUILD_MODULE_PATH}) | ||
|
||
# Check CMAKE_MODULE_PATH | ||
message(STATUS "CMAKE_MODULE_PATH=" "${CMAKE_MODULE_PATH}") | ||
|
||
# Add packages | ||
find_package(PythonLibs REQUIRED) | ||
find_package(PythonExtensions REQUIRED) | ||
find_package(NumPy REQUIRED) | ||
find_package(Dpctl REQUIRED) | ||
|
||
# Includes | ||
include(GNUInstallDirs) | ||
include_directories(${Python_INCLUDE_DIRS}) | ||
include_directories(${NumPy_INCLUDE_DIRS}) | ||
include_directories(${Numba_INCLUDE_DIRS}) | ||
include_directories(${Dpctl_INCLUDE_DIRS}) | ||
include_directories(.) | ||
|
||
# Source files, *.c | ||
file(GLOB SOURCES "*.c") | ||
|
||
# Link dpctl library path with -L | ||
link_directories(${DPCTL_LIBRARY_PATH}) | ||
|
||
# Output static library, *.so or *.dll | ||
add_library(${PROJECT_NAME} MODULE ${SOURCES}) | ||
|
||
# Link the static library to python libraries and DPCTLSyclInterface | ||
target_link_libraries(${PROJECT_NAME} ${Python_LIBRARIES}) | ||
target_link_libraries(${PROJECT_NAME} DPCTLSyclInterface) | ||
|
||
# Build python extension module | ||
python_extension_module(${PROJECT_NAME}) | ||
|
||
# If IS_DEVELOP, copy back the target into numba_dpex/core/runtime | ||
if(IS_DEVELOP) | ||
add_custom_command( | ||
TARGET ${PROJECT_NAME} | ||
POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy | ||
${CMAKE_BINARY_DIR}/numba_dpex/core/runtime/*.so | ||
${CMAKE_SOURCE_DIR}/numba_dpex/core/runtime/ | ||
) | ||
endif() | ||
|
||
# Install | ||
install( | ||
TARGETS ${PROJECT_NAME} LIBRARY DESTINATION numba_dpex/core/runtime | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from . import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.