Skip to content

Conversation

@diptorupd
Copy link
Contributor

Merge gold/2021 into master.

xaleryb and others added 30 commits May 18, 2021 02:10
This test checks for conformance to __sycl_usm_array_interface__ spect from Wiki
DPCLTDeviceMgr_GetDevices should not rely of the cached unordered map
of root sycl devices to sycl contexts. Because unordered map can change
the ordering.

Changed implementation to iterate over device::get_devices instead.

Confirmation of the fix:

```
In [1]: import dpctl

In [2]: d0 = dpctl.SyclDevice("gpu:0")

In [3]: d0.filter_string
Out[3]: 'opencl:gpu:0'

In [4]: [i for i, di in enumerate(dpctl.get_devices(dpctl.backend_type.all, dpctl.device_type.gpu)) if di == d0]
Out[4]: [0]

In [5]: d0 == dpctl.SyclDevice(d0.filter_string)
Out[5]: True

In [6]: d1 = dpctl.SyclDevice("gpu:1")

In [7]: d1.filter_string
Out[7]: 'level_zero:gpu:0'

In [8]: [i for i, di in enumerate(dpctl.get_devices(dpctl.backend_type.all, dpctl.device_type.gpu)) if di == d1]
Out[8]: [1]

In [9]: d1 == dpctl.SyclDevice(d1.filter_string)
Out[9]: True
```
DeviceType enums now are [0, 8), BackendType enums have lower
16 bits zero, and span [1<<16, 1<<20)
…ompiler.

   - FindDPCPP.cmake is now renamed to FindIntelSycl.cmake.
   - llvm-cov and llvm-profdata now have their own cmake modules
     and the minimum version required is 11.0.0 for these tools.
   - CMAKE_C_COMPILER and CMAKE_CXX_COMPILER are now set by the
     FindIntelSycl.cmake module and do not need to be set manually.
   - A new CMAKE flag DPCTL_CUSTOM_DPCPP_INSTALL_DIR is now available
     that makes it possible to build the DPCTLSyclInterface with a
     custom dpcpp compiler.
   - Formatting changes to CMakeLists.txt files.
   - A new helper script to build the DPCTLSyclInterface library using a
     custom dpcpp.
   - All version checking for CMake modules requirements uses LESS_EQUAL
     instead of EQUAL.
   - Replaced FindLevelZero cmake module with GetLevelZeroHeaders module which
     checks out Level zero repo to satisfy dependency of DPCTL on Level-zero
     headers when configured
   - Added GetProjectVersion cmake module to get version and semantic version
     information for Git repos.
Now that Level zero is being checkout out, the location of the .h file
has changed and is controlled via include directory path.
This function is more general that DPCTL_GetRelativeId(DRef).
The latter corresponds to DPCTLDeviceMgr_GetPositionInDevices(DRef,
 DPCTLDevice_GetBackend(DRef) | DPCTLDevice_GetDeviceType(DRef));

The function can be used to generate filter selector based on a
pattern, expressed by device_mask (any backend, given type), or
(any backend, any type), or (given backend, given type).
dpctl.SyclDevice.filter_string property gives fully specified
filter selector, which includes backend, device_type and relative id.

get_filter_string(include_backend, include_device_type) allows one
to construct filter strings which would omit either backend or device_type
or both, guaranteeing that dpctl.SyclDevice(obtained_selector_string)
will give back the same device.

```
In [1]: import dpctl

In [2]: default_dev = dpctl.SyclDevice()

In [3]: default_dev.get_filter_string(include_backend=False)
Out[3]: 'gpu:1'

In [4]: default_dev.get_filter_string(include_device_type=False)
Out[4]: 'level_zero:0'

In [5]: default_dev.get_filter_string(include_device_type=False, include_backend=False)
Out[5]: '4'
```
The logic to build the backend is moved inside a function, allowing
to pass argument controlling the build.

Currently this is used to specify whether to use L0 support (hardcoded to True),
but opens a door to specify custom compiler to use to build SyclInterface library.

setup.py no longer uses subprocess to invoke build_backed, but uses
importlib to import the function defined there and calls the function with
appropriate arguments.

scipts/build_backend.py retains the function of the script, calling the build_backend
function with default arguments (no L0 support)
python setup.py develop ---help displays them, with use messaes

Options are

   --level-zerop-support=(true|false)
   --coverage=(true|false)
   --sycl-compiler-path=(path to prefix, optional)

If path is not provided backend builder looks up ONEAPI_ROOT variable.

In the path, builder looks for bin/dpcpp (Linux), or bin/dpcpp.exe (Windows).
If found, cmake does see -DDPCTL_DPCPP_ROOT variable set.

Otherwise the variable is set, and clang++ is used instead of dpcpp
CODE_COVERAGE was used to influence whether the backend SyclInterface library
was built in debug mode with coverage over dpctp-capi/ test suite collected or not.

It was also influencing how Cython extensions were built. It would pass linetrace=true
option to cythonize, and define CYTHON_TRACE preprocessor variable when compiling
Cython-generated C++ source files with compiler.

This change removes use CODE_COVERAGE all together. Instead:

1. Custom setuptools command 'build_ext' is implemented which auto-adds
   'CYTHON_TRACE' to the list of defines received by downstream build_ext
   command if develop command received --coverage=True

   cythonize call was removed from extensions() function, allowing
   ``python setup.py develop --help` execute cleanly without running
   cythonize.

   Consequentially, linetrace Cython directive will need to be added to
   each .pyx file in a separate commit.  This is safe to do per

   https://cython.readthedocs.io/en/latest/src/tutorial/profiling_tutorial.html#enabling-line-tracing

   since it is a no-op unless CYTHON_TRACE preprocessor variable is also set,
   which is only done when --coverage=True is used

2. install setuptools command removed support for `--coverage` option, and always
   builds backend without coverage.

   This is to avoid inadvertent installation of debug build of library in Python prefix.
This is safe to do per

https://cython.readthedocs.io/en/latest/src/tutorial/profiling_tutorial.html#enabling-line-tracing

Its use allows improved coverage testing of Cython modules when Cython
sources are compiled with CYTHON_TRACE/CYTHON_TRACE_NOGIL preprocessor
variables defined.
* Correctly copy symlinks to the dpctl dir, but avoid copying if the symlink was previously copied.
Diptorup Deb and others added 13 commits May 24, 2021 18:53
…lls.io.

  - A new github action that builds dpctl in develop mode with
    coverage enabled.
  - The coverage reports for dpctl C and Python APIs are merged
    and uploaded to coveralls.io.
Expanded the test checking consistency between NumPy's and dpctl's notions
…rototype) (#463)

* Changes to make dpctl-capi headers C complaint and satisfy `-Wstrict-prototype`

Co-authored-by: Oleksandr Pavlyk <oleksandr.pavlyk@intel.com>
…setup steps are run to collect headers generated by cythonization (#464)
@coveralls
Copy link
Collaborator

Coverage Status

Coverage remained the same at 60.665% when pulling fed3f4b on gold/2021 into ea841a4 on master.

@diptorupd diptorupd merged commit fed3f4b into master May 25, 2021
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.

4 participants