Skip to content

Build of backend library with custom math lib and dpl #987

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
merged 2 commits into from
Oct 5, 2021
Merged
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
6 changes: 3 additions & 3 deletions 0.build.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash
THEDIR=$(dirname $(readlink -e ${BASH_SOURCE[0]}))

. ${THEDIR}/0.env.sh
# . ${THEDIR}/0.env.sh
cd ${THEDIR}

export DPNP_DEBUG=1

python setup.py clean
python setup.py build_clib
DPLROOT=/opt/intel/oneapi/dpl/latest python setup.py build_clib

# inplace build
python setup.py build_ext --inplace
CC=dpcpp python setup.py build_ext --inplace

# development build. Root privileges needed
# python setup.py develop
Expand Down
7 changes: 0 additions & 7 deletions conda-recipe/activate_env.sh

This file was deleted.

4 changes: 2 additions & 2 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# if ONEAPI_ROOT is specified (use all from it)
if [ -n "${ONEAPI_ROOT}" ]; then
export DPCPPROOT=${ONEAPI_ROOT}/compiler/latest
# TODO uncomment when CI will be changed
# export MKLROOT=${ONEAPI_ROOT}/mkl/latest
export MKLROOT=${ONEAPI_ROOT}/mkl/latest
export TBBROOT=${ONEAPI_ROOT}/tbb/latest
export DPLROOT=${ONEAPI_ROOT}/dpl/latest
fi

# if DPCPPROOT is specified (work with custom DPCPP)
Expand Down
5 changes: 3 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ build:
number: {{ GIT_DESCRIBE_NUMBER }}
include_recipe: False
script_env:
- _ONEAPI_ROOT # renamed for ignore in CI
- _DPCPPROOT # renamed for ignore in CI
- ONEAPI_ROOT
- DPCPPROOT
- MKLROOT
- TBBROOT
- DPLROOT
- WHEELS_OUTPUT_FOLDER

test:
Expand Down
4 changes: 2 additions & 2 deletions conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# if ONEAPI_ROOT is specified (use all from it)
if [ -n "${ONEAPI_ROOT}" ]; then
export DPCPPROOT=${ONEAPI_ROOT}/compiler/latest
# TODO uncomment when CI will be changed
# export MKLROOT=${ONEAPI_ROOT}/mkl/latest
export MKLROOT=${ONEAPI_ROOT}/mkl/latest
export TBBROOT=${ONEAPI_ROOT}/tbb/latest
export DPLROOT=${ONEAPI_ROOT}/dpl/latest
fi

# if DPCPPROOT is specified (work with custom DPCPP)
Expand Down
12 changes: 2 additions & 10 deletions dpnp/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
# -----------------------------------------------------------------------------------------------
if(DEFINED ENV{ONEAPI_ROOT})
set(DPNP_ONEAPI_ROOT "$ENV{ONEAPI_ROOT}" CACHE PATH "Folder contains oneapi tool set")
else()
if(UNIX)
set(DPNP_ONEAPI_ROOT "/opt/intel/oneapi" CACHE PATH "Folder contains oneapi tool set")
elseif(WIN32)
set(DPNP_ONEAPI_ROOT "C:/Program Files (x86)/Intel/oneAPI" CACHE PATH "Folder contains oneapi tool set")
else()
message(FATAL_ERROR "Unsupported system ${CMAKE_SYSTEM}")
endif()
endif()

option(DPNP_STATIC_LIB_ENABLE "Enable build DPNP static library" FALSE)
Expand Down Expand Up @@ -253,8 +245,8 @@ target_link_libraries(dpnp_backend_c PUBLIC ${DPNP_MATHLIB_DEP_LIBS})

# Parallel STL from DPC++
if(NOT WIN32)
find_package(PSTL REQUIRED)
target_include_directories(dpnp_backend_c PUBLIC ${PSTL_INCLUDE_DIR})
find_package(DPL REQUIRED)
target_include_directories(dpnp_backend_c PUBLIC ${DPL_INCLUDE_DIR})
endif()

# SYCL queue manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,30 @@
# *****************************************************************************

# The following variables are optionally searched for defaults
# PSTL_ROOT_DIR: Base directory where all components are found
# DPLROOT: Environment variable to specify custom search place
# ONEAPI_ROOT: Environment variable to specify search place from oneAPI
#
# The following are set after configuration is done:
# PSTL_FOUND
# PSTL_INCLUDE_DIR
# DPL_FOUND
# DPL_INCLUDE_DIR

include(FindPackageHandleStandardArgs)

