Skip to content

Commit c5e5a39

Browse files
authored
Merge pull request #815 from IntelPython/master
merge master to gold
2 parents c564028 + 7dbc689 commit c5e5a39

File tree

98 files changed

+6308
-4824
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+6308
-4824
lines changed

.github/workflows/conda-package.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Conda package
2+
3+
on: push
4+
5+
env:
6+
PACKAGE_NAME: dpctl
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- name: Install Intel repository
13+
run: |
14+
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
15+
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
16+
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
17+
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
18+
sudo apt-get update
19+
- name: Update libstdc++-dev
20+
run: |
21+
sudo apt remove -y gcc-7 g++-7 gcc-8 g++-8 gcc-10 g++-10
22+
sudo apt remove -y libstdc++-10-dev
23+
sudo apt autoremove
24+
sudo apt install --reinstall -y gcc-9 g++-9 libstdc++-9-dev
25+
- name: Install Intel OneAPI
26+
run: |
27+
sudo apt-get install intel-oneapi-mkl \
28+
intel-oneapi-mkl-devel \
29+
intel-oneapi-dpcpp-cpp-compiler
30+
- name: Checkout repo
31+
uses: actions/checkout@v2
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Add conda to system path
36+
run: echo $CONDA/bin >> $GITHUB_PATH
37+
- name: Install conda-build
38+
run: conda install conda-build
39+
- name: Build conda package
40+
run: |
41+
. /opt/intel/oneapi/setvars.sh
42+
. ./scripts/install_cmake_lin.sh
43+
CHANNELS="-c dppy/label/dev -c intel -c defaults --override-channels"
44+
VERSIONS="--python 3.8"
45+
TEST="--no-test"
46+
conda build \
47+
$TEST \
48+
$VERSIONS \
49+
$CHANNELS \
50+
conda-recipe
51+
52+
- name: Upload artifact
53+
uses: actions/upload-artifact@v2
54+
with:
55+
name: dpnp ${{ runner.os }}
56+
path: /usr/share/miniconda/conda-bld/linux-64/dpnp-*.tar.bz2
57+
58+
upload:
59+
needs: build
60+
if: ${{ github.ref == 'refs/heads/master' }}
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Download artifact
64+
uses: actions/download-artifact@v2
65+
with:
66+
name: dpnp ${{ runner.os }}
67+
68+
- name: Install anaconda-client
69+
run: conda install anaconda-client
70+
- name: Add conda to system path
71+
run: echo $CONDA/bin >> $GITHUB_PATH
72+
73+
- name: Upload
74+
env:
75+
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
76+
run: |
77+
conda install anaconda-client
78+
anaconda --token $ANACONDA_TOKEN upload --user dppy --label dev dpnp-*.tar.bz2

0.build.sh

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,48 @@ python setup.py build_ext --inplace
1717

1818
echo
1919
echo =========example3==============
20-
clang++ -g -fPIC dpnp/backend/examples/example3.cpp -Idpnp -Idpnp/backend/include -Ldpnp -Wl,-rpath='$ORIGIN'/dpnp -ldpnp_backend_c -o example3
20+
dpcpp -g -fPIC dpnp/backend/examples/example3.cpp -Idpnp -Idpnp/backend/include -Ldpnp -Wl,-rpath='$ORIGIN'/dpnp -ldpnp_backend_c -o example3
21+
# LD_DEBUG=libs,bindings,symbols ./example3
2122
./example3
2223

