Skip to content

Commit

Permalink
Merge branch 'master' into impl_unique
Browse files Browse the repository at this point in the history
  • Loading branch information
antonwolfy authored Aug 16, 2024
2 parents a0758d5 + 6c1bf98 commit 82cb5ec
Show file tree
Hide file tree
Showing 55 changed files with 3,033 additions and 959 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @antonwolfy @npolina4 @vlad-perevezentsev @vtavana
5 changes: 3 additions & 2 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ env:
test_umath.py
test_usm_type.py
third_party/cupy/core_tests
third_party/cupy/fft_tests
third_party/cupy/creation_tests
third_party/cupy/indexing_tests/test_indexing.py
third_party/cupy/lib_tests
Expand Down Expand Up @@ -144,13 +145,13 @@ jobs:
run: conda build --no-test --python ${{ matrix.python }} --numpy 1.24 ${{ env.CHANNELS }} conda-recipe

- name: Upload artifact
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2

- name: Upload wheels artifact
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
path: ${{ env.WHEELS_OUTPUT_FOLDER }}${{ env.PACKAGE_NAME }}-*.whl
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/openssf-scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: SARIF file
path: results.sarif
retention-days: 14

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
uses: github/codeql-action/upload-sarif@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0
with:
sarif_file: results.sarif
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ repos:
[
"-rn", # Only display messages
"-sn", # Don't display the score
"--disable=c-extension-no-member",
"--disable=import-error",
"--disable=redefined-builtin",
"--disable=unused-wildcard-import"
Expand Down
60 changes: 58 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ include(GNUInstallDirs)
include(FetchContent)
FetchContent_Declare(
pybind11
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.1.tar.gz
URL_HASH SHA256=51631e88960a8856f9c497027f55c9f2f9115cafb08c0005439838a05ba17bfc
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.3.tar.gz
URL_HASH SHA256=6e7a84ec241544f2f5e30c7a82c09c81f0541dd14e9d9ef61051e07105f9c445
)
FetchContent_MakeAvailable(pybind11)

Expand All @@ -67,6 +67,62 @@ find_package(Dpctl REQUIRED)
message(STATUS "Dpctl_INCLUDE_DIR=" ${Dpctl_INCLUDE_DIR})
message(STATUS "Dpctl_TENSOR_INCLUDE_DIR=" ${Dpctl_TENSOR_INCLUDE_DIR})

option(DPNP_TARGET_CUDA
"Build DPNP to target CUDA devices"
OFF
)
option(DPNP_USE_ONEMKL_INTERFACES
"Build DPNP with oneMKL Interfaces"
OFF
)
set(_dpnp_sycl_targets)
set(_use_onemkl_interfaces_cuda OFF)
if ("x${DPNP_SYCL_TARGETS}" STREQUAL "x")
if(DPNP_TARGET_CUDA)
set(_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown")
set(_use_onemkl_interfaces_cuda ON)
else()
if(DEFINED ENV{DPNP_TARGET_CUDA})
set(_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown")
set(_use_onemkl_interfaces_cuda ON)
endif()
endif()
else()
set(_dpnp_sycl_targets ${DPNP_SYCL_TARGETS})
endif()

if(_dpnp_sycl_targets)
message(STATUS "Compiling for -fsycl-targets=${_dpnp_sycl_targets}")
endif()

set(_use_onemkl_interfaces OFF)
if(DPNP_USE_ONEMKL_INTERFACES)
set(_use_onemkl_interfaces ON)
else()
if(DEFINED ENV{DPNP_USE_ONEMKL_INTERFACES})
set(_use_onemkl_interfaces ON)
endif()
endif()

if(_use_onemkl_interfaces)
set(BUILD_FUNCTIONAL_TESTS False)
set(BUILD_EXAMPLES False)
if(_use_onemkl_interfaces_cuda)
# set(ENABLE_CUBLAS_BACKEND True)
set(ENABLE_CUSOLVER_BACKEND True)
set(ENABLE_CUFFT_BACKEND True)
# set(ENABLE_CURAND_BACKEND True)
set(ENABLE_MKLGPU_BACKEND False)
set(ENABLE_MKLCPU_BACKEND False)
endif()
FetchContent_Declare(
onemkl_interfaces_library
GIT_REPOSITORY https://github.com/oneapi-src/oneMKL.git
GIT_TAG f2d2dcb4213a435bb60fbb88320c5f24892423ce
)
FetchContent_MakeAvailable(onemkl_interfaces_library)
endif()

if(WIN32)
string(CONCAT WARNING_FLAGS
"-Wall "
Expand Down
1 change: 1 addition & 0 deletions doc/reference/logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Comparison
dpnp.allclose
dpnp.isclose
dpnp.array_equal
dpnp.array_equiv
dpnp.greater
dpnp.greater_equal
dpnp.less
Expand Down
21 changes: 20 additions & 1 deletion dpnp/backend/extensions/fft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ set(_module_src
pybind11_add_module(${python_module_name} MODULE ${_module_src})
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src})

if(_dpnp_sycl_targets)
# make fat binary
target_compile_options(
${python_module_name}
PRIVATE
-fsycl-targets=${_dpnp_sycl_targets}
)
target_link_options(
${python_module_name}
PRIVATE
-fsycl-targets=${_dpnp_sycl_targets}
)
endif()

if (WIN32)
if (${CMAKE_VERSION} VERSION_LESS "3.27")
# this is a work-around for target_link_options inserting option after -link option, cause
Expand Down Expand Up @@ -68,7 +82,12 @@ if (DPNP_GENERATE_COVERAGE)
target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
endif()

target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::DFT)
if(_use_onemkl_interfaces)
target_link_libraries(${python_module_name} PUBLIC onemkl)
target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMKL_INTERFACES)
else()
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::DFT)
endif()

