Skip to content

Feature/device selectors #274

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 15 commits into from
Feb 19, 2021

Conversation

diptorupd
Copy link
Contributor

@diptorupd diptorupd commented Feb 15, 2021

This PR is extracted out of #271 and only adds the device selector classes to C API and Python API.

  • A SyclDevice can now be created out of SYCL's standard device selector classes.
  • A SyclDevice can also be constructed using a filter selector string.

@@ -20,11 +20,41 @@
""" Implements SyclDevice Cython extension type.
"""

from ._backend cimport *
from ._backend cimport (
Copy link
Contributor

Choose a reason for hiding this comment

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

So much better :)

@oleksandr-pavlyk
Copy link
Contributor

Looking good. I still would like to build it locally, so please wait some before merging.

@diptorupd diptorupd force-pushed the feature/device_selectors branch from c41c5c1 to 7a2070f Compare February 16, 2021 16:19
@diptorupd
Copy link
Contributor Author

diptorupd commented Feb 16, 2021

Looking good. I still would like to build it locally, so please wait some before merging.

Sure, I will also like to add the support for filter selector. I tried the following code. It works, but breaks the SyclDevice._create implementation. How to design support for filter selector to create a SyclDevice?

    @staticmethod
    cdef _init_helper(SyclDevice device, DPCTLSyclDeviceRef DRef):
        device._device_ref = DRef
        device._vendor_name = DPCTLDevice_GetVendorName(DRef)
        device._device_name = DPCTLDevice_GetName(DRef)
        device._driver_version = DPCTLDevice_GetDriverInfo(DRef)
        device._max_compute_units = DPCTLDevice_GetMaxComputeUnits(DRef)
        device._max_work_item_dims = DPCTLDevice_GetMaxWorkItemDims(DRef)
        device._max_work_item_sizes = DPCTLDevice_GetMaxWorkItemSizes(DRef)
        device._max_work_group_size = DPCTLDevice_GetMaxWorkGroupSize(DRef)
        device._max_num_sub_groups = DPCTLDevice_GetMaxNumSubGroups(DRef)
        device._int64_base_atomics = DPCTLDevice_HasInt64BaseAtomics(DRef)
        device._int64_extended_atomics = (
            DPCTLDevice_HasInt64ExtendedAtomics(DRef)
        )

    def __cinit__(self, filter_str):
        cdef const char *filter_c_str = NULL
        if type(filter_str) is unicode:
            string = bytes(<unicode>filter_str, "utf-8")
            filter_c_str = string
        elif isinstance(filter_str, unicode):
            string = bytes(unicode(filter_str), "utf-8")
            filter_c_str = <unicode>string
        cdef DPCTLSyclDeviceSelectorRef DSRef = (
            DPCTLFilterSelector_Create(filter_c_str)
        )
        cdef DPCTLSyclDeviceRef DRef = DPCTLDevice_CreateFromSelector(DSRef)
        if DRef is NULL:
            raise ValueError("Device could not be created from provided filter")
        # Initialize the attributes of the SyclDevice object
        SyclDevice._init_helper(self, DRef)
        # Free up the device selector
        DPCTLDeviceSelector_Delete(DSRef)

@diptorupd diptorupd force-pushed the feature/device_selectors branch from ab2c12f to 4b491e6 Compare February 17, 2021 00:59
@diptorupd
Copy link
Contributor Author

@oleksandr-pavlyk this one is good to go. The CI chokes up due to pytest not being added to the recipe. I have opened another PR #276 that should fix the CI.

@diptorupd diptorupd force-pushed the feature/device_selectors branch from 88abbba to 30e3307 Compare February 17, 2021 21:52
@diptorupd
Copy link
Contributor Author

@oleksandr-pavlyk We actually do need the SyclDevice._create method as we are using it to create a SyclDevice from a cdef DPCTLSyclDeviceRef.

@diptorupd
Copy link
Contributor Author

@oleksandr-pavlyk are we good to go with this?

@diptorupd diptorupd force-pushed the feature/device_selectors branch from a898b0b to 28022af Compare February 19, 2021 18:49
@diptorupd
Copy link
Contributor Author

merging as @oleksandr-pavlyk gave his blessings :)

@diptorupd diptorupd merged commit 8e526b4 into IntelPython:master Feb 19, 2021
@diptorupd diptorupd deleted the feature/device_selectors branch February 19, 2021 21:53
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