Skip to content

Commit 185d73b

Browse files
Merge remote-tracking branch 'origin/master' into gold/2021
2 parents fd26373 + 395f3bc commit 185d73b

28 files changed

+946
-41
lines changed

.github/workflows/conda-package.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414

1515
jobs:
1616
build_linux:
17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-20.04
1818

1919
strategy:
2020
matrix:
@@ -104,7 +104,7 @@ jobs:
104104
matrix:
105105
python: ['3.8', '3.9', '3.10']
106106
experimental: [false]
107-
runner: [ubuntu-latest]
107+
runner: [ubuntu-20.04]
108108
continue-on-error: ${{ matrix.experimental }}
109109
env:
110110
CHANNELS: -c intel -c main --override-channels
@@ -150,9 +150,10 @@ jobs:
150150
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
151151
- name: Install dpctl
152152
run: |
153-
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
153+
export CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
154+
export TEST_DEPENDENCIES="pytest pytest-cov cython"
154155
export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}")
155-
conda create -n test_dpctl $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} $CHANNELS
156+
conda create -n test_dpctl $PACKAGE_NAME=${PACKAGE_VERSION} ${TEST_DEPENDENCIES} python=${{ matrix.python }} ${CHANNELS}
156157
# Test installed packages
157158
conda list -n test_dpctl
158159
- name: Smoke test
@@ -249,10 +250,12 @@ jobs:
249250
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
250251
SET PACKAGE_VERSION=%%F
251252
)
252-
conda install ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% pytest python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
253-
- name: Report content of test environemtn
253+
SET "TEST_DEPENDENCIES=pytest pytest-cov cython"
254+
conda install ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
255+
- name: Report content of test environment
254256
shell: cmd /C CALL {0}
255257
run: |
258+
pip install --no-cache-dir brotli
256259
echo "Value of CONDA enviroment variable was: " %CONDA%
257260
conda list
258261
- name: Add library
@@ -307,7 +310,7 @@ jobs:
307310
upload_linux:
308311
needs: test_linux
309312
if: ${{github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/')}}
310-
runs-on: ubuntu-latest
313+
runs-on: ubuntu-20.04
311314
strategy:
312315
matrix:
313316
python: ['3.8', '3.9', '3.10']
@@ -362,7 +365,7 @@ jobs:
362365
matrix:
363366
python: ['3.9']
364367
experimental: [false]
365-
runner: [ubuntu-latest]
368+
runner: [ubuntu-20.04]
366369
continue-on-error: ${{ matrix.experimental }}
367370
env:
368371
CHANNELS: -c intel -c main --override-channels
@@ -507,7 +510,7 @@ jobs:
507510
matrix:
508511
python: ['3.10']
509512
experimental: [false]
510-
runner: [ubuntu-latest]
513+
runner: [ubuntu-20.04]
511514
continue-on-error: ${{ matrix.experimental }}
512515
env:
513516
CHANNELS: -c intel -c main --override-channels

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ on:
77

88
jobs:
99
pre-commit:
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-20.04
1111
steps:
1212
- uses: actions/checkout@v3
1313
- uses: actions/setup-python@v4
1414
with:
1515
python-version: '3.10'
16+
- name: Version of clang-format
17+
run: |
18+
clang-format --version
1619
- uses: pre-commit/[email protected]

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [dev]
8+
9+
### Added
10+
11+
### Changed
12+
13+
### Fixed
14+
15+
716
## [0.14.0] - 11/18/2022
817

918
### Added

conda-recipe/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
# activation scripts.
66
export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib"
77

8-
${PYTHON} setup.py clean --all
8+
if [ -e "_skbuild" ]; then
9+
${PYTHON} setup.py clean --all
10+
fi
911
export CMAKE_GENERATOR="Ninja"
1012
SKBUILD_ARGS="-- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx"
1113
echo "${PYTHON} setup.py install ${SKBUILD_ARGS}"

conda-recipe/meta.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ requirements:
1616
- {{ compiler('dpcpp') }} >=2022.1 # [not osx]
1717
host:
1818
- setuptools
19-
- cython
2019
- cmake >=3.21
21-
- python
2220
- ninja
21+
- git
22+
- cython
23+
- python
2324
- scikit-build
2425
- numpy 1.19
2526
- wheel

dpctl/__main__.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import os.path
2020
import platform
2121
import sys
22+
import warnings
2223

2324
import dpctl
2425

@@ -50,6 +51,24 @@ def print_library() -> None:
5051
print(ld_flags + " -lSyclInterface")
5152

5253

54+
def _warn_if_any_set(args, li) -> None:
55+
opts_set = [it for it in li if getattr(args, it, True)]
56+
if opts_set:
57+
if len(opts_set) == 1:
58+
warnings.warn(
59+
"The option " + str(opts_set[0]) + " is being ignored.",
60+
stacklevel=3,
61+
)
62+
else:
63+
warnings.warn(
64+
"Options " + str(opts_set) + " are being ignored.", stacklevel=3
65+
)
66+
67+
68+
def print_lsplatform(verbosity: int) -> None:
69+
dpctl.lsplatform(verbosity=verbosity)
70+
71+
5372
def main() -> None:
5473
"""Main entry-point."""
5574
parser = argparse.ArgumentParser()
@@ -68,9 +87,45 @@ def main() -> None:
6887
action="store_true",
6988
help="Linker flags for SyclInterface library.",
7089
)
90+
parser.add_argument(
91+
"-f",
92+
"--full-list",
93+
action="store_true",
94+
help="Enumerate system platforms, using dpctl.lsplatform(verbosity=2)",
95+
)
96+
parser.add_argument(
97+
"-l",
98+
"--long-list",
99+
action="store_true",
100+
help="Enumerate system platforms, using dpctl.lsplatform(verbosity=1)",
101+
)
102+
parser.add_argument(
103+
"-s",
104+
"--summary",
105+
action="store_true",
106+
help="Enumerate system platforms, using dpctl.lsplatform()",
107+
)
71108
args = parser.parse_args()
72109
if not sys.argv[1:]:
73110
parser.print_help()
111+
if args.full_list:
112+
_warn_if_any_set(
113+
args, ["long_list", "summary", "includes", "cmakedir", "library"]
114+
)
115+
print_lsplatform(2)
116+
return
117+
if args.long_list:
118+
_warn_if_any_set(
119+
args, ["full_list", "summary", "includes", "cmakedir", "library"]
120+
)
121+
print_lsplatform(1)
122+
return
123+
if args.summary:
124+
_warn_if_any_set(
125+
args, ["long_list", "full_list", "includes", "cmakedir", "library"]
126+
)
127+
print_lsplatform(0)
128+
return
74129
if args.includes:
75130
print_includes()
76131
if args.cmakedir:

dpctl/_backend.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ cdef extern from "syclinterface/dpctl_sycl_device_interface.h":
206206
const DPCTLSyclDeviceRef DRef)
207207
cdef size_t *DPCTLDevice_GetSubGroupSizes(const DPCTLSyclDeviceRef DRef,
208208
size_t *res_len)
209+
cdef uint32_t DPCTLDevice_GetPartitionMaxSubDevices(const DPCTLSyclDeviceRef DRef)
209210

