Skip to content

Commit f4a281f

Browse files
committed
Merge branch 'master' into gold/2021
2 parents d157ee0 + ef1e715 commit f4a281f

13 files changed

+184
-57
lines changed

CHANGELOG.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
48
## [Unreleased]
9+
10+
## [0.5.0] - 2020-12-17
511
### Added
12+
- `_Memory.get_pointer_type` static method which returns kind of USM pointer.
13+
- Utility functions to transform string to device type and back.
14+
- New `dpctl.dptensor.numpy_usm_shared` module containing USM array. USM array
15+
extends NumPy ndarray.
16+
- A lot of new examples. Including examples of building Cython extensions with DPC++ compiler that interoperate with dpCtl.
17+
- Mechanism for registering a callback function to look and see if the object
18+
supports USM.
19+
20+
### Changed
621
- setup.py builds C++ backend for develop and install commands.
22+
- Building wheels.
23+
- Use DPC++ runtime from package `dpcpp_cpp_rt`.
24+
- All usage of `DPPL` in C-API functions was changed to `DPCTL`, _e.g._, `DPPLQueueMgr_GetCurrentQueue` to `DPCTLQueueMgr_GetCurrentQueue`.
25+
- Renamed the C-API directory is now called `dpctl-capi` instead of `backends`.
26+
- Refactoring the `dpctl-capi` functions to prepare for changes to add Level Zero program creation.
27+
- `SyclProgram` and `SyclKernel` classes were moved out of `dpctl` into the `dpctl.program` sub-module.
28+
29+
### Fixed
30+
- Klockwork static code analysis warnings.
731

832
## [0.4.0] - 2020-11-04
933
### Added
1034
- Device descriptors "max_compute_units", "max_work_item_dimensions", "max_work_item_sizes", "max_work_group_size", "max_num_sub_groups" and "aspects" for int64 atomics inside dpctl C API and inside the dpctl.SyclDevice class.
1135
- MemoryUSM* classes moved to `dpctl.memory` module, added support for aligned allocation, added support for `prefetch` and `mem_advise` (sychronous) methods, implemented `copy_to_host`, `copy_from_host` and `copy_from_device` methods, pickling support, and zero-copy interoperability with Python objects which implement `__sycl_usm_array_inerface__` protocol.
1236
- Helper scripts to generate API documentation for both C API and Python.
1337

14-
1538
### Fixed
1639
- Compiler warnings when building libDPPLSyclInterface and the Cython extensions.
1740

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ conda install dpctl
4242
Build and Install with setuptools
4343
=================================
4444
dpCtl relies on DPC++ runtime. With Intel oneAPI installed you should activate it.
45+
`setup.py` requires environment variable `ONEAPI_ROOT` and following packages
46+
installed:
47+
- `cython`
48+
- `numpy`
49+
- `cmake` - for building C API
50+
- `ninja` - only on Windows
51+
52+
Activate DPC++ compiler:
53+
```bash
54+
export ONEAPI_ROOT=/opt/intel/oneapi
55+
source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh
56+
```
4557

4658
For install:
4759
```cmd
@@ -81,10 +93,11 @@ Run python examples:
8193
for script in `ls examples/python/`; do echo "executing ${script}"; python examples/python/${script}; done
8294
```
8395

84-
Examples of building Cython extensions with DPC++ compiler, that interoperate with dpCtl can be found in
85-
folder `cython`.
96+
Examples of building Cython extensions with DPC++ compiler, that interoperate
97+
with dpCtl can be found in folder `cython`.
8698

87-
Each example in `cython` folder can be built using `CC=clang CXX=dpcpp python setup.py build_ext --inplace`.
99+
Each example in `cython` folder can be built using
100+
`CC=clang CXX=dpcpp python setup.py build_ext --inplace`.
88101
Please refer to `run.py` script in respective folders to execute extensions.
89102

90103
Tests

