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

Move sycl::event and __result_and_scratch_storage into __future #1774

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

SergeyKopienko
Copy link
Contributor

@SergeyKopienko SergeyKopienko commented Aug 12, 2024

In this PR we move the instances of sycl::event and __result_and_scratch_storage into __future constructor to avoid extra operations with counters inside std::shared_ptr objects which are the members of __result_and_scratch_storage (and probably in sycl::event implementation too).

Also we avoid copy operation for _ExecutionPolicy instance inside __result_and_scratch_storage too.

Please take a look to https://stackoverflow.com/questions/41871115/why-would-i-stdmove-an-stdshared-ptr for details.

Additionally, in this PR we fix issue #1776 : we remove ability to create __future instance by copy and copy-assignment:

    using FutureType = __future<_Event, _Args...>;
    // ....
    __future(const FutureType&) = delete;
    __future(FutureType&&) = default;

    FutureType&
    operator=(const FutureType&) = delete;
    FutureType&
    operator=(FutureType&&) = default;

@SergeyKopienko SergeyKopienko marked this pull request as ready for review August 12, 2024 10:03
@SergeyKopienko SergeyKopienko added this to the 2022.7.0 milestone Aug 12, 2024
@danhoeflinger
Copy link
Contributor

For this to stop the copy from happening, changes are required for __future as well I believe. I think @julianmi may be working on this already, we have discussed it a little.

Here is a godbolt that shows that even with this move, it still ends up with a copy when creating the tuple, unless we forward it in. The downside to such a change is it requires explicit specification of the __future type, rather than allowing it to use deduction. Julian has been looking at a way to at least allow the user to skip specifying the event type, but I don't think we can avoid requiring users to define the future value types. In the end, this may not be a bad thing, as it requires users of __future to be more deliberate with their types.

https://godbolt.org/z/vEWz6svMT

@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch from fa370a3 to 3b61d5e Compare August 12, 2024 13:06
@julianmi
Copy link
Contributor

For this to stop the copy from happening, changes are required for __future as well I believe. I think @julianmi may be working on this already, we have discussed it a little.

Here is a godbolt that shows that even with this move, it still ends up with a copy when creating the tuple, unless we forward it in. The downside to such a change is it requires explicit specification of the __future type, rather than allowing it to use deduction. Julian has been looking at a way to at least allow the user to skip specifying the event type, but I don't think we can avoid requiring users to define the future value types. In the end, this may not be a bad thing, as it requires users of __future to be more deliberate with their types.

https://godbolt.org/z/vEWz6svMT

That's right. I've also included @reble in the discussion since he designed the original __future class. Another alternative would be to remove the tuple and specialize for our current use cases (event and/or one result container). However, this would be less generic. I would propose to close this PR and have an offline design discussion.

@SergeyKopienko
Copy link
Contributor Author

SergeyKopienko commented Aug 12, 2024

For this to stop the copy from happening, changes are required for __future as well I believe. I think @julianmi may be working on this already, we have discussed it a little.
Here is a godbolt that shows that even with this move, it still ends up with a copy when creating the tuple, unless we forward it in. The downside to such a change is it requires explicit specification of the __future type, rather than allowing it to use deduction. Julian has been looking at a way to at least allow the user to skip specifying the event type, but I don't think we can avoid requiring users to define the future value types. In the end, this may not be a bad thing, as it requires users of __future to be more deliberate with their types.
https://godbolt.org/z/vEWz6svMT

That's right. I've also included @reble in the discussion since he designed the original __future class. Another alternative would be to remove the tuple and specialize for our current use cases (event and/or one result container). However, this would be less generic. I would propose to close this PR and have an offline design discussion.

I like this variant!
Due we pass only event id + 0/1param into the __future constructor now...

@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch from 3b61d5e to d6ce9ec Compare August 12, 2024 13:29
@SergeyKopienko
Copy link
Contributor Author

@danhoeflinger, @reble I wrote new issue about our __future implementation: #1776

@SergeyKopienko
Copy link
Contributor Author

@danhoeflinger , please take a look to this PR again.
Probably this __future implementations is ok for us?
Also I fixed issue #1776 here.

@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch from d6ce9ec to cc8c438 Compare August 13, 2024 07:31
@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch 3 times, most recently from 9d6e93f to 888d61e Compare August 14, 2024 09:46
@SergeyKopienko SergeyKopienko changed the title Move __result_and_scratch_storage into __future Move sycl::event and __result_and_scratch_storage into __future Aug 14, 2024
@SergeyKopienko
Copy link
Contributor Author

We made decision together with @akukanov and @danhoeflinger to postpone this PR.
So I clear milestone state and change it's state to Draft.

@SergeyKopienko SergeyKopienko removed this from the 2022.7.0 milestone Aug 14, 2024
@SergeyKopienko SergeyKopienko marked this pull request as draft August 14, 2024 12:25
@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch from 1604a07 to ab9ec83 Compare August 14, 2024 12:27
@SergeyKopienko
Copy link
Contributor Author

@reble please take a look to this draft PR and take anything if it's useful for you.

@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch 2 times, most recently from 285c9c1 to aa4c3df Compare September 6, 2024 14:45
@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch 2 times, most recently from b6434e6 to 4f889d4 Compare September 16, 2024 10:37
@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch 2 times, most recently from da7ab7f to 038dae9 Compare September 24, 2024 08:19
…or and copy-assignment should be disabled.

Signed-off-by: Sergey Kopienko <[email protected]>
…refactoring of class __future

Signed-off-by: Sergey Kopienko <[email protected]>
Signed-off-by: Sergey Kopienko <[email protected]>
…om __future specializations

Signed-off-by: Sergey Kopienko <[email protected]>
@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/move_result_and_scratch_storage_into_future branch from 038dae9 to 1ea7940 Compare September 25, 2024 08:27
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