210211

211212
cdef extern from "syclinterface/dpctl_sycl_device_manager.h":

dpctl/_sycl_device.pyx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ from ._backend cimport ( # noqa: E211
5555
DPCTLDevice_GetMaxWriteImageArgs,
5656
DPCTLDevice_GetName,
5757
DPCTLDevice_GetParentDevice,
58+
DPCTLDevice_GetPartitionMaxSubDevices,
5859
DPCTLDevice_GetPlatform,
5960
DPCTLDevice_GetPreferredVectorWidthChar,
6061
DPCTLDevice_GetPreferredVectorWidthDouble,
@@ -1292,9 +1293,25 @@ cdef class SyclDevice(_SyclDevice):
12921293
"""
12931294
cdef uint64_t cache_line_sz = DPCTLDevice_GetGlobalMemCacheLineSize(
12941295
self._device_ref
1295-
)
1296+
)
12961297
return cache_line_sz
12971298

1299+
@property
1300+
def partition_max_sub_devices(self):
1301+
""" The maximum number of sub-devices this :class:`dpctl.SyclDevice`
1302+
instance can be partitioned into. The value returned cannot exceed the
1303+
value returned by :attr:`dpctl.SyclDevice.max_compute_units`.
1304+
1305+
Returns:
1306+
int: The maximum number of sub-devices that can be created when this
1307+
device is partitioned. Zero value indicates that device can not
1308+
be partitioned.
1309+
"""
1310+
cdef uint32_t max_part = DPCTLDevice_GetPartitionMaxSubDevices(
1311+
self._device_ref
1312+
)
1313+
return max_part
1314+
12981315
cdef cpp_bool equals(self, SyclDevice other):
12991316
""" Returns ``True`` if the :class:`dpctl.SyclDevice` argument has the
13001317
same _device_ref as this SyclDevice.

dpctl/apis/include/dpctl4pybind11.hpp

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ class dpctl_capi
150150
return PyObject_TypeCheck(obj, PySyclProgramType_) != 0;
151151
}
152152

153-
~dpctl_capi(){};
153+
~dpctl_capi()
154+
{
155+
as_usm_memory_.reset();
156+
default_usm_ndarray_.reset();
157+
default_usm_memory_.reset();
158+
default_sycl_queue_.reset();
159+
};
154160

