Skip to content

Conversation

@1e-to
Copy link

@1e-to 1e-to commented Oct 12, 2020

For now in this PR I did following:

  1. Fix a typo with the name of one of the getter DPPLDevice_GetMaxComputeUnites to DPPLDevice_GetMaxComputeUnits
  2. Add the function declarations for the getters to backend.pxd.
  3. Add dppl_utils.h/DPPLSize_t_Array_Delete to backend.pxd.
  4. Add members and getters for all the attributes to SyclDevice class in sycl_core.pyx and _sycl_core.pxd.
  5. Also change the existing getters get_device_name, get_device_type, get_vendor_name, get_driver_version also to cpdef.
  6. Add unit tests for the Cython functions to a new test_sycl_device.py file.

WIP

Diptorup Deb and others added 30 commits October 4, 2020 09:17
Solution is not to create context on devices that are not
of the requested device type or not from the requested backend.

```
Python 3.7.7 (default, Jul 14 2020, 22:02:37)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.17.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import dpctl

In [2]: with dpctl.device_context('opencl:gpu'):
   ...:     print(1)
      ...:
      1

In [3]: with dpctl.device_context('level0:gpu'):
   ...:     print(1)
      ...:
      1

```
* CC=clang.exe

* CC=clang-cl.exe
* CC=clang.exe

* CC=clang-cl.exe
…ific_queues_v2

Feature/backend specific queues v2
* Add support for uint8 and ulong.
* Rename all functions to addressof_ref and add docstring.

Co-authored-by: reazul.hoque <[email protected]>
* Rename readme and headers

* Fix left over places where DPPL/PyDPPL was used in comments.

Co-authored-by: Diptorup Deb <[email protected]>
* Fix unhandled character

* Fix unhandled character

* Remove unused imports

* Fix class name duplication
Warning about conda-build=3.20
* Add changelog

Co-authored-by: etotmeni <[email protected]>
Co-authored-by: Diptorup Deb <[email protected]>
This ensures that backend libraries  are copied into dpctl
and included in the conda tar ball.

Also fixed copy statement to account for .lib files being
in %INSTALL_PREFIX%\lib and .dll files being in
%INSTALL_PREFIX%\bin on Windows.
* Fixed typo in the code for set_default_queue

Allowing both strings or enums as selectors for
backend and device.

* Fixed "variabel reference before assignment" in device_context manager

ctxt must be set outside of try/finally to be guaranteed avaialble
in the finally clause.
max_work_item_sizes = []
for n in range(3):
max_work_item_sizes.append(self._max_work_item_sizes[n])
DPPLSize_t_Array_Delete(self._max_work_item_sizes)
Copy link
Owner

Choose a reason for hiding this comment

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

Should the DPPLSize_t_Array_Delete call be here? I think should be moved to the __dealloc__ otherwise the self._max_work_item_sizes is deleted after first call to get_max_work_item_sizes.


def test_get_max_compute_units (self):
q = dpctl.get_current_queue()
try:
Copy link
Owner

@diptorupd diptorupd Oct 13, 2020

Choose a reason for hiding this comment

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

Also test if max_compute_units is returned some expected value and not garbage?

class TestSyclDevice (unittest.TestCase):

def test_get_max_compute_units (self):
q = dpctl.get_current_queue()
Copy link
Owner

@diptorupd diptorupd Oct 13, 2020

Choose a reason for hiding this comment

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

Maybe check for exception on get_current_queue as well since that call can raise a SyclQueueCreationError.

def test_get_max_work_item_dims (self):
q = dpctl.get_current_queue()
try:
max_work_item_dims = q.get_sycl_device().get_max_work_item_dims()
Copy link
Owner

Choose a reason for hiding this comment

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

same.

def test_get_max_work_item_sizes (self):
q = dpctl.get_current_queue()
try:
max_work_item_sizes = q.get_sycl_device().get_max_work_item_sizes()
Copy link
Owner

Choose a reason for hiding this comment

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

same.

def test_get_max_work_group_size (self):
q = dpctl.get_current_queue()
try:
max_work_group_size = q.get_sycl_device().get_max_work_group_size()
Copy link
Owner

Choose a reason for hiding this comment

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

same.