docs/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ if (GIT_FOUND)
2323
OUTPUT_VARIABLE CURRENT_RELEASE
2424
OUTPUT_STRIP_TRAILING_WHITESPACE
2525
)
26+
set(CURRENT_COMMIT "")
27+
execute_process(
28+
COMMAND ${GIT_EXECUTABLE} describe --tags
29+
RESULT_VARIABLE result
30+
OUTPUT_VARIABLE CURRENT_COMMIT
31+
OUTPUT_STRIP_TRAILING_WHITESPACE
32+
)
33+
if (NOT "${CURRENT_RELEASE}" STREQUAL "${CURRENT_COMMIT}")
34+
set(CURRENT_RELEASE "master")
35+
endif ()
2636
endif (GIT_FOUND)
2737

2838
set(DOXYGEN_INPUT_DIR ../dpctl-capi)

docs/README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ What?
33

44
Generator scripts for dpCtl API documentation. To run these scripts, follow
55
the following steps:
6-
7-
`mkdir build`
8-
`cd build`
9-
`cmake -DDPCTL_DOCGEN_PREFIX=<WHERE_YOU_WANT_DOCS_TO_BE_GENERATED>`
10-
`make Sphinx`
6+
```bash
7+
cd dpctl/docs
8+
mkdir build
9+
cd build
10+
cmake -DDPCTL_DOCGEN_PREFIX=<WHERE_YOU_WANT_DOCS_TO_BE_GENERATED> ..
11+
make Sphinx
12+
```
1113

1214
The `DPCTL_DOCGEN_PREFIX` flag is optional and can be omitted to generate the
1315
documents in the current source directory in a sub-directory called
@@ -25,4 +27,4 @@ packages installed:
2527
- sphinx
2628
- doxygen
2729
- breathe
28-
- exhale
30+
- exhale

docs/dpCtl.dptensor_api.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _dpCtl.dptensor_api:
2+
3+
#########################
4+
dpCtl dptensor Python API
5+
#########################
6+
7+
.. automodule:: dpctl.dptensor
8+
:members:

docs/dpCtl.program_api.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _dpCtl.program_api:
2+
3+
########################
4+
dpCtl Program Python API
5+
########################
6+
7+
.. automodule:: dpctl.program
8+
:members:

docs/index.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ Indices and tables
1919
* :ref:`search`
2020

2121
.. toctree::
22-
:maxdepth: 2
22+
:maxdepth: 3
2323
:caption: Contents:
2424

2525
self
26-
dpCtl Python API <dpCtl_api>
27-
dpctl.memory Python API <dpCtl.memory_api>
26+
toc_pyapi
2827
api/dpCtl-CAPI_root

docs/toc_pyapi.rst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Python API
2+
================
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
7+
dpctl - SYCL runtime wrapper classes and queue manager <dpCtl_api>
8+
dpctl.memory - USM memory manager <dpCtl.memory_api>
9+
dpctl.dptensor - Data-parallel tensor containers <dpCtl.dptensor_api>
10+
dpctl.program - Program manager <dpCtl.program_api>

dpctl/__init__.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# ===---------------- __init__.py - dpctl module -------*- Cython -*--------===#
2-
#
1+
# ===-----------------------------------------------------------------------===#
32
# Data Parallel Control (dpCtl)
43
#
54
# Copyright 2020 Intel Corporation
@@ -17,11 +16,7 @@
1716
# limitations under the License.
1817
#
1918
# ===-----------------------------------------------------------------------===#
20-
#
21-
# \file
22-
# The top-level dpctl module.
23-
#
24-
# ===-----------------------------------------------------------------------===#
19+
2520
"""
2621
**Data Parallel Control (dpCtl)**
2722
@@ -31,8 +26,14 @@
3126
a common runtime to manage specific SYCL resources, such as devices
3227
and USM memory, for SYCL-based Python packages and extension modules.
3328
34-
Currently, dpCtl has two main features: a global SYCL queue manager
35-
and a USM memory manager.
29+
The main features presently provided by dpCtl are:
30+
31+
* A SYCL queue manager exposed directly inside the top-level `dpctl`
32+
module.
33+
* A USM memory manager (`dpctl.memory`) that provides Python objects
34+
implementing the Python buffer protocol using USM shared and USM host
35+
allocators. The memory manager also exposes various utility functions
36+
to wrap SYCL's USM allocators, deallocators, `memcpy` functions, *etc.*
3637
"""
3738
__author__ = "Intel Corp."
3839

