Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 114 additions & 1 deletion .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,119 @@ jobs:

python -m pytest -n auto -ra --pyargs dpnp.tests.tensor

test_examples_linux:
name: Test examples

needs: build

runs-on: ubuntu-latest
timeout-minutes: 60

defaults:
run:
shell: bash -el {0}

strategy:
matrix:
python: ['3.14']

env:
dpnp-repo-path: '${{ github.workspace }}/source/'
create-conda-channel-env: 'source/environments/create_conda_channel.yml'
channel-path: '${{ github.workspace }}/channel/'
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
ver-json-path: '${{ github.workspace }}/version.json'
examples-env-name: 'examples_test'

steps:
- name: Checkout DPNP repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: ${{ env.fetch-depth }}
path: ${{ env.dpnp-repo-path }}

- name: Download artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.package-name }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.pkg-path-in-channel }}

- name: Setup miniconda
id: setup_miniconda
continue-on-error: true
uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
use-mamba: 'true'
conda-remove-defaults: 'true'
environment-file: ${{ env.create-conda-channel-env }}
activate-environment: ${{ env.examples-env-name }}

- name: ReSetup miniconda
if: steps.setup_miniconda.outcome == 'failure'
uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
use-mamba: 'true'
conda-remove-defaults: 'true'
environment-file: ${{ env.create-conda-channel-env }}
activate-environment: ${{ env.examples-env-name }}

- name: Create conda channel
run: |
python -m conda_index ${{ env.channel-path }}

- name: Test conda channel
run: |
conda search ${{ env.package-name }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
cat ${{ env.ver-json-path }}

- name: Get package version
run: |
PACKAGE_VERSION=$(python -c "${{ env.ver-script-part1 }} ${{ env.ver-script-part2 }}")
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> "$GITHUB_ENV"

- name: Install dpnp
id: install_dpnp
continue-on-error: true
run: |
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.channels-list }}'

- name: ReInstall dpnp
if: steps.install_dpnp.outcome == 'failure'
run: |
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.channels-list }}'

- name: Install example requirements
run: |
mamba install pytest dpcpp_linux-64">=2026.0.0" cmake ninja scikit-build ${{ env.TEST_CHANNELS }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an option we can add a dedicated env file to dpnp/enviroments folder and install all the requirements in Setup miniconda step

env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.channels-list }}'

- name: List installed packages
run: mamba list

- name: Smoke test
run: |
python -c "import dpctl; dpctl.lsplatform()"
python -c "import dpnp; print(dpnp.__version__)"

- name: Build and run pybind11 examples
run: |
cd ${{ env.dpnp-repo-path }}/examples/pybind11
for d in */; do
pushd "$d" > /dev/null
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1
if [ -d tests ]; then
python -m pytest tests || exit 1
fi
popd > /dev/null
done

test_windows:
name: Test

Expand Down Expand Up @@ -451,7 +564,7 @@ jobs:
upload:
name: Upload

needs: [test_linux, test_windows]
needs: [test_linux, test_windows, test_examples_linux]

strategy:
fail-fast: false
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
_skbuild
build_cython
cython_debug
dpnp.egg-info
*.egg-info

# Byte-compiled / optimized / DLL files
__pycache__/
Expand All @@ -27,9 +27,13 @@ dpnp_pytest.*
# Build examples
example3

# moved cmake scripts
dpnp/resources/cmake

*dpnp_backend*
dpnp/include/dpnp/tensor/*.h
dpnp/**/*.cpython*.so
dpnp/**/*.pyd
*~
core
*.so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a pattern with ...*so already above. Do we need to be more specific here and to ignore only ones generated in example folder?

15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,21 @@ else()
message(FATAL_ERROR "Unsupported system.")
endif()

# install dpnp-config.cmake for find_package() support
install(
FILES ${CMAKE_SOURCE_DIR}/cmake/dpnp-config.cmake
DESTINATION dpnp/resources/cmake
)
install(FILES ${CMAKE_SOURCE_DIR}/cmake/dpnp-config.cmake DESTINATION lib/cmake/dpnp)
Comment on lines +331 to +335

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can reduce duplication:

Suggested change
install(
FILES ${CMAKE_SOURCE_DIR}/cmake/dpnp-config.cmake
DESTINATION dpnp/resources/cmake
)
install(FILES ${CMAKE_SOURCE_DIR}/cmake/dpnp-config.cmake DESTINATION lib/cmake/dpnp)
foreach(_dest IN ITEMS dpnp/resources/cmake lib/cmake/dpnp)
install(FILES ${CMAKE_SOURCE_DIR}/cmake/dpnp-config.cmake DESTINATION ${_dest})
endforeach()


# install dpnp4pybind11.hpp and usm_ndarray_constants.h into include folder
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/dpnp/include/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually means the recurses into ALL subdirs. But there is another rule at dpnp/CMakeLists.txt:147-156 which installs the Cython-generated headers from the build.
Thus the rule will grab dpnp/tensor/_usmarray.h and _usmarray_api.h and install them to <prefix>/dpnp/include/dpnp/tensor. Exactly the same as rules at dpnp/CMakeLists.txt:147-156 do.

So the same files might be written twice to the same location.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to specify explicitly:

install(FILES
    ${CMAKE_SOURCE_DIR}/dpnp/include/dpnp4pybind11.hpp
    ${CMAKE_SOURCE_DIR}/dpnp/include/usm_ndarray_constants.h
    DESTINATION dpnp/include)

or to add PATTERN "dpnp/tensor" EXCLUDE to the end of install command.

