Skip to content

Level zero codegen #241

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 9 commits into from
Jan 22, 2021
Merged

Conversation

diptorupd
Copy link
Contributor

@diptorupd diptorupd commented Jan 16, 2021

The PR adds an optional feature to enable Level Zero program creation from SPIR-V in dpctl.

  • The feature is enabled for Linux for the time being.
  • When using this feature level-zero-dev headers should be installed.
  • Windows support is not enabled at this point.

@diptorupd diptorupd marked this pull request as draft January 16, 2021 01:27
@diptorupd
Copy link
Contributor Author

diptorupd commented Jan 16, 2021

@PokhodenkoSA @oleksandr-pavlyk I can get the C API to work, but I need help with getting Python to find the level zero loader library:

  1. How should the level-zero loader libraray be located? On my local system it is installed under /usr/lib/x86_64-linux-gnu/. However, Python is unaware of the library and I get this error:
ImportError: Failed to import test module: dpctl
Traceback (most recent call last):
  File "/home/diptorupd/.conda/envs/dpctl-devel/lib/python3.8/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/home/diptorupd/Desktop/devel/dpctl/dpctl/__init__.py", line 38, in <module>
    from dpctl._sycl_core import *
ImportError: /home/diptorupd/Desktop/devel/dpctl/dpctl/libDPCTLSyclInterface.so: undefined symbol: zeModuleCreate
  1. The Linux CI server needs the level-zero headers (level-zero-dev) to be installed. The driver should already be available.

Ideally we should be packaging the libze_loader as a conda package. Surprisingly, the intel-compute-runtime conda package does not include the level zero library.

Once these two changes are done, we should be good to go.

@oleksandr-pavlyk
Copy link
Contributor

Level-zero libraries and level-zero include headers must be made available to Python as conda package, if ze_loaded is directly linked to DPCTLSyclInterface. oneDAL does not link directly, but likely uses dlopen :

(base) [13:31:57 ansatnuc04 ~]$ grep ze_loader /localdisk/intel/oneapi/dal/latest/lib/intel64/*.so
Binary file /localdisk/intel/oneapi/dal/latest/lib/intel64/libonedal_dpc.so matches

(base) [13:40:02 ansatnuc04 ~]$ ldd /localdisk/intel/oneapi/dal/latest/lib/intel64/*.so | grep 'ze_loader' | wc
      0       0       0

@oleksandr-pavlyk
Copy link
Contributor

@diptorupd
Copy link
Contributor Author

diptorupd commented Jan 20, 2021

oneDAL's solution: https://github.com/oneapi-src/oneDAL/blob/1e6f13f10d14a117e235aaf6217f3c4a65469d4a/cpp/daal/include/services/internal/sycl/level_zero_module_sycl.h#L82

The reason this works is that they include the headers almost verbatim inside oneDAL https://github.com/oneapi-src/oneDAL/blob/1e6f13f10d14a117e235aaf6217f3c4a65469d4a/cpp/daal/include/services/internal/sycl/level_zero_common.h.

We need to know level zero types to create the function pointers as is done here:
https://github.com/oneapi-src/oneDAL/blob/1e6f13f10d14a117e235aaf6217f3c4a65469d4a/cpp/daal/include/services/internal/sycl/level_zero_common.h

Is this the route we want to go? If we want level zero support on Windows, at this point there is no real alternatives as the headers are not available on Windows.

@diptorupd
Copy link
Contributor Author

Merging since CI passes and no objections :)

@diptorupd diptorupd marked this pull request as ready for review January 22, 2021 15:36
@diptorupd diptorupd merged commit 7a3d1b2 into IntelPython:master Jan 22, 2021
@diptorupd diptorupd deleted the level_zero_codegen branch January 22, 2021 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Level Zero support for program compilation for dpctl
2 participants