dpctl/_sycl_core.pyx

+36-25
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ cdef class SyclQueue:
303303
"""
304304

305305
@staticmethod
306-
cdef SyclQueue _create (DPCTLSyclQueueRef qref):
306+
cdef SyclQueue _create(DPCTLSyclQueueRef qref):
307307
if qref is NULL:
308308
raise SyclQueueCreationError("Queue creation failed.")
309309
cdef SyclQueue ret = SyclQueue.__new__(SyclQueue)
@@ -605,7 +605,7 @@ cdef class _SyclRTManager:
605605
cdef dict _backend_enum_ty_dict
606606
cdef dict _device_enum_ty_dict
607607

608-
def __cinit__ (self):
608+
def __cinit__(self):
609609

610610
self._backend_str_ty_dict = {
611611
"opencl" : _backend_type._OPENCL,
@@ -627,7 +627,7 @@ cdef class _SyclRTManager:
627627
device_type.gpu : _device_type._GPU,
628628
}
629629

630-
def _set_as_current_queue (self, backend_ty, device_ty, device_id):
630+
def _set_as_current_queue(self, backend_ty, device_ty, device_id):
631631
cdef DPCTLSyclQueueRef queue_ref
632632

633633
try :
@@ -642,45 +642,47 @@ cdef class _SyclRTManager:
642642
raise UnsupportedBackendError("Backend can only be opencl or "
643643
"level-0")
644644

645-
def _remove_current_queue (self):
645+
def _remove_current_queue(self):
646646
DPCTLQueueMgr_PopQueue()
647647

648-
def dump (self):
648+
def dump(self):
649649
""" Prints information about the Runtime object.
650650
"""
651651
DPCTLPlatform_DumpInfo()
652652

653-
def print_available_backends (self):
654-
""" Prints the available backends.
653+
def print_available_backends(self):
654+
""" Prints the available SYCL backends.
655655
"""
656656
print(self._backend_str_ty_dict.keys())
657657

658-
cpdef get_current_backend (self):
659-
""" Returns the backend for the current queue as `backend_type` enum
658+
cpdef get_current_backend(self):
659+
""" Returns the backend for the current queue as a `backend_type` enum
660660
"""
661661
return self.get_current_queue().get_sycl_backend()
662662

663-
cpdef get_current_device_type (self):
664-
""" Returns current device type as `device_type` enum
663+
cpdef get_current_device_type(self):
664+
""" Returns current device type as a `device_type` enum
665665
"""
666666
return self.get_current_queue().get_sycl_device().get_device_type()
667667

668-
cpdef SyclQueue get_current_queue (self):
669-
""" Returns the activated SYCL queue as a PyCapsule.
668+
cpdef SyclQueue get_current_queue(self):
669+
""" Returns the currently activate SYCL queue as a new SyclQueue object.
670+
If there are no active queues then a SyclQueueCreationError exception is
671+
raised.
670672
"""
671673
return SyclQueue._create(DPCTLQueueMgr_GetCurrentQueue())
672674

673-
def get_num_activated_queues (self):
674-
""" Return the number of currently activated queues for this thread.
675+
def get_num_activated_queues(self):
676+
""" Returns the number of currently activated queues for this thread.
675677
"""
676678
return DPCTLQueueMgr_GetNumActivatedQueues()
677679

678-
def get_num_platforms (self):
680+
def get_num_platforms(self):
679681
""" Returns the number of available non-host SYCL platforms.
680682
"""
681683
return DPCTLPlatform_GetNumNonHostPlatforms()
682684

