IntelPython / dpctl

Python SYCL bindings and SYCL-based Python Array API library
https://intelpython.github.io/dpctl/
Apache License 2.0
102 stars 29 forks source link

`cumulative_logsumexp` raises Runtime warning `loop not vectorized` while running on CPU device #1668

Open antonwolfy opened 6 months ago

antonwolfy commented 6 months ago

The below warning is raised from cumulative_logsumexp call during the first launch on CPU device:

import dpctl, dpctl.tensor as dpt

dpctl.__version__
# Out: '0.17.0dev0+331.g1243edc8f5'

a = dpt.ones(10, device='cpu')
dpt.cumulative_logsumexp(a)
warning: <unknown>:0:0: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering
# Out:
# usm_ndarray([1.        , 1.69314718, 2.09861229, 2.38629436, 2.60943791,
#              2.79175947, 2.94591015, 3.07944154, 3.19722458, 3.30258509])

There is no warning when running on OCL or L0 GPU.

Environment details ```bash $ conda list # packages in environment at /home/xantvol/miniconda3/envs/dpnp_dev: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge intel _openmp_mutex 4.5 2_gnu intel _sysroot_linux-64_curr_repodata_hack 3 h69a702a_14 conda-forge astroid 3.0.3 pypi_0 pypi asttokens 2.4.1 pyhd8ed1ab_0 conda-forge attrs 23.2.0 pyh71513ae_0 conda-forge beautifulsoup4 4.12.3 pyha770c72_0 conda-forge brotli-python 1.1.0 py39h3d6467e_1 intel bzip2 1.0.8 hb9a14ef_9 intel c-ares 1.26.0 hd590300_0 intel ca-certificates 2024.2.2 hbcca054_0 intel certifi 2024.2.2 pyhd8ed1ab_0 intel cffi 1.16.0 py39h7a31438_0 intel cfgv 3.3.1 pypi_0 pypi chardet 5.2.0 py39hf3d152e_1 intel charset-normalizer 3.3.2 pyhd8ed1ab_0 intel click 8.0.4 py39h06a4308_0 intel cmake 3.29.2 h91dbaaa_1 conda-forge codespell 2.2.6 pypi_0 pypi colorama 0.4.6 pyhd8ed1ab_0 intel conda 23.3.1 py39h535c160_1 http://satpkgserver.an.intel.com:8081 conda-build 24.1.2 py39hf3d152e_0 conda-forge conda-index 0.4.0 pyhd8ed1ab_0 conda-forge conda-package-handling 2.2.0 pyh38be061_0 intel conda-package-streaming 0.9.0 pyhd8ed1ab_0 intel coverage 5.5 py39h27cfd23_2 intel cpplint 1.6.1 pypi_0 pypi cryptography 42.0.4 py39hd4f0224_0 intel cython 3.0.8 py39h3d6467e_0 intel decorator 5.0.9 pyhd3eb1b0_0 intel dill 0.3.8 pypi_0 pypi distlib 0.3.6 pypi_0 pypi distro 1.9.0 pyhd8ed1ab_0 conda-forge dpcpp-cpp-rt 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 dpcpp-sycl-rt 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 dpcpp_cpp_rt 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 dpcpp_impl_linux-64 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 dpcpp_linux-64 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 dpctl 0.17.0dev0 py39h15de555_331 dppy/label/dev dpnp 0.15.0.dev1+51.gad8d1c3033.dirty dev_0 exceptiongroup 1.2.0 pyhd8ed1ab_2 conda-forge executing 2.0.1 pyhd8ed1ab_0 conda-forge filelock 3.6.0 pyhd3eb1b0_0 intel icc_rt 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 icu 73.2 h59595ed_0 intel identify 2.5.24 pypi_0 pypi idna 3.6 pyhd8ed1ab_0 intel importlib_resources 5.2.0 pyhd3eb1b0_1 intel iniconfig 2.0.0 pyhd8ed1ab_0 conda-forge intel-cmplr-lib-rt 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 intel-cmplr-lib-ur 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 intel-cmplr-lic-rt 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 intel-opencl-rt 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 intel-openmp 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 intel-sycl-rt 2024.2.0 intel_684 http://satpkgserver.an.intel.com:8081 intelpython 2024.2.0 0 http://satpkgserver.an.intel.com:8081 ipython 8.18.1 pyh707e725_3 conda-forge isort 5.13.2 pypi_0 pypi jedi 0.19.1 pyhd8ed1ab_0 conda-forge jinja2 3.0.1 pyhd3eb1b0_0 intel jsonpatch 1.33 pyhd8ed1ab_0 intel jsonpointer 2.4 py39hf3d152e_3 intel jsonschema 4.22.0 pyhd8ed1ab_0 conda-forge jsonschema-specifications 2023.12.1 pyhd8ed1ab_0 conda-forge kernel-headers_linux-64 4.18.0 he073ed8_2 conda-forge keyutils 1.6.1 h166bdaf_0 conda-forge krb5 1.21.2 h659d440_0 conda-forge level-zero 1.16.0 h00ab1b0_0 intel libarchive 3.7.2 h2aa1ff5_1 conda-forge libcurl 8.7.1 hca28451_0 conda-forge libedit 3.1.20210910 h7f8727e_0 intel libev 4.33 h7f8727e_1 intel libexpat 2.6.2 h59595ed_0 conda-forge libffi 3.4.2 h7f98852_5 intel libgcc-ng 13.2.0 h807b86a_5 intel libgomp 13.2.0 h807b86a_5 intel libiconv 1.17 hd590300_2 intel liblief 0.14.1 hac33072_1 conda-forge libllvm14 14.0.6 hcd5def8_4 intel libnghttp2 1.58.0 h47da74e_0 conda-forge libnsl 2.0.1 hd590300_0 intel libsqlite 3.45.1 h2797004_0 intel libssh2 1.11.0 h0841786_0 conda-forge libstdcxx-ng 13.2.0 h7e041cc_5 intel libuuid 2.38.1 h0b41bf4_0 intel libuv 1.48.0 hd590300_0 conda-forge libxml2 2.12.5 h232c23b_0 intel libzlib 1.2.13 hd590300_5 intel llvm 14.0.6 h32600fe_4 intel lz4-c 1.9.4 hcb278e6_0 intel lzo 2.10 h516909a_1000 intel markupsafe 2.0.1 py39h27cfd23_0 intel matplotlib-inline 0.1.7 pyhd8ed1ab_0 conda-forge mccabe 0.7.0 pypi_0 pypi menuinst 2.0.2 py39hf3d152e_0 conda-forge mkl 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 mkl-devel 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 mkl-devel-dpcpp 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 mkl-dpcpp 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 mkl-include 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 mkl-service 2.4.1 py39h1e356de_0 http://satpkgserver.an.intel.com:8081 mkl_fft 1.3.8 py39h977b55c_71 http://satpkgserver.an.intel.com:8081 mkl_random 1.2.4 py39hae8aba8_91 http://satpkgserver.an.intel.com:8081 mkl_umath 0.1.1 py39h9ab9c7e_101 http://satpkgserver.an.intel.com:8081 more-itertools 10.2.0 pyhd8ed1ab_0 conda-forge ncurses 6.4.20240210 h59595ed_0 conda-forge ninja 1.10.2 py39hff7bd54_0 intel nodeenv 1.8.0 pypi_0 pypi numpy 1.26.4 py39h689b997_2 http://satpkgserver.an.intel.com:8081 numpy-base 1.26.4 py39h913173e_2 http://satpkgserver.an.intel.com:8081 onedpl-devel 2022.6.0 intel_414 http://satpkgserver.an.intel.com:8081 onemkl-sycl-blas 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 onemkl-sycl-datafitting 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 onemkl-sycl-dft 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 onemkl-sycl-lapack 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 onemkl-sycl-rng 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 onemkl-sycl-sparse 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 onemkl-sycl-stats 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 onemkl-sycl-vm 2024.2.0 intel_472 http://satpkgserver.an.intel.com:8081 openssl 3.2.1 hd590300_1 intel packaging 23.2 pyhd8ed1ab_0 intel parso 0.8.4 pyhd8ed1ab_0 conda-forge patch 2.7.6 h7f98852_1002 conda-forge patchelf 0.17.2 h58526e2_0 conda-forge pexpect 4.9.0 pyhd8ed1ab_0 conda-forge pickleshare 0.7.5 py_1003 conda-forge pip 24.0 pyhd8ed1ab_0 intel pkginfo 1.10.0 pyhd8ed1ab_0 conda-forge pkgutil-resolve-name 1.3.10 pyhd8ed1ab_1 conda-forge platformdirs 3.7.0 pypi_0 pypi pluggy 1.4.0 pyhd8ed1ab_0 conda-forge pre-commit 3.3.3 pypi_0 pypi prompt-toolkit 3.0.42 pyha770c72_0 conda-forge psutil 5.8.0 py39h27cfd23_2 intel ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge pure_eval 0.2.2 pyhd8ed1ab_0 conda-forge py-lief 0.14.1 py39h84cc369_1 conda-forge pycosat 0.6.6 py39hd1e30aa_0 intel pycparser 2.21 pyhd3eb1b0_0 intel pygments 2.18.0 pyhd8ed1ab_0 conda-forge pylint 3.0.3 pypi_0 pypi pyopenssl 24.0.0 pyhd8ed1ab_0 intel pysocks 1.7.1 pyha2e5f31_6 intel pytest 8.1.2 pyhd8ed1ab_0 conda-forge pytest-cov 5.0.0 pyhd8ed1ab_0 conda-forge python 3.9.18 h4499717_0 http://satpkgserver.an.intel.com:8081 python-libarchive-c 4.0 py39hf3d152e_2 intel python_abi 3.9 2_cp39 intel pytz 2024.1 pyhd8ed1ab_0 intel pyyaml 6.0.1 py39hd1e30aa_1 intel readline 8.2 h8228510_1 intel referencing 0.35.1 pyhd8ed1ab_0 conda-forge requests 2.31.0 pyhd8ed1ab_0 intel rhash 1.4.4 hd590300_0 conda-forge ripgrep 14.1.0 he8a937b_0 conda-forge rpds-py 0.18.1 py39ha68c5e3_0 conda-forge ruamel.yaml 0.17.40 py39hd1e30aa_0 intel ruamel.yaml.clib 0.2.8 py39hd1e30aa_0 intel scikit-build 0.17.6 pyh4af843d_0 conda-forge setuptools 69.1.0 pyhd8ed1ab_1 intel six 1.16.0 pyhd3eb1b0_1 intel soupsieve 2.5 pyhd8ed1ab_1 conda-forge stack_data 0.6.2 pyhd8ed1ab_0 conda-forge sysroot_linux-64 2.28 he073ed8_2 conda-forge tbb 2021.13.0 intel_493 http://satpkgserver.an.intel.com:8081 tbb-devel 2021.13.0 intel_493 http://satpkgserver.an.intel.com:8081 tbb4py 2021.13.0 py39_intel_493 http://satpkgserver.an.intel.com:8081 tk 8.6.13 noxft_h4845f30_101 intel toml 0.10.2 pyhd8ed1ab_0 conda-forge tomli 2.0.1 pyhd8ed1ab_0 conda-forge tomlkit 0.12.3 pypi_0 pypi toolz 0.12.1 pyhd8ed1ab_0 intel tqdm 4.66.2 pyhd8ed1ab_0 intel traitlets 5.14.3 pyhd8ed1ab_0 conda-forge typing-extensions 4.9.0 hd8ed1ab_0 intel typing_extensions 4.9.0 pyha770c72_0 intel tzdata 2024a h0c530f3_0 intel urllib3 2.2.1 pyhd8ed1ab_0 intel virtualenv 20.23.1 pypi_0 pypi wcwidth 0.2.13 pyhd8ed1ab_0 conda-forge wheel 0.42.0 pyhd8ed1ab_0 intel xz 5.2.8 h5eee18b_0 intel yaml 0.2.5 h7f98852_2 intel zipp 3.15.0 pyhd8ed1ab_0 intel zstandard 0.19.0 py39h29414ee_1 intel zstd 1.5.6 ha6fb4c9_0 conda-forge ``` ### Driver versions ```bash $ python -m dpctl -f Platform 0 :: Name Intel(R) OpenCL Version OpenCL 3.0 LINUX Vendor Intel(R) Corporation Backend opencl Num Devices 1 # 0 Name 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz Version 2024.18.4.0.26_160000 Filter string opencl:cpu:0 Platform 1 :: Name Intel(R) OpenCL Graphics Version OpenCL 3.0 Vendor Intel(R) Corporation Backend opencl Num Devices 1 # 0 Name Intel(R) Graphics [0x9a49] Version 23.52.28202.16 Filter string opencl:gpu:0 Platform 2 :: Name Intel(R) FPGA Emulation Platform for OpenCL(TM) Version OpenCL 1.2 Intel(R) FPGA SDK for OpenCL(TM), Version 20.3 Vendor Intel(R) Corporation Backend opencl Num Devices 1 # 0 Name Intel(R) FPGA Emulation Device Version 2024.18.4.0.26_160000 Filter string opencl:accelerator:0 Platform 3 :: Name Intel(R) Level-Zero Version 1.3 Vendor Intel(R) Corporation Backend ext_oneapi_level_zero Num Devices 1 # 0 Name Intel(R) Graphics [0x9a49] Version 1.3.28202 Filter string level_zero:gpu:0 ``` ### WSL info ```bash $ uname -a Linux antonvol-mobl1 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux ```

Is it expected to have such kind of warning here?

oleksandr-pavlyk commented 6 months ago

Note, that the message does not show with DPC++ 2024.1:

(dev_dpctl) opavlyk@opavlyk-mobl:~/repos/application_examples/kde$ ipython
Python 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:38:13) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.24.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import dpctl.tensor as dpt

In [2]: x = dpt.ones(10, device='cpu')

In [3]: dpt.cumulative_logsumexp(x)
Out[3]:
usm_ndarray([1.        , 1.69314718, 2.09861229, 2.38629436, 2.60943791,
             2.79175947, 2.94591015, 3.07944154, 3.19722458, 3.30258509])

In [4]: !icpx --version
Intel(R) oneAPI DPC++/C++ Compiler 2024.1.0 (2024.1.0.20240308)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2024.1/bin/compiler
Configuration file: /opt/intel/oneapi/compiler/2024.1/bin/compiler/../icpx.cfg

In [5]: !sycl-ls
[opencl:acc:0] Intel(R) FPGA Emulation Platform for OpenCL(TM), Intel(R) FPGA Emulation Device OpenCL 1.2  [2024.17.3.0.08_160000]
[opencl:cpu:1] Intel(R) OpenCL, 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz OpenCL 3.0 (Build 0) [2024.17.3.0.08_160000]