install(TARGETS ${python_module_name}
DESTINATION "dpnp/backend/extensions/fft"
Expand Down
36 changes: 22 additions & 14 deletions dpnp/backend/extensions/fft/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,32 @@ class DescriptorWrapper
// config_param::PLACEMENT
bool get_in_place()
{
// TODO: replace when MKLD-10506 is implemented
// mkl_dft::config_value placement;
#if defined(USE_ONEMKL_INTERFACES)
mkl_dft::config_value placement;
descr_.get_value(mkl_dft::config_param::PLACEMENT, &placement);
return (placement == mkl_dft::config_value::INPLACE);
#else
// TODO: remove branch when MKLD-10506 is implemented
DFTI_CONFIG_VALUE placement;

descr_.get_value(mkl_dft::config_param::PLACEMENT, &placement);
// TODO: replace when MKLD-10506 is implemented
// return (placement == mkl_dft::config_value::INPLACE);
return (placement == DFTI_CONFIG_VALUE::DFTI_INPLACE);
#endif // USE_ONEMKL_INTERFACES
}

void set_in_place(const bool &in_place_request)
{
// TODO: replace when MKLD-10506 is implemented
// descr_.set_value(mkl_dft::config_param::PLACEMENT, (in_place_request)
// ? mkl_dft::config_value::INPLACE :
// mkl_dft::config_value::NOT_INPLACE);
#if defined(USE_ONEMKL_INTERFACES)
descr_.set_value(mkl_dft::config_param::PLACEMENT,
(in_place_request)
? mkl_dft::config_value::INPLACE
: mkl_dft::config_value::NOT_INPLACE);
#else
// TODO: remove branch when MKLD-10506 is implemented
descr_.set_value(mkl_dft::config_param::PLACEMENT,
(in_place_request)
? DFTI_CONFIG_VALUE::DFTI_INPLACE
: DFTI_CONFIG_VALUE::DFTI_NOT_INPLACE);
#endif // USE_ONEMKL_INTERFACES
}

// config_param::PRECISION
Expand All @@ -221,14 +227,16 @@ class DescriptorWrapper
// config_param::COMMIT_STATUS
bool is_committed()
{
// TODO: replace when MKLD-10506 is implemented
// mkl_dft::config_value committed;
#if defined(USE_ONEMKL_INTERFACES)
mkl_dft::config_value committed;
descr_.get_value(mkl_dft::config_param::COMMIT_STATUS, &committed);
return (committed == mkl_dft::config_value::COMMITTED);
#else
// TODO: remove branch when MKLD-10506 is implemented
DFTI_CONFIG_VALUE committed;

descr_.get_value(mkl_dft::config_param::COMMIT_STATUS, &committed);
// TODO: replace when MKLD-10506 is implemented
// return (committed == mkl_dft::config_value::COMMITTED);
return (committed == DFTI_CONFIG_VALUE::DFTI_COMMITTED);
#endif // USE_ONEMKL_INTERFACES
}

private:
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/fft/out_of_place.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// THE POSSIBILITY OF SUCH DAMAGE.
//*****************************************************************************

#include <oneapi/mkl/dfti.hpp>
#include <oneapi/mkl.hpp>
#include <sycl/sycl.hpp>

#include <dpctl4pybind11.hpp>
Expand Down
21 changes: 20 additions & 1 deletion dpnp/backend/extensions/lapack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ set(_module_src
pybind11_add_module(${python_module_name} MODULE ${_module_src})
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src})