683-
def get_num_queues (self, backend_ty, device_ty):
685+
def get_num_queues(self, backend_ty, device_ty):
684686
cdef size_t num = 0
685687
try :
686688
beTy = self._backend_enum_ty_dict[backend_ty]
@@ -699,7 +701,7 @@ cdef class _SyclRTManager:
699701

700702
return num
701703

702-
def has_gpu_queues (self, backend_ty=backend_type.opencl):
704+
def has_gpu_queues(self, backend_ty=backend_type.opencl):
703705
cdef size_t num = 0
704706
try :
705707
beTy = self._backend_enum_ty_dict[backend_ty]
@@ -714,7 +716,7 @@ cdef class _SyclRTManager:
714716
else:
715717
return False
716718

717-
def has_cpu_queues (self, backend_ty=backend_type.opencl):
719+
def has_cpu_queues(self, backend_ty=backend_type.opencl):
718720
cdef size_t num = 0
719721
try :
720722
beTy = self._backend_enum_ty_dict[backend_ty]
@@ -729,21 +731,21 @@ cdef class _SyclRTManager:
729731
else:
730732
return False
731733

732-
def has_sycl_platforms (self):
734+
def has_sycl_platforms(self):
733735
cdef size_t num_platforms = DPCTLPlatform_GetNumNonHostPlatforms()
734736
if num_platforms:
735737
return True
736738
else:
737739
return False
738740

739-
def is_in_device_context (self):
741+
def is_in_device_context(self):
740742
cdef size_t num = DPCTLQueueMgr_GetNumActivatedQueues()
741743
if num:
742744
return True
743745
else:
744746
return False
745747

746-
def set_default_queue (self, backend_ty, device_ty, device_id):
748+
def set_default_queue(self, backend_ty, device_ty, device_id):
747749
cdef DPCTLSyclQueueRef ret
748750
try :
749751
if isinstance(backend_ty, str):
@@ -785,8 +787,17 @@ set_default_queue = _mgr.set_default_queue
785787
is_in_device_context = _mgr.is_in_device_context
786788

787789
cpdef SyclQueue get_current_queue():
788-
"""
789-
Obtain current Sycl Queue from Data Parallel Control package.
790+
""" Returns the currently activate SYCL queue as a new SyclQueue object.
791+
792+
Returns:
793+
SyclQueue: If there is a currently active SYCL queue that queue
794+
is returned wrapped in a SyclQueue object. The SyclQueue object
795+
owns a copy of the currently active SYCL queue as an opaque
796+
`DPCTLSyclQueueRef` pointer. The pointer is freed when the SyclQueue
797+
is garbage collected.
798+
799+
Raises:
800+
SyclQueueCreationError: If no currently active SYCL queue found.
790801
"""
791802
return _mgr.get_current_queue()
792803

@@ -805,7 +816,7 @@ cpdef get_current_backend():
805816
from contextlib import contextmanager
806817

807818
@contextmanager
808-
def device_context (str queue_str="opencl:gpu:0"):
819+
def device_context(str queue_str="opencl:gpu:0"):
809820
"""
810821
The SYCL queue defined by the "backend:device type:device id" tuple is
811822
set as the currently active queue, *i.e.*, a subsequent call to

dpctl/dptensor/__init__.py

+31
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1+
# ===-----------------------------------------------------------------------===#
2+
# Data Parallel Control (dpCtl)
3+
#
4+
# Copyright 2020 Intel Corporation
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# ===-----------------------------------------------------------------------===#
19+
"""
20+
**Data Parallel Tensor Collection**
21+
22+
`dpctl.dptensor` is an experimental collection of tensor implementations
23+
that will implement future Python data API (https://data-apis.github.io/array-api/latest/).
24+
25+
Available tensor implementations:
26+
27+
* `numpy_usm_shared`: Provides a `numpy.ndarray` sub-class whose \
28+
underlying memory buffer is allocated with a USM shared memory allocator.
29+
30+
"""
31+
132
import dpctl.dptensor.numpy_usm_shared

0 commit comments

Comments
 (0)