Skip to content
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

[SYCL] Queue shortcut functions with placeholder accessors #7266

Merged
merged 12 commits into from
Nov 14, 2022

Conversation

andylshort
Copy link
Contributor

Implementation of the explicit copy-based queue shortcut functions defined in Table 29 of Section 4.6.5.2 of the specification (the last 7 rows of the table to be precise).

An end-to-end test was used in place of a unit test as it was not possible to verify or mock the functionality of the handler::require function - everything else was testable with PIMock.

Each shortcut function is implemented in accordance with its description in the table, and I've added doxygen comments to each to document parameter and behaviour information as with the rest of the functions in queue.hpp.

Seem like erroneous additions as manually invoking clang-format-diff
doesn't re-add them. So removing them.
- Still debating how to test ::require and accessors
- Debating whether or not to split into separate tests with setup.
Unit testing was initially chosen but it became apparent that we weren't
able to test the handler::require call due to its inability to be mocked
or replaced in the queue, so it was changed to an end-to-end test instead.
@andylshort andylshort requested a review from a team as a code owner November 3, 2022 11:12
@andylshort andylshort requested review from romanovvlad and a team November 3, 2022 11:12
/// Copies data from a memory region pointed to by a placeholder accessor to
/// another memory region pointed to by a shared_ptr.
///
/// \param Src is a placeholder accessor to the source memory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure the API works with placeholder accessors only, does it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Technically it should be as this is a function on queue, so at this level it should only be possible to have placeholder and host accessors, the latter being moved to host_accessor. We could have a check to make sure it is not a host accessor in the meantime.

@romanovvlad
Copy link
Contributor

@andylshort

An end-to-end test was used in place of a unit test as it was not possible to verify or mock the functionality of the handler::require function - everything else was testable with PIMock.

Can we check that PI APIs with correct parameters are called for each shortcut queue API?

@andylshort
Copy link
Contributor Author

@andylshort

An end-to-end test was used in place of a unit test as it was not possible to verify or mock the functionality of the handler::require function - everything else was testable with PIMock.

Can we check that PI APIs with correct parameters are called for each shortcut queue API?

Yes this is possible. I will reintroduce the unit test with the mocked PI API functions to check the calls.

update_host doesn't call any so could probably be removed.
Actual verification of results is performed in llvm-test-suite.
@andylshort
Copy link
Contributor Author

This unit test has now been added.

unittest::PiMock Mock;
platform Plt = Mock.getPlatform();

Mock.redefine<detail::PiApiKind::piEnqueueMemBufferWrite>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor. It's not critical in this specific case, but it would be better to use redefineAfter or redefineBefore to let the original mock function execute.

sycl/unittests/queue/ShortcutFunctions.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

LGTM!

@romanovvlad romanovvlad merged commit 5ee066e into intel:sycl Nov 14, 2022
Comment on lines +122 to +123
accessor<int, 1, access::mode::write, access::target::device,
access::placeholder::true_t, ext::oneapi::accessor_property_list<>>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think SYCL 2020 makes access::placeholder::true_t unnecessary. I'd suggest to either simplify or at least add as extra simple

  accessor Dest(Buf, sycl::write);

test.

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.

None yet

5 participants