Skip to content

Refactor/device properties #324

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 3 commits into from
Mar 22, 2021
Merged

Refactor/device properties #324

merged 3 commits into from
Mar 22, 2021

Conversation

diptorupd
Copy link
Contributor

@diptorupd diptorupd commented Mar 13, 2021

SyclDevice no longer stores attributes related to SYCL device_info types (except for vendor_name, driver_version, device_name, and _max_work_item_sizes). All device_info values are converted to properties.

Contains everything in #323 and should be merged after #323 is merged.

@diptorupd diptorupd force-pushed the refactor/device_properties branch from 915e7ba to cf5b5f6 Compare March 15, 2021 17:21
@diptorupd diptorupd mentioned this pull request Mar 15, 2021
8 tasks
@diptorupd diptorupd requested a review from PokhodenkoSA March 15, 2021 22:10
@diptorupd
Copy link
Contributor Author

@PokhodenkoSA @1e-to @oleksandr-pavlyk should the attributes of SyclDevice be defined using property or cached_property

@oleksandr-pavlyk
Copy link
Contributor

I was not aware of cached_property, but if it exists, cached property works too.

@diptorupd
Copy link
Contributor Author

I was not aware of cached_property, but if it exists, cached property works too.

Was referring to https://pypi.org/project/cached-property/. Not sure if it worth the trouble.

@PokhodenkoSA
Copy link
Contributor

@diptorupd please don't use 3rd party package for cached properties.
Standard functools module already contains cached properties (i.e. @lru_cache new in version 3.2 and @cached_property new in version 3.8).

I think cached properties are not necessary because our properties don't contain heavy executions.

max_work_item_sizes = []
for n in range(3):
max_work_item_sizes.append(self._max_work_item_sizes[n])
return tuple(max_work_item_sizes)
Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cython will generate more efficient code from doing

    return (
        self._max_work_item_sizes[0],
        self._max_work_item_sizes[1],
        self._max_work_item_sizes[2],
    )

This avoids needless list temporary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the changes, but am now getting this error

Traceback (most recent call last):
  File "/home/diptorupd/Desktop/devel/dpctl/dpctl/tests/test_sycl_queue.py", line 326, in test_valid_filter_selectors
    check(device)
  File "/home/diptorupd/Desktop/devel/dpctl/dpctl/tests/test_sycl_queue.py", line 66, in check_get_max_work_item_sizes
    max_work_item_sizes = device.max_work_item_sizes
  File "dpctl/_sycl_device.pyx", line 421, in dpctl._sycl_device.SyclDevice.max_work_item_sizes.__get__
    return tuple(
TypeError: tuple expected at most 1 argument, got 3

Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than my prior suggestion, this is good to go, I would like to urge to not put off merging it for longer than absolutely necessary :)

@diptorupd diptorupd merged commit 323d301 into master Mar 22, 2021
@diptorupd diptorupd deleted the refactor/device_properties branch March 22, 2021 18:53
diptorupd pushed a commit that referenced this pull request Apr 2, 2021
* Convert all device attributes to properties.
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.

3 participants