https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82864
Bug ID: 82864 Summary: Stop using GOMP_OFFLOAD_openacc_async_set_async Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- When grepping for async_set_async_func in libgomp sources, we see a pattern emerging: ... libgomp.h:917: __typeof (GOMP_OFFLOAD_openacc_async_set_async) *async_set_async_func; oacc-host.c:246: .async_set_async_func = host_openacc_async_set_async, oacc-init.c:432: acc_dev->openacc.async_set_async_func (acc_async_sync); oacc-parallel.c:156: acc_dev->openacc.async_set_async_func (async); oacc-parallel.c:191: acc_dev->openacc.async_set_async_func (acc_async_sync); oacc-parallel.c:289: acc_dev->openacc.async_set_async_func (async); oacc-parallel.c:395: acc_dev->openacc.async_set_async_func (acc_async_sync); oacc-parallel.c:448: acc_dev->openacc.async_set_async_func (async); oacc-parallel.c:474: acc_dev->openacc.async_set_async_func (acc_async_sync); oacc-plugin.c:39: devicep->openacc.async_set_async_func (async); oacc-plugin.c:41: devicep->openacc.async_set_async_func (acc_async_sync); ... F.i., lets look at the last pair: ... void GOMP_PLUGIN_async_unmap_vars (void *ptr, int async) { struct target_mem_desc *tgt = ptr; struct gomp_device_descr *devicep = tgt->device_descr; devicep->openacc.async_set_async_func (async); gomp_unmap_vars (tgt, true); devicep->openacc.async_set_async_func (acc_async_sync); } ... This is an example of implicit parameter passing: instead of passing the async argument to gomp_unmap_vars and beyond, we tell the target plugin to store the async argument for the time being as attribute of the current thread, and let the target plugin use that argument where appropriate while executing gomp_unmap_vars. It is a bit odd though that we're asking the target plugin to keep this state. I think it would be more logical to have the attribute as a part of struct goacc_thread, and extend the plugin interface with the async argument where necessary. So f.i. alongside the existing extern bool GOMP_OFFLOAD_dev2host (int, void *, const void *, size_t); we add an async variant extern bool GOMP_OFFLOAD_dev2host_async (int, void *, const void *, size_t, int async); and use that instead if the target plugin provides it.