Skip to content

Used functools.cache to cache filter_string property #1127

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

Merged
merged 2 commits into from
Mar 21, 2023

Conversation

oleksandr-pavlyk
Copy link
Contributor

Partially addresses gh-1098, improving timing of dpctl.SyclDevice.filter_string property on repeated invocations.

Fixed docstring of filter_string property.

Introduced internal dpctl._sycl_device._cached_filter_string stand-alone function that is decorated with functools.cache.

Used that internal function in implementation of
dpctl.SyclDevice.filter_string.

Caching improved timing of filter_string property:

In [1]: import dpctl

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

In [3]: %timeit d.filter_string
2.31 µs ± 42.7 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

Previously, the timing was around 200 ms.

Tests already exist.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • If this PR is a work in progress, are you filing the PR as a draft?

Fixed docstring of filter_string property.

Introduced internal dpctl._sycl_device._cached_filter_string stand-alone
function that is decorated with functools.cache

Used that internal function in implementation of
dpctl.SyclDevice.filter_string.

Caching improved timing of filter_string property:

```
In [1]: import dpctl

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

In [3]: %timeit d.filter_string
2.31 µs ± 42.7 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)
```

Previously, the timing was around `200 ms`.
@github-actions
Copy link

@coveralls
Copy link
Collaborator

coveralls commented Mar 16, 2023

Coverage Status

Coverage: 82.46% (+0.01%) from 82.45% when pulling 586a2ab on cache-filter-string into 742b603 on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.2=py310h76be34b_48 ran successfully.
Passed: 46
Failed: 788
Skipped: 280

@oleksandr-pavlyk oleksandr-pavlyk merged commit ef40014 into master Mar 21, 2023
@oleksandr-pavlyk oleksandr-pavlyk deleted the cache-filter-string branch March 21, 2023 20:50
@github-actions
Copy link

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_8 ran successfully.
Passed: 46
Failed: 788
Skipped: 280

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.

2 participants