155161
static auto &get()
156162
{
@@ -194,8 +200,36 @@ class dpctl_capi
194200
std::shared_ptr<py::object> as_usm_memory_;
195201

196202
dpctl_capi()
197-
: default_sycl_queue_{}, default_usm_memory_{}, default_usm_ndarray_{},
198-
as_usm_memory_{}
203+
: Py_SyclDeviceType_(nullptr), PySyclDeviceType_(nullptr),
204+
Py_SyclContextType_(nullptr), PySyclContextType_(nullptr),
205+
Py_SyclEventType_(nullptr), PySyclEventType_(nullptr),
206+
Py_SyclQueueType_(nullptr), PySyclQueueType_(nullptr),
207+
Py_MemoryType_(nullptr), PyMemoryUSMDeviceType_(nullptr),
208+
PyMemoryUSMSharedType_(nullptr), PyMemoryUSMHostType_(nullptr),
209+
PyUSMArrayType_(nullptr), PySyclProgramType_(nullptr),
210+
PySyclKernelType_(nullptr), SyclDevice_GetDeviceRef_(nullptr),
211+
SyclDevice_Make_(nullptr), SyclContext_GetContextRef_(nullptr),
212+
SyclContext_Make_(nullptr), SyclEvent_GetEventRef_(nullptr),
213+
SyclEvent_Make_(nullptr), SyclQueue_GetQueueRef_(nullptr),
214+
SyclQueue_Make_(nullptr), Memory_GetUsmPointer_(nullptr),
215+
Memory_GetContextRef_(nullptr), Memory_GetQueueRef_(nullptr),
216+
Memory_GetNumBytes_(nullptr), Memory_Make_(nullptr),
217+
SyclKernel_GetKernelRef_(nullptr), SyclKernel_Make_(nullptr),
218+
SyclProgram_GetKernelBundleRef_(nullptr), SyclProgram_Make_(nullptr),
219+
UsmNDArray_GetData_(nullptr), UsmNDArray_GetNDim_(nullptr),
220+
UsmNDArray_GetShape_(nullptr), UsmNDArray_GetStrides_(nullptr),
221+
UsmNDArray_GetTypenum_(nullptr), UsmNDArray_GetElementSize_(nullptr),
222+
UsmNDArray_GetFlags_(nullptr), UsmNDArray_GetQueueRef_(nullptr),
223+
UsmNDArray_GetOffset_(nullptr), USM_ARRAY_C_CONTIGUOUS_(0),
224+
USM_ARRAY_F_CONTIGUOUS_(0), USM_ARRAY_WRITABLE_(0), UAR_BOOL_(-1),
225+
UAR_SHORT_(-1), UAR_USHORT_(-1), UAR_INT_(-1), UAR_UINT_(-1),
226+
UAR_LONG_(-1), UAR_ULONG_(-1), UAR_LONGLONG_(-1), UAR_ULONGLONG_(-1),
227+
UAR_FLOAT_(-1), UAR_DOUBLE_(-1), UAR_CFLOAT_(-1), UAR_CDOUBLE_(-1),
228+
UAR_TYPE_SENTINEL_(-1), UAR_HALF_(-1), UAR_INT8_(-1), UAR_UINT8_(-1),
229+
UAR_INT16_(-1), UAR_UINT16_(-1), UAR_INT32_(-1), UAR_UINT32_(-1),
230+
UAR_INT64_(-1), UAR_UINT64_(-1), default_sycl_queue_{},
231+
default_usm_memory_{}, default_usm_ndarray_{}, as_usm_memory_{}
232+
199233
{
200234
// Import Cython-generated C-API for dpctl
201235
// This imports python modules and initializes

dpctl/tensor/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
squeeze,
5959
stack,
6060
)
61+
from dpctl.tensor._print import (
62+
get_print_options,
63+
print_options,
64+
set_print_options,
65+
)
6166
from dpctl.tensor._reshape import reshape
6267
from dpctl.tensor._usmarray import usm_ndarray
6368

@@ -129,4 +134,7 @@
129134
"can_cast",
130135
"result_type",
131136
"meshgrid",
137+
"get_print_options",
138+
"set_print_options",
139+
"print_options",
132140
]

dpctl/tensor/_ctors.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,14 +773,20 @@ def full(
773773

774774
sycl_queue = normalize_queue_device(sycl_queue=sycl_queue, device=device)
775775
usm_type = usm_type if usm_type is not None else "device"
776-
dtype = _get_dtype(dtype, sycl_queue, ref_type=type(fill_value))
776+
fill_value_type = type(fill_value)
777+
dtype = _get_dtype(dtype, sycl_queue, ref_type=fill_value_type)
777778
res = dpt.usm_ndarray(
778779
sh,
779780
dtype=dtype,
780781
buffer=usm_type,
781782
order=order,
782783
buffer_ctor_kwargs={"queue": sycl_queue},
783784
)
785+
if fill_value_type in [float, complex] and np.issubdtype(dtype, np.integer):
786+
fill_value = int(fill_value.real)
787+
elif fill_value_type is complex and np.issubdtype(dtype, np.floating):
788+
fill_value = fill_value.real
789+
784790
hev, _ = ti._full_usm_ndarray(fill_value, res, sycl_queue)
785791
hev.wait()
786792
return res

0 commit comments

Comments
 (0)