Skip to content
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

Update dpnp 0.8 #524

Merged
merged 22 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,11 @@ jobs:
artifact_name: [""]
dependencies: [""]
include:
- python: "3.8"
integration_channels: -c dppy/label/dev
artifact_name: -c dppy_label_dev
experimental: true
dependencies: ""
- python: "3.8"
integration_channels: -c dppy/label/dev
artifact_name: -c dppy_label_dev
experimental: false # current stable
dependencies: dpnp=0.7.1=*_41
dependencies: ""
continue-on-error: ${{ matrix.experimental }}
env:
# conda-forge: llvm-spirv 11 not on intel channel yet
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ https://intelpython.github.io/dpnp/
## Dependencies

* numba 0.54.*
* dpctl 0.9.*
* dpnp 0.7.* (optional)
* dpctl 0.10.*
* dpnp 0.8.* (optional)
* llvm-spirv 11.* (SPIRV generation from LLVM IR)
* spirv-tools
* packaging
Expand Down
4 changes: 2 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ requirements:
- cython
- numba 0.54*
- dpctl >=0.10*
- dpnp 0.7* # [linux]
- dpnp >=0.8* # [linux]
- wheel
run:
- python
- numba 0.54*
- dpctl >=0.10*
- spirv-tools
- llvm-spirv 11.*
- dpnp 0.7* # [linux]
- dpnp >=0.8* # [linux]
- packaging

test:
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- cython
- numba 0.54*
- dpctl >=0.10*
- dpnp 0.7*=*_41
- dpnp 0.8*=*_10
- spirv-tools
# - llvm-spirv 11.*
- packaging
Expand Down
15 changes: 11 additions & 4 deletions numba_dppy/dpnp_glue/dpnp_array_ops_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,18 @@ def dpnp_take_impl(a, ind):
ret_type = types.void
"""
dpnp source:
https://github.com/IntelPython/dpnp/blob/0.5.1/dpnp/backend/kernels/dpnp_krnl_indexing.cpp#L34
https://github.com/IntelPython/dpnp/blob/ca6eb1b8fc561957402b6f258529f862c4a8f945/dpnp/backend/kernels/dpnp_krnl_indexing.cpp#L479
Function declaration:
void dpnp_take_c(void* array1_in, void* indices1, void* result1, size_t size)
void dpnp_take_c(void* array1_in, const size_t array1_size, void* indices1, void* result1, size_t size)
"""
sig = signature(ret_type, types.voidptr, types.voidptr, types.voidptr, types.intp)
sig = signature(
ret_type,
types.voidptr,
types.intp,
types.voidptr,
types.voidptr,
types.intp,
)
dpnp_func = dpnp_ext.dpnp_func("dpnp_" + name, [a.dtype.name, "NONE"], sig)

res_dtype = a.dtype
Expand Down Expand Up @@ -264,7 +271,7 @@ def dpnp_impl(a, ind):
out = np.arange(0, ind.size, 1, res_dtype).reshape(ind.shape)
out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)

dpnp_func(a_usm, ind_usm, out_usm, ind.size)
dpnp_func(a_usm, a.size * a.itemsize, ind_usm, out_usm, ind.size)