23-
echo
24+
# gcc --version
25+
# echo =========LD_LIBRARY_PATH==============
26+
# echo $LD_LIBRARY_PATH
27+
28+
# echo =========ldd example3==============
29+
# ldd ./example3
30+
# echo =========readelf example3==============
31+
# readelf -d ./example3
32+
# echo =========ldd dpnp/libdpnp_backend_c.so==============
33+
# ldd ./dpnp/libdpnp_backend_c.so
34+
# echo =========readelf dpnp/libdpnp_backend_c.so==============
35+
# readelf -d ./dpnp/libdpnp_backend_c.so
36+
37+
# echo ========= libstdc++.so ==============
38+
# ls -l /usr/share/miniconda/envs/dpnp*/lib/libstdc++.so
39+
# strings /usr/share/miniconda/envs/dpnp*/lib/libstdc++.so | grep GLIBCXX | sort -n
40+
41+
42+
# echo
2443
echo =========example1==============
44+
# LD_DEBUG=libs,bindings,symbols python examples/example1.py
45+
# LD_DEBUG=libs python examples/example1.py
2546
python examples/example1.py
47+
48+
# echo ========= find /opt ==============
49+
# find /opt -name libstdc++.so*
50+
# echo ========= find anaconda ==============
51+
# find /usr/share/miniconda -name libstdc++.so*
52+
# echo ========= dpkg-query -L libstdc++6 ==============
53+
# dpkg-query -L libstdc++6
54+
# echo ========= ls -l /lib/x86_64-linux-gnu/libstdc* ==============
55+
# ls -l /lib/x86_64-linux-gnu/libstdc*
56+
57+
# gcc --version
58+
# g++ --version
59+
# dpcpp --version
60+
61+
# echo ========= APT ==============
62+
# apt list --installed
63+
# echo ========= conda ==============
64+
# conda list

0.env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export ONEAPI_ROOT=/opt/intel/oneapi
99
. ${ONEAPI_ROOT}/compiler/latest/env/vars.sh
1010
. ${ONEAPI_ROOT}/tbb/latest/env/vars.sh
1111

12-
if true
12+
if false
1313
then
1414
# Temporary use explicit version (arg_verz) due to MKLD-10520
1515
arg_verz=latest

benchmarks/pytest_benchmark/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# dpnp/benchmarks/pytest_benchmark/
2+
3+
## Prerequisites
4+
* pytest >= 6.1.1
5+
* pytest-benchmark >= 3.4.1
6+
7+
8+
## Running benchmark tests
9+
```bash
10+
pytest benchmarks/ --benchmark-json=results.json
11+
```
12+
Running tests and saving the current run into `STORAGE`, see [1]
13+
```bash
14+
pytest benchmarks/ --benchmark-json=results.json --benchmark-autosave
15+
```
16+
17+
## Creating `.csv` report
18+
```bash
19+
pytest-benchmark compare results.json --csv=results.csv --group-by='name'
20+
```
21+
22+
## Optional: creating histogram
23+
Note: make sure that `pytest-benchmark[histogram]` installed
24+
```bash
25+
# example
26+
pip install pytest-benchmark[histogram]
27+
pytest -vv benchmarks/ --benchmark-autosave --benchmark-histogram
28+
pytest-benchmark compare .benchmarks/Linux-CPython-3.7-64bit/* --histogram
29+
```
30+
31+
## Advanced running example
32+
```
33+
pytest benchmarks/ --benchmark-columns='min, max, mean, stddev, median, rounds, iterations' --benchmark-json=results.json --benchmark-autosave
34+
pytest-benchmark compare results.json --csv=results.csv --group-by='name'
35+
```
36+
37+
38+
[1] https://pytest-benchmark.readthedocs.io/en/latest/usage.html
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
# cython: language_level=3
3+
# -*- coding: utf-8 -*-
4+
# *****************************************************************************
5+
# Copyright (c) 2016-2020, Intel Corporation
6+
# All rights reserved.
7+
#
8+
# Redistribution and use in source and binary forms, with or without
9+
# modification, are permitted provided that the following conditions are met:
10+
# - Redistributions of source code must retain the above copyright notice,
11+
# this list of conditions and the following disclaimer.
12+
# - Redistributions in binary form must reproduce the above copyright notice,
13+
# this list of conditions and the following disclaimer in the documentation
14+
# and/or other materials provided with the distribution.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26+
# THE POSSIBILITY OF SUCH DAMAGE.
27+
# *****************************************************************************
28+
29+
import pytest
30+
31+
import dpnp
32+
import numpy as np
33+
34+
ROUNDS = 30
35+
ITERATIONS = 4
36+
37+
NNUMBERS = 2**26
38+
39+
40+
@pytest.mark.parametrize("function", [dpnp.random.beta, np.random.beta],
41+
ids=["dpnp", "numpy"])
42+
def test_beta(benchmark, function):
43+
result = benchmark.pedantic(target=function, args=(4.0, 5.0, NNUMBERS,),
44+
rounds=ROUNDS, iterations=ITERATIONS)
45+
46+
47+
@pytest.mark.parametrize("function", [dpnp.random.exponential, np.random.exponential],
48+
ids=["dpnp", "numpy"])
49+
def test_exponential(benchmark, function):
50+
result = benchmark.pedantic(target=function, args=(4.0, NNUMBERS,),
51+
rounds=ROUNDS, iterations=ITERATIONS)
52+
53+
54+
@pytest.mark.parametrize("function", [dpnp.random.gamma, np.random.gamma],
55+
ids=["dpnp", "numpy"])
56+
def test_gamma(benchmark, function):
57+
result = benchmark.pedantic(target=function, args=(2.0, 4.0, NNUMBERS,),
58+
rounds=ROUNDS, iterations=ITERATIONS)
59+
60+
61+
@pytest.mark.parametrize("function", [dpnp.random.normal, np.random.normal],
62+
ids=["dpnp", "numpy"])
63+
def test_normal(benchmark, function):
64+
result = benchmark.pedantic(target=function, args=(0.0, 1.0, NNUMBERS,),
65+
rounds=ROUNDS, iterations=ITERATIONS)
66+
67+
68+
@pytest.mark.parametrize("function", [dpnp.random.uniform, np.random.uniform],
69+
ids=["dpnp", "numpy"])
70+
def test_uniform(benchmark, function):
71+
result = benchmark.pedantic(target=function, args=(0.0, 1.0, NNUMBERS,),
72+
rounds=ROUNDS, iterations=ITERATIONS)

