Skip to content

Simplified arg parsing in SyclDevice constructor #572

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 1 commit into from
Sep 2, 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
13 changes: 2 additions & 11 deletions dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,8 @@ cdef class SyclDevice(_SyclDevice):
cdef const char *filter_c_str = NULL
cdef int ret = 0

if type(arg) is unicode:
string = bytes(<unicode>arg, "utf-8")
filter_c_str = string
DSRef = DPCTLFilterSelector_Create(filter_c_str)
ret = self._init_from_selector(DSRef)
if ret == -1:
raise ValueError(
"Could not create a SyclDevice with the selector string"
)
elif isinstance(arg, unicode):
string = bytes(<unicode>unicode(arg), "utf-8")
if type(arg) is str:
string = bytes(<str>arg, "utf-8")
filter_c_str = string
DSRef = DPCTLFilterSelector_Create(filter_c_str)
ret = self._init_from_selector(DSRef)
Expand Down
6 changes: 6 additions & 0 deletions dpctl/tests/test_sycl_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"opencl:gpu:-1",
"cuda:cpu:0",
"abc",
1,
]


Expand Down Expand Up @@ -470,6 +471,10 @@ def check_print_device_info(device):
pytest.fail("Encountered an exception inside print_device_info().")


def check_repr(device):
assert type(repr(device)) is str


list_of_checks = [
check_get_max_compute_units,
check_get_max_work_item_dims,
Expand Down Expand Up @@ -523,6 +528,7 @@ def check_print_device_info(device):
check_create_sub_devices_by_affinity_L1_cache,
check_create_sub_devices_by_affinity_next_partitionable,
check_print_device_info,
check_repr,
]


Expand Down