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

Performance: in-place dpctl.tensor.add with strides #1278

Open
npolina4 opened this issue Jul 12, 2023 · 3 comments
Open

Performance: in-place dpctl.tensor.add with strides #1278

npolina4 opened this issue Jul 12, 2023 · 3 comments

Comments

@npolina4
Copy link
Collaborator

import dpctl.tensor as dpt
a = dpt.ones((8192, 8192), dtype='i4', device='cpu')
b = dpt.ones((8192 + 2, 8192 + 2), dtype='i4', device='cpu')
%timeit b[2:, 2:]+=a
#209 ms ± 36.8 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

import numpy
a_np = numpy.ones((8192, 8192), dtype='i4')
b_np = numpy.ones((8192 + 2, 8192 + 2), dtype='i4')
%timeit b_np[2:, 2:]+=a_np
#75.7 ms ± 1.31 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
@npolina4 npolina4 changed the title Performance: in-place dpctl.tensor.add with strides performance Performance: in-place dpctl.tensor.add with strides Jul 12, 2023
@oleksandr-pavlyk
Copy link
Collaborator

This was addressed and should be closed.

oleksandr-pavlyk added a commit that referenced this issue Aug 15, 2023
Provides an alternative implementation of std::abs for complex types
via std::hypot which is used on Windows.
@ndgrigorian
Copy link
Collaborator

Checked timings again, for Xeon CPU:

In [2]: import dpctl.tensor as dpt
   ...: a = dpt.ones((8192, 8192), dtype='i4', device='cpu')
   ...: b = dpt.ones((8192 + 2, 8192 + 2), dtype='i4', device='cpu')

In [3]: q = a.sycl_queue

In [4]: %timeit b[2:, 2:] += a; q.wait()
6.59 ms ± 748 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)

for i7-1185G7:

In [2]: import dpctl.tensor as dpt
   ...: a = dpt.ones((8192, 8192), dtype='i4', device='cpu')
   ...: b = dpt.ones((8192 + 2, 8192 + 2), dtype='i4', device='cpu')

In [3]: q = a.sycl_queue

In [4]: %timeit b[2:, 2:] += a; q.wait()
72.2 ms ± 2.14 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

@oleksandr-pavlyk should this be closed?

@oleksandr-pavlyk
Copy link
Collaborator

I agree, the performance had improved.

I'd think systematic way to decide whether there are any improvements to be had is to collect the numpy timing on the same machine, and then with dpctl using taskset -c 0 ipython, taskset -c 0-1 ipython, taskset -c 0-3 ipython, taskset -c 0-7 ipython, and plain ipython to see whether performance of CPU device scales.

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

No branches or pull requests

3 participants