DESTINATION dpnp/include
FILES_MATCHING
REGEX "\\.(h|hpp)$"
)

# Define flags for CMAKE_BUILD_TYPE=Coverage
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_DEBUG} -O1 -g1 -DDEBUG")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} -O1 -g1 -DDEBUG")
Expand Down
63 changes: 63 additions & 0 deletions cmake/dpnp-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#.rst:
#
# Find the include directory for ``dpnp4pybind11.hpp`` and dpnp tensor kernels.
#
# This module sets the following variables:
#
# ``Dpnp_FOUND``
# True if DPNP was found.
# ``Dpnp_INCLUDE_DIR``
# The include directory needed to use dpnp.
# ``Dpnp_TENSOR_INCLUDE_DIR``
# The include directory for tensor kernels implementation.
# ``Dpnp_VERSION``
# The version of dpnp found.
#
# The module will also explicitly define two cache variables:
#
# ``Dpnp_INCLUDE_DIR``
# ``Dpnp_TENSOR_INCLUDE_DIR``
#

if(NOT Dpnp_FOUND)
find_package(Python 3.10 REQUIRED COMPONENTS Interpreter Development.Module)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have upper limit also?

Suggested change
find_package(Python 3.10 REQUIRED COMPONENTS Interpreter Development.Module)
find_package(Python 3.10...<3.15 REQUIRED COMPONENTS Interpreter Development.Module)


if(Python_EXECUTABLE)
execute_process(
COMMAND "${Python_EXECUTABLE}" -m dpnp --include-dir
OUTPUT_VARIABLE _dpnp_include_dir
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
execute_process(
COMMAND "${Python_EXECUTABLE}" -c "import dpnp; print(dpnp.__version__)"
OUTPUT_VARIABLE Dpnp_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
endif()

find_path(
Dpnp_INCLUDE_DIR
dpnp4pybind11.hpp
PATHS "${_dpnp_include_dir}" "${Python_INCLUDE_DIRS}"
PATH_SUFFIXES dpnp/include

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to use NO_DEFAULT_PATH here ?

)
get_filename_component(_dpnp_dir "${Dpnp_INCLUDE_DIR}" DIRECTORY)

find_path(Dpnp_TENSOR_INCLUDE_DIR kernels PATHS "${_dpnp_dir}/tensor/libtensor/include")

set(Dpnp_INCLUDE_DIRS ${Dpnp_INCLUDE_DIR})

# handle the QUIETLY and REQUIRED arguments and set Dpnp_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Dpnp
REQUIRED_VARS Dpnp_INCLUDE_DIR Dpnp_TENSOR_INCLUDE_DIR
VERSION_VAR Dpnp_VERSION
)

mark_as_advanced(Dpnp_INCLUDE_DIR)
mark_as_advanced(Dpnp_TENSOR_INCLUDE_DIR)
16 changes: 15 additions & 1 deletion dpnp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _dpnp_dir() -> str:

def get_include_dir() -> str:
"""Returns path to dpnp include directory containing dpnp4pybind11.hpp"""
return os.path.join(_dpnp_dir(), "backend", "include")
return os.path.join(_dpnp_dir(), "include")


def print_include_flags() -> None:
Expand All @@ -61,6 +61,13 @@ def print_tensor_include_flags() -> None:
print("-I " + libtensor_dir)


def print_cmake_dir() -> None:
"""Prints directory with dpnp-config.cmake"""
dpnp_dir = _dpnp_dir()
cmake_dir = os.path.join(dpnp_dir, "resources", "cmake")
print(cmake_dir)


def main() -> None:
"""Main entry-point."""
parser = argparse.ArgumentParser()
Expand All @@ -84,6 +91,11 @@ def main() -> None:
action="store_true",
help="Path to dpnp libtensor include directory.",
)
parser.add_argument(
"--cmakedir",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to test --cmakedir / Dpnp_ROOT in the example also?

action="store_true",
help="CMake module directory, ideal for setting -DDpnp_ROOT in CMake.",
)
args = parser.parse_args()
if not sys.argv[1:]:
parser.print_help()
Expand All @@ -95,6 +107,8 @@ def main() -> None:
print_tensor_include_flags()
if args.tensor_include_dir:
print(get_tensor_include_dir())
if args.cmakedir:
print_cmake_dir()


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/blas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ target_include_directories(
${python_module_name}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/blas/dot_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/memory_overlap.hpp"
#include "utils/output_validation.hpp"
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/fft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set_target_properties(
target_include_directories(
${python_module_name}
PRIVATE
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/indexing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ target_include_directories(
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/lapack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ target_include_directories(
${python_module_name}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/evd_batch_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <oneapi/mkl.hpp>
#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/type_dispatch.hpp"

Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/evd_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <oneapi/mkl.hpp>
#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/type_dispatch.hpp"

Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/evd_common_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/memory_overlap.hpp"
#include "utils/output_validation.hpp"
Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/gesv_common_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/memory_overlap.hpp"
#include "utils/output_validation.hpp"
Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/gesvd_common_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <oneapi/mkl.hpp>
#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/memory_overlap.hpp"
#include "utils/output_validation.hpp"
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/statistics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ target_include_directories(
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@

#pragma once

#include "ext/dispatch_table.hpp"
#include <pybind11/pybind11.h>
#include <sycl/sycl.hpp>

#include "dpnp4pybind11.hpp"

#include "ext/dispatch_table.hpp"

namespace statistics::sliding_window1d
{
struct SlidingDotProduct1d
Expand Down
Loading
Loading