event = dpctl_functions.queue_memcpy(
sycl_queue, out.ctypes, out_usm, out.size * out.itemsize
Expand Down
15 changes: 12 additions & 3 deletions numba_dppy/dpnp_glue/dpnp_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ def dpnp_diagonal_impl(a, offset=0):
ret_type = types.void
"""
dpnp source:
https://github.com/IntelPython/dpnp/blob/master/dpnp/backend/kernels/dpnp_krnl_indexing.cpp#L38
https://github.com/IntelPython/dpnp/blob/e389248c709531b181be8bf33b1a270fca812a92/dpnp/backend/kernels/dpnp_krnl_indexing.cpp#L39

Function declaration:
void dpnp_diagonal_c(
void* array1_in, void* result1, const size_t offset, size_t* shape, size_t* res_shape, const size_t res_ndim)
void* array1_in, const size_t input1_size, void* result1, const size_t offset, size_t* shape, size_t* res_shape, const size_t res_ndim)

"""
sig = signature(
ret_type,
types.voidptr,
types.intp,
types.voidptr,
types.intp,
types.voidptr,
Expand Down Expand Up @@ -93,7 +94,15 @@ def dpnp_impl(a, offset=0):

out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)

dpnp_func(a_usm, out_usm, offset, a.shapeptr, out.shapeptr, out.ndim)
dpnp_func(
a_usm,
a.size * a.itemsize,
out_usm,
offset,
a.shapeptr,
out.shapeptr,
out.ndim,
)

event = dpctl_functions.queue_memcpy(
sycl_queue, out.ctypes, out_usm, out.size * out.itemsize
Expand Down
150 changes: 119 additions & 31 deletions numba_dppy/dpnp_glue/dpnp_linalgimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,45 @@ def common_matmul_impl(dpnp_func, a, b, out, m, n, k, print_debug):

out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)

dpnp_func(a_usm, b_usm, out_usm, m, n, k)
a_m = np.array((m, k))
b_m = np.array((k, n))
out_m = np.array((m, n))

result_out = out_usm
result_size = out.size
result_ndim = 2
result_shape = out_m.ctypes
result_strides = 0

input1_in = a_usm
input1_size = a.size
input1_ndim = 2
input1_shape = a_m.ctypes
input1_strides = 0

input2_in = b_usm
input2_size = b.size
input2_ndim = 2
input2_shape = b_m.ctypes
input2_strides = 0

dpnp_func(
result_out,
result_size,
result_ndim,
result_shape,
result_strides,
input1_in,
input1_size,
input1_ndim,
input1_shape,
input1_strides,
input2_in,
input2_size,
input2_ndim,
input2_shape,
input2_strides,
)

event = dpctl_functions.queue_memcpy(
sycl_queue, out.ctypes, out_usm, out.size * out.itemsize
Expand All @@ -127,6 +165,7 @@ def common_matmul_impl(dpnp_func, a, b, out, m, n, k, print_debug):
dpctl_functions.free_with_queue(out_usm, sycl_queue)

dpnp_ext._dummy_liveness_func([a.size, b.size, out.size])
dpnp_ext._dummy_liveness_func([a_m.size, b_m.size, out_m.size])

if print_debug:
print("dpnp implementation")
Expand All @@ -152,27 +191,39 @@ def common_dot_impl(dpnp_func, a, b, out, m, print_debug):
out_usm = dpctl_functions.malloc_shared(out.size * out.itemsize, sycl_queue)

result_out = out_usm
result_size = out.size
result_ndim = out.ndim
result_shape = out.shapeptr
result_strides = 0

input1_in = a_usm
input1_size = a.size
input1_ndim = a.ndim
input1_shape = a.shapeptr
input1_shape_ndim = a.ndim
input1_strides = 0

input2_in = b_usm
input2_size = b.size
input2_ndim = b.ndim
input2_shape = b.shapeptr
input2_shape_ndim = b.ndim
where = 0
input2_strides = 0

dpnp_func(
result_out,
result_size,
result_ndim,
result_shape,
result_strides,
input1_in,
input1_size,
input1_ndim,
input1_shape,
input1_shape_ndim,
input1_strides,
input2_in,
input2_size,
input2_ndim,
input2_shape,
input2_shape_ndim,
where,
input2_strides,
)

event = dpctl_functions.queue_memcpy(
Expand Down Expand Up @@ -237,31 +288,42 @@ def dpnp_dot_impl(a, b):
ret_type = types.void
"""
dpnp source:
https://github.com/IntelPython/dpnp/blob/0.4.0/dpnp/backend/custom_kernels.cpp#L42
https://github.com/IntelPython/dpnp/blob/0.6.1dev/dpnp/backend/kernels/dpnp_krnl_common.cpp#L78
https://github.com/IntelPython/dpnp/blame/67a101c90cf253cfe9b9ba80ac397811ce94edee/dpnp/backend/kernels/dpnp_krnl_common.cpp#L322

Function declaration:
void dpnp_matmul_c(void* array1_in, void* array2_in, void* result1, size_t size_m,
size_t size_n, size_t size_k)
void dpnp_dot_c(void* result_out,
const void* input1_in,
const size_t input1_size,
const size_t* input1_shape,
const size_t input1_shape_ndim,
const void* input2_in,
const size_t input2_size,
const size_t* input2_shape,
const size_t input2_shape_ndim,
const size_t* where)
void dpnp_matmul_c(void* result_out,
const size_t result_size,
const size_t result_ndim,
const size_t* result_shape,
const size_t* result_strides,
const void* input1_in,
const size_t input1_size,
const size_t input1_ndim,
const size_t* input1_shape,
const size_t* input1_strides,
const void* input2_in,
const size_t input2_size,
const size_t input2_ndim,
const size_t* input2_shape,
const size_t* input2_strides)
"""
sig = signature(
ret_type,
types.voidptr,
types.intp,
types.intp,
types.voidptr,
types.voidptr,
types.voidptr,
types.intp,
types.intp,
types.voidptr,
types.voidptr,
types.voidptr,
types.intp,
types.intp,
types.voidptr,
types.voidptr,
)

res_dtype = get_res_dtype(a, b)
Expand Down Expand Up @@ -319,18 +381,44 @@ def dot_2_vm(a, b):

return dot_2_vm
elif ndims == [1, 1]:
"""
dpnp source:
https://github.com/IntelPython/dpnp/blob/67a101c90cf253cfe9b9ba80ac397811ce94edee/dpnp/backend/kernels/dpnp_krnl_common.cpp#L79

Function declaration:
void dpnp_dot_c(void* result_out,
const size_t result_size,
const size_t result_ndim,
const size_t* result_shape,
const size_t* result_strides,
const void* input1_in,
const size_t input1_size,
const size_t input1_ndim,
const size_t* input1_shape,
const size_t* input1_strides,
const void* input2_in,
const size_t input2_size,
const size_t input2_ndim,
const size_t* input2_shape,
const size_t* input2_strides)
"""
sig = signature(
ret_type,
types.voidptr, # void* result_out,
types.voidptr, # const void* input1_in,
types.intp, # const size_t input1_size,
types.voidptr, # const size_t* input1_shape,
types.intp, # const size_t input1_shape_ndim,
types.voidptr, # const void* input2_in,
types.intp, # const size_t input2_size,
types.voidptr, # const size_t* input2_shape,
types.intp, # const size_t input2_shape_ndim,
types.voidptr, # const size_t* where)
types.voidptr,
types.intp,
types.intp,
types.voidptr,
types.voidptr,
types.voidptr,
types.intp,
types.intp,
types.voidptr,
types.voidptr,
types.voidptr,
types.intp,
types.intp,
types.voidptr,
types.voidptr,
)
dpnp_func = dpnp_ext.dpnp_func("dpnp_dot", [a.dtype.name, "NONE"], sig)

Expand Down
Loading