set(PSTL_ROOT_DIR
"${DPNP_ONEAPI_ROOT}/dpl"
CACHE PATH "Folder contains PSTL headers")
set(DPNP_ONEAPI_DPL "$ENV{DPNP_ONEAPI_ROOT}/dpl/latest" CACHE PATH "Folder contains DPL files from ONEAPI_ROOT")

if(DEFINED ENV{DPLROOT})
set(DPNP_DPLROOT "$ENV{DPLROOT}" CACHE PATH "Folder contains DPL files from DPLROOT")
endif()

find_path(
PSTL_INCLUDE_DIR oneapi/dpl/algorithm
HINTS ENV CONDA_PREFIX ${PSTL_ROOT_DIR} # search order is important
PATH_SUFFIXES include latest/linux/include
DOC "Path to PSTL include files")
DPL_INCLUDE_DIR oneapi/dpl/algorithm
HINTS ${DPNP_DPLROOT} ${DPNP_ONEAPI_DPL} ENV CONDA_PREFIX ENV PREFIX # search order is important
PATH_SUFFIXES include linux/include
DOC "Path to DPL include files")

find_package_handle_standard_args(PSTL DEFAULT_MSG PSTL_INCLUDE_DIR)
find_package_handle_standard_args(DPL DEFAULT_MSG DPL_INCLUDE_DIR)

if(PSTL_FOUND)
message(STATUS "Found PSTL: (include: ${PSTL_INCLUDE_DIR})")
# mark_as_advanced(PSTL_ROOT_DIR PSTL_INCLUDE_DIR)
if(DPL_FOUND)
message(STATUS "Found DPL: (include: ${DPL_INCLUDE_DIR})")
# mark_as_advanced(DPNP_DPLROOT DPL_INCLUDE_DIR)
endif()
21 changes: 12 additions & 9 deletions dpnp/backend/cmake/Modules/FindMathLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
# *****************************************************************************

# The following variables are optionally searched for defaults
# MATHLIB_ROOT_DIR: Base directory where all components are found
# MKLROOT: Environment variable to specify custom search place
# ONEAPI_ROOT: Environment variable to specify search place from oneAPI
#
# The following are set after configuration is done:
# MATHLIB_FOUND
Expand All @@ -33,9 +34,11 @@

include(FindPackageHandleStandardArgs)

set(MATHLIB_ROOT_DIR
"${DPNP_ONEAPI_ROOT}/mkl"
CACHE PATH "Folder contains mathlib")
set(DPNP_ONEAPI_MKL "$ENV{DPNP_ONEAPI_ROOT}/mkl/latest" CACHE PATH "Folder contains Math Lib files from ONEAPI_ROOT")

if(DEFINED ENV{MKLROOT})
set(DPNP_MKLROOT "$ENV{MKLROOT}" CACHE PATH "Folder contains Math Lib files from MKLROOT")
endif()

if(UNIX)
set(MATHLIB_SYCL_LIB
Expand All @@ -51,14 +54,14 @@ endif()

find_path(
MATHLIB_INCLUDE_DIR oneapi/mkl.hpp
HINTS ENV CONDA_PREFIX ENV PREFIX ${MATHLIB_ROOT_DIR} # search order is important
PATH_SUFFIXES include latest/include
HINTS ${DPNP_MKLROOT} ${DPNP_ONEAPI_MKL} ENV CONDA_PREFIX ENV PREFIX # search order is important
PATH_SUFFIXES include include
DOC "Path to mathlib include files")

find_path(
MATHLIB_LIBRARY_DIR ${MATHLIB_SYCL_LIB}
HINTS ENV CONDA_PREFIX ENV PREFIX ${MATHLIB_ROOT_DIR} # search order is important
PATH_SUFFIXES lib latest/lib/intel64
HINTS ${DPNP_MKLROOT} ${DPNP_ONEAPI_MKL} ENV CONDA_PREFIX ENV PREFIX # search order is important
PATH_SUFFIXES lib lib/intel64
DOC "Path to mathlib library files")

# TODO implement recurcive searching file (GLOB_RECURSE MY_PATH "/opt/intel/*/mkl.hpp")
Expand All @@ -68,5 +71,5 @@ find_package_handle_standard_args(MathLib DEFAULT_MSG MATHLIB_INCLUDE_DIR MATHLI

if(MathLib_FOUND)
message(STATUS "Found MathLib: (include: ${MATHLIB_INCLUDE_DIR}, library: ${MATHLIB_LIBRARY_DIR})")
mark_as_advanced(MATHLIB_ROOT_DIR MATHLIB_INCLUDE_DIR MATHLIB_LIBRARY_DIR)
# mark_as_advanced(DPNP_MKLROOT MATHLIB_INCLUDE_DIR MATHLIB_LIBRARY_DIR)
endif()