This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][NFC] Extend the event introduction to allow wait event actions
AbandonedPublic

Authored by jdoerfert on Mar 5 2022, 1:49 PM.

Details

Summary

Similar to the (old) addEventIfNecessary we now allow to add an event
and wait for it if that is necessary. This allows a thread to put in
a wait before the event was created yet. Since this is not yet used this
patch won't change anything.

Diff Detail

Event Timeline

jdoerfert created this revision.Mar 5 2022, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2022, 1:49 PM
jdoerfert requested review of this revision.Mar 5 2022, 1:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2022, 1:49 PM
Herald added a subscriber: sstefan1. · View Herald Transcript
ye-luo requested changes to this revision.Mar 5 2022, 6:52 PM
ye-luo added a subscriber: ye-luo.
ye-luo added inline comments.
openmp/libomptarget/include/device.h
141

both recordEventIfNecessary and waitEventIfNecessary are confusing names "IfNecessary" part.

openmp/libomptarget/src/device.cpp
46

Cannot take the logic of Record

62

create an event without recording it once, waitevent is undefined behavior.

This revision now requires changes to proceed.Mar 5 2022, 6:52 PM
jdoerfert added inline comments.Mar 6 2022, 2:45 PM
openmp/libomptarget/include/device.h
141

I don't understand what the problem is. Could you say what about it is confusing, maybe suggest an alternative wording or at least describe how that could look like?

openmp/libomptarget/src/device.cpp
46

I do not understand what you mean here either.

62

Is it? I looked at the CUDA API manual and I did not get that idea. Do you happen to have the passage that says so or is it from experimentation?

ye-luo added inline comments.Mar 6 2022, 4:17 PM
openmp/libomptarget/include/device.h
141

recordEventIfNecessary. It sounds like under certain circumstance defined as necessary, an event will be recorded. Otherwise, it is no-op. What is "necessary"?
It is not well defined.
But what the function does is actually create an event if there was no such one and then record that event.

It can be much cleaner to have 3 APIs.
createEventIfNonExist. recordEvent, waitEvent. It is not good to blend APIs.

I also don't get why waitEventIfNecessary is a good API. Should waitEvent just do no-op when there was no event rather than create one?

openmp/libomptarget/src/device.cpp
62

I found the concrete word. It is safe.
Before the first call to cudaEventRecord(), an event represents an empty set of work, so for example cudaEventQuery() would return cudaSuccess.

jdoerfert abandoned this revision.Mar 6 2022, 4:43 PM

Seems to controversial for now. Will revisit if it comes up later.

openmp/libomptarget/include/device.h
141

It can be much cleaner to have 3 APIs.
createEventIfNonExist. recordEvent, waitEvent. It is not good to blend APIs.

While there is some truth to this, you simply ignored the "necessary" part in your new "design".
Once you put that in there it is not as clear anymore. createEvent is now potentially creating one, potentially not. That means record and wait have to accept a "null-event" if none was created. This again leads to the question, should they always?