if(_dpnp_sycl_targets)
# make fat binary
target_compile_options(
${python_module_name}
PRIVATE
-fsycl-targets=${_dpnp_sycl_targets}
)
target_link_options(
${python_module_name}
PRIVATE
-fsycl-targets=${_dpnp_sycl_targets}
)
endif()

if (WIN32)
if (${CMAKE_VERSION} VERSION_LESS "3.27")
# this is a work-around for target_link_options inserting option after -link option, cause
Expand Down Expand Up @@ -85,7 +99,12 @@ if (DPNP_GENERATE_COVERAGE)
target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
endif()

target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::LAPACK)
if(_use_onemkl_interfaces)
target_link_libraries(${python_module_name} PUBLIC onemkl)
target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMKL_INTERFACES)
else()
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::LAPACK)
endif()

install(TARGETS ${python_module_name}
DESTINATION "dpnp/backend/extensions/lapack"
Expand Down
6 changes: 6 additions & 0 deletions dpnp/backend/extensions/lapack/gesv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ static sycl::event gesv_impl(sycl::queue &exec_q,
char *in_b,
const std::vector<sycl::event> &depends)
{
#if defined(USE_ONEMKL_INTERFACES)
// Temporary flag for build only
// FIXME: Need to implement by using lapack::getrf and lapack::getrs
std::logic_error("Not Implemented");
#else
type_utils::validate_type_for_device<T>(exec_q);

T *a = reinterpret_cast<T *>(in_a);
Expand Down Expand Up @@ -129,6 +134,7 @@ static sycl::event gesv_impl(sycl::queue &exec_q,
});

return ht_ev;
#endif // USE_ONEMKL_INTERFACES
}

std::pair<sycl::event, sycl::event>
Expand Down
1 change: 1 addition & 0 deletions dpnp/backend/extensions/ufunc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(_elementwise_sources
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/degrees.cpp
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fabs.cpp
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fix.cpp
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/float_power.cpp
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fmax.cpp
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fmin.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "degrees.hpp"
#include "fabs.hpp"
#include "fix.hpp"
#include "float_power.hpp"
#include "fmax.hpp"
#include "fmin.hpp"
Expand All @@ -45,6 +46,7 @@ void init_elementwise_functions(py::module_ m)
{
init_degrees(m);
init_fabs(m);
init_fix(m);
init_float_power(m);
init_fmax(m);
init_fmin(m);
Expand Down
Loading

0 comments on commit 82cb5ec

Please sign in to comment.