def test_get_max_num_sub_groups (self):
q = dpctl.get_current_queue()
try:
max_num_sub_groups = q.get_sycl_device().get_max_num_sub_groups()
Copy link
Owner

Choose a reason for hiding this comment

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

same.

*/
DPPL_API
bool
DPPLDevice_GetAspectsBaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef);
Copy link
Owner

Choose a reason for hiding this comment

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

Let us rename to DPPLDevice_HasInt64BaseAtomics.

*/
DPPL_API
bool
DPPLDevice_GetAspectsExtendedAtomics (__dppl_keep const DPPLSyclDeviceRef DRef);
Copy link
Owner

Choose a reason for hiding this comment

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

let us rename to DPPLDevice_HasInt64ExtendedAtomics

{
auto D = unwrap(DRef);
if(D) {
return D->has(aspect::int64_base_atomics);
Copy link
Owner

Choose a reason for hiding this comment

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

I did not know about the functions. Nice!

if(!OpenCL_cpu)
GTEST_SKIP_("Skipping as no OpenCL CPU device found.");

auto n = DPPLDevice_GetAspectsBaseAtomics(OpenCL_cpu);
Copy link
Owner

Choose a reason for hiding this comment

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

What do we expect on devices that actually do not have int64_base_atomics? In such cases false is the right result. I think a better way to test this is to include CL::sycl.hpp and call the get the aspect for the device using SYCL and see if it matches what DPPLDevice_xxx returns. It is not really a great test, just sanity check.


auto n = DPPLDevice_GetAspectsBaseAtomics(OpenCL_gpu);
EXPECT_TRUE(n != false);
}
Copy link
Owner

Choose a reason for hiding this comment

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

Same here.

GTEST_SKIP_("Skipping as no OpenCL CPU device found.");

auto n = DPPLDevice_GetAspectsExtendedAtomics(OpenCL_cpu);
EXPECT_TRUE(n != false);
Copy link
Owner

Choose a reason for hiding this comment

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

Same here.

GTEST_SKIP_("Skipping as no OpenCL GPU device found.");

auto n = DPPLDevice_GetAspectsExtendedAtomics(OpenCL_gpu);
EXPECT_TRUE(n != false);
Copy link
Owner

Choose a reason for hiding this comment

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

and here.


def test_get_aspects_base_atomics (self):
q = dpctl.get_current_queue()
try:
Copy link
Owner

Choose a reason for hiding this comment

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

Aha now I see. Basically we are testing that the function should never raise an exception. OK.

@1e-to 1e-to force-pushed the extra_device_info branch from 75a229a to e3c901d Compare October 14, 2020 16:15
etotmeni and others added 9 commits October 14, 2020 12:02
This GitHub Action checks that code in pull request
is formatted with black.

See https://black.readthedocs.io/en/stable/github_actions.html
versioneer.py is not a part of the project.

Add pyproject.toml file with section [tool.black] and parameter
exclude = 'versioneer.py'. This file will be used by developers and
GitHub Actions for black.

Usign pyproject.toml allows use black like this: `black .`
Use black version 20.8b1 or branch [stable](https://github.com/psf/black/tree/stable)).

Command: black .
File .git-blame-ignore-revs contains a list of revisions to use for
ignoring in blame. Example:
$ git blame FILE --ignore-revs-file .git-blame-ignore-revs

Also you can configure git to automatically ignore revisions listed
in a file on every call to git blame:
$ git config blame.ignoreRevsFile .git-blame-ignore-revs

Requirements: Git >=2.23
…t-queue-on-C-side

dpctl.get_current_queue is now cimportable
DPPL_API
uint32_t
DPPLDevice_GetMaxComputeUnites (__dppl_keep const DPPLSyclDeviceRef DRef);
DPPLDevice_GetMaxComputeUnits (__dppl_keep const DPPLSyclDeviceRef DRef);

Choose a reason for hiding this comment

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

It is very dangerous to rename API function. It is better to create a new one with new name and implement the old one via the new one.

Choose a reason for hiding this comment

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

Then mark it as deprecated. Better to print warning in stderr when old function is used.
And remove in the next release.

@1e-to 1e-to closed this Oct 29, 2020
@1e-to 1e-to deleted the extra_device_info branch March 2, 2021 12:13
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.

4 participants