conda-recipe/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fi
1616
# if MKLROOT is specified (work with custom math library)
1717
if [ -n "${MKLROOT}" ]; then
1818
. ${MKLROOT}/env/vars.sh
19-
conda remove mkl --force -y || true
19+
# conda remove mkl --force -y || true
2020
fi
2121

2222
# have to activate while SYCL CPU device/driver needs paths

conda-recipe/run_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fi
1616
# if MKLROOT is specified (work with custom math library)
1717
if [ -n "${MKLROOT}" ]; then
1818
. ${MKLROOT}/env/vars.sh
19-
conda remove mkl --force -y || true
19+
# conda remove mkl --force -y || true
2020
fi
2121

2222
# have to activate while SYCL CPU device/driver needs paths

dpnp/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
import sys
2828
import warnings
2929

30+
# import os
31+
# myvar=os.environ
32+
33+
# import pprint
34+
# pp = pprint.PrettyPrinter(indent=4)
35+
# pp.pprint(myvar)
36+
37+
# os.system("ldd ./dpnp/libdpnp_backend_c.so")
38+
# subprocess.call("echo Hello 123", shell=True)
39+
3040
if "numpy" in sys.modules:
3141
warnings.warn("\nDPNP: Module NumPy found. Please load DPNP module before NumPy.\n")
3242

dpnp/backend/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ endif()
144144
add_definitions(-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security)
145145
if(NOT WIN32)
146146
add_compile_options(-fno-delete-null-pointer-checks -fstack-protector-strong -fno-strict-overflow)
147+
# add_link_options(-static-libstdc++ -static-libgcc)
147148
add_link_options(-Wl,-z,noexecstack,-z,relro,-z,now)
148149
endif()
149150

@@ -185,7 +186,9 @@ set(DPNP_SRC
185186
kernels/dpnp_krnl_statistics.cpp
186187
src/dpnp_iface_fptr.cpp
187188
src/memory_sycl.cpp
188-
src/queue_sycl.cpp)
189+
src/queue_sycl.cpp
190+
src/verbose.cpp
191+
)
189192

190193
if(DPNP_STATIC_LIB_ENABLE)
191194
add_library(dpnp_backend_c STATIC ${DPNP_SRC})
@@ -221,7 +224,7 @@ if(UNIX)
221224
set(DPNP_MATHLIB_DEP_LIBS
222225
mkl_sycl
223226
mkl_intel_ilp64
224-
mkl_sequential
227+
mkl_tbb_thread # mkl_sequential
225228
mkl_core
226229
sycl
227230
OpenCL

0 commit comments

Comments
 (0)