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

Mark copy events as nodiscard #286

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

stephenswat
Copy link
Member

Currently, there is no compile-time mechanism to ensure that copy objects are properly handled, i.e. either waited for or ignored. This commit adds the nodiscard attribute to methods of the copy objects which return events to ensure that the compiler will issue a warning if the object is ignored.

@stephenswat stephenswat added the improvement Improve an existing feature label Jul 16, 2024
@stephenswat stephenswat force-pushed the feat/nodiscard_copy branch 2 times, most recently from a2ef8b0 to 9389492 Compare July 16, 2024 12:52
Copy link
Member

@krasznaa krasznaa left a comment

Choose a reason for hiding this comment

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

🤔 I considered doing this a while ago. But decided that it would be too painful for the users to always have to deal with adding wait() and ignore() calls, for all vecmem::copy variants. Even all the synchronous ones.

Since forgetting to add these calls is "only" a performance penalty in the current setup, I introduced VECMEM_FAIL_ON_ASYNC_ERRORS in #270.

Now... I do not think that that solution is perfect. Not at all. But I'm very afraid of making the UI "too painful" to use. And I fear that using [[nodiscard]] on all of these functions is very painful. 😦

@stephenswat
Copy link
Member Author

Hmm, not necessarily. I modified traccc using this PR and it only came to 20 files changed, 86 insertions(+), 69 deletions(-). So not that painful, really.

@stephenswat
Copy link
Member Author

Since forgetting to add these calls is "only" a performance penalty in the current setup, I introduced VECMEM_FAIL_ON_ASYNC_ERRORS in #270.

Unfortunately, they can also be runtime errors in SYCL code if you use unordered streams.

stephenswat added a commit to stephenswat/traccc that referenced this pull request Jul 17, 2024
Using acts-project/vecmem#286 I was able to find
a few more cases where we do not properly wait for or ignore events. In
this PR I opted to add those missing statements according to a simple
heuristic, i.e. I added waits for all SYCL and share code and I added
ignores for all CUDA code. Reason for this is that CUDA events are
stream-ordered, so you can't really shoot yourself in the foot too much.
SYCL events, on the other hand, are unordered, so they need stricted
checking.
@krasznaa
Copy link
Member

Unfortunately there are some HIP issues after all. 😦 (Some missing return value handling was left in.)

Copy link
Member

@krasznaa krasznaa left a comment

Choose a reason for hiding this comment

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

Plus, the HIP changes...

core/include/vecmem/utils/attributes.hpp Show resolved Hide resolved
Currently, there are a few copy statements in the testing code which are
not being properly ignored or waited for. Thus, this commit adds the
appropriate code to ensure that the (potentially) asynchronous
properties of these copies are properly handled.
@stephenswat
Copy link
Member Author

Updated to pass the CI. @krasznaa

Copy link
Member

@krasznaa krasznaa left a comment

Choose a reason for hiding this comment

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

Fine, let's go with the unnecessary VECMEM_NODISCARD. We can remove it later on... 🤔

@krasznaa krasznaa merged commit ea48e02 into acts-project:main Oct 27, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improve an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants