[Openmp-commits] [PATCH] D108528: [OpenMP][Offloading] Add support for event related interfaces
Johannes Doerfert via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Aug 23 15:05:41 PDT 2021
jdoerfert added a comment.
In D108528#2961197 <https://reviews.llvm.org/D108528#2961197>, @JonChesterfield wrote:
> Does 'waitEvent' mean the GPU waits until all the kernels before it have completed and 'syncEvent' mean the host thread waits for the same?
Wait, attach a wait into the AsyncObj stream to avoid anything added after runs before the event is fulfilled.
Sync, block until the event is fulfilled.
================
Comment at: openmp/libomptarget/include/omptargetplugin.h:160
+// {
+void *__tgt_rtl_create_event(int32_t ID, __tgt_async_info *AsyncInfo);
+
----------------
ye-luo wrote:
> JonChesterfield wrote:
> > ye-luo wrote:
> > > tianshilei1992 wrote:
> > > > ye-luo wrote:
> > > > > Please remove AsyncInfo which is not used.
> > > > I would keep it for compatibility consideration. Note that we are not writing a library only for CUDA. There might be programming models requiring the queue.
> > > If you think compatibility consideration is real now, please provide details of one case of need. It is not about CUDA, but it is better to avoid hypothetical needs.
> > >
> > > Additional unused arguments adds confusion and cost maintenance.
> > >
> > > With the minimal arguments,
> > > If a real needs shows up, it is easy to adapt and expand the list arguments.
> > That's true if the interface is easy to change. This one doesn't seem to be - we carry around legacy entry points in case they're still in use, at least for some period of time. I wonder if we should start putting version numbers in it to establish a path to dropping parts.
> >
> > To a fair approximation, every C callback interface should take an additional void*. Otherwise you end up with qsort vs qsort_r when inevitably the callback has to do something with state. In this case, the interface is roughly:
> > ```
> > void * async_info_create();
> > // do things with the async info
> > // awkwardly some of these make a new instance if passed 0
> > void async_info_destroy(void*);
> > ```
> >
> > Threading a single void* through the sequence of calls gives the plugin a way of associating them with each other. Given multiple host threads and multiple targets that is otherwise extremely difficult, hence every function getting an integer ID.
> >
> > I would guess that eliding the void* will work fine until we want to have two independent asynchronous regions running on the same target at the same time, at which point we won't know which one to 'record_event' onto.
> >
> > That's not an argument for this interface in particular, I haven't thought about whether an event should have an identity independent of whatever it is coordinating, but each function in the __tgt_rtl interface that can do things asynchronously should get the async_info instance it is acting on.
> Changing API may never as easy as it might be but this is secondary.
> I prefer not adding an argument which is not used. That means it cannot be precisely defined and can be potentially abused.
> For this reason, I'm asking if there was a solid need.
> __tgt_rtl_record_event and __tgt_rtl_wait_event should have AsyncInfo. I was only asking for the removal on __tgt_rtl_wait_event __tgt_rtl_sync_event and __tgt_rtl_destroy_event which are not asynchronous APIs.
Remove the AsyncInfo in the ones that do not attach the event to a stream/AsyncInfo object.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108528/new/
https://reviews.llvm.org/D108528
More information about the Openmp-commits
mailing list