For 'OFFSET_INLINED', 'gomp_map_val' does the right thing, and we may then
simplify the device plugins accordingly.
This is a follow-up to
Subversion r279551 (Git commit
a6163563f2ce502bd4ef444bd5de33570bb8eeb1)
"Add OpenACC 2.6's no_create",
Subversion r279622 (Git commit
5bcd470bf0749e1f56d05dd43aa9584ff2e3a090)
"Use gomp_map_val for OpenACC host-to-device address translation".
libgomp/
* target.c (gomp_map_vars_internal): Use 'OFFSET_INLINED' for
'GOMP_MAP_IF_PRESENT'.
* plugin/plugin-gcn.c (gcn_exec, GOMP_OFFLOAD_openacc_exec)
(GOMP_OFFLOAD_openacc_async_exec): Adjust.
* plugin/plugin-nvptx.c (nvptx_exec, GOMP_OFFLOAD_openacc_exec)
(GOMP_OFFLOAD_openacc_async_exec): Likewise.
* testsuite/libgomp.oacc-c-c++-common/no_create-1.c: Add 'async'
testing.
* testsuite/libgomp.oacc-c-c++-common/no_create-2.c: Likewise.
/* Execute an OpenACC kernel, synchronously or asynchronously. */
static void
-gcn_exec (struct kernel_info *kernel, size_t mapnum, void **hostaddrs,
+gcn_exec (struct kernel_info *kernel, size_t mapnum,
void **devaddrs, unsigned *dims, void *targ_mem_desc, bool async,
struct goacc_asyncqueue *aq)
{
/* devaddrs must be double-indirect on the target. */
void **ind_da = alloc_by_agent (kernel->agent, sizeof (void*) * mapnum);
for (size_t i = 0; i < mapnum; i++)
- hsa_fns.hsa_memory_copy_fn (&ind_da[i],
- devaddrs[i] ? &devaddrs[i] : &hostaddrs[i],
- sizeof (void *));
+ hsa_fns.hsa_memory_copy_fn (&ind_da[i], &devaddrs[i], sizeof (void *));
struct hsa_kernel_description *hsa_kernel_desc = NULL;
for (unsigned i = 0; i < kernel->module->image_desc->kernel_count; i++)
void
GOMP_OFFLOAD_openacc_exec (void (*fn_ptr) (void *), size_t mapnum,
- void **hostaddrs, void **devaddrs, unsigned *dims,
+ void **hostaddrs __attribute__((unused)),
+ void **devaddrs, unsigned *dims,
void *targ_mem_desc)
{
struct kernel_info *kernel = (struct kernel_info *) fn_ptr;
- gcn_exec (kernel, mapnum, hostaddrs, devaddrs, dims, targ_mem_desc, false,
- NULL);
+ gcn_exec (kernel, mapnum, devaddrs, dims, targ_mem_desc, false, NULL);
}
/* Run an asynchronous OpenACC kernel on the specified queue. */
void
GOMP_OFFLOAD_openacc_async_exec (void (*fn_ptr) (void *), size_t mapnum,
- void **hostaddrs, void **devaddrs,
+ void **hostaddrs __attribute__((unused)),
+ void **devaddrs,
unsigned *dims, void *targ_mem_desc,
struct goacc_asyncqueue *aq)
{
struct kernel_info *kernel = (struct kernel_info *) fn_ptr;
- gcn_exec (kernel, mapnum, hostaddrs, devaddrs, dims, targ_mem_desc, true,
- aq);
+ gcn_exec (kernel, mapnum, devaddrs, dims, targ_mem_desc, true, aq);
}
/* Create a new asynchronous thread and queue for running future kernels. */
}
static void
-nvptx_exec (void (*fn), size_t mapnum, void **hostaddrs, void **devaddrs,
- unsigned *dims, void *targ_mem_desc,
+nvptx_exec (void (*fn), size_t mapnum, unsigned *dims, void *targ_mem_desc,
CUdeviceptr dp, CUstream stream)
{
struct targ_fn_descriptor *targ_fn = (struct targ_fn_descriptor *) fn;
void
GOMP_OFFLOAD_openacc_exec (void (*fn) (void *), size_t mapnum,
- void **hostaddrs, void **devaddrs,
+ void **hostaddrs __attribute__((unused)),
+ void **devaddrs,
unsigned *dims, void *targ_mem_desc)
{
GOMP_PLUGIN_debug (0, " %s: prepare mappings\n", __FUNCTION__);
size_t s = mapnum * sizeof (void *);
hp = alloca (s);
for (int i = 0; i < mapnum; i++)
- hp[i] = (devaddrs[i] ? devaddrs[i] : hostaddrs[i]);
+ hp[i] = devaddrs[i];
CUDA_CALL_ASSERT (cuMemAlloc, &dp, s);
if (profiling_p)
goacc_profiling_acc_ev_alloc (thr, (void *) dp, s);
}
}
- nvptx_exec (fn, mapnum, hostaddrs, devaddrs, dims, targ_mem_desc,
- dp, NULL);
+ nvptx_exec (fn, mapnum, dims, targ_mem_desc, dp, NULL);
CUresult r = CUDA_CALL_NOCHECK (cuStreamSynchronize, NULL);
const char *maybe_abort_msg = "(perhaps abort was called)";
void
GOMP_OFFLOAD_openacc_async_exec (void (*fn) (void *), size_t mapnum,
- void **hostaddrs, void **devaddrs,
+ void **hostaddrs __attribute__((unused)),
+ void **devaddrs,
unsigned *dims, void *targ_mem_desc,
struct goacc_asyncqueue *aq)
{
block = (void **) GOMP_PLUGIN_malloc (2 * sizeof (void *) + s);
hp = block + 2;
for (int i = 0; i < mapnum; i++)
- hp[i] = (devaddrs[i] ? devaddrs[i] : hostaddrs[i]);
+ hp[i] = devaddrs[i];
CUDA_CALL_ASSERT (cuMemAlloc, &dp, s);
if (profiling_p)
goacc_profiling_acc_ev_alloc (thr, (void *) dp, s);
}
}
- nvptx_exec (fn, mapnum, hostaddrs, devaddrs, dims, targ_mem_desc,
- dp, aq->cuda_stream);
+ nvptx_exec (fn, mapnum, dims, targ_mem_desc, dp, aq->cuda_stream);
if (mapnum > 0)
GOMP_OFFLOAD_openacc_async_queue_callback (aq, cuda_free_argmem, block);
{
/* Not present, hence, skip entry - including its MAP_POINTER,
when existing. */
- tgt->list[i].offset = OFFSET_POINTER;
+ tgt->list[i].offset = OFFSET_INLINED;
if (i + 1 < mapnum
&& ((typemask & get_kind (short_mapkind, kinds, i + 1))
== GOMP_MAP_POINTER))
devptr[0] = &var;
devptr[1] = &arr[2];
}
-
if (acc_hostptr (devptr[0]) != (void *) &var)
__builtin_abort ();
if (acc_hostptr (devptr[1]) != (void *) &arr[2])
__builtin_abort ();
-
- acc_delete (&var, sizeof (var));
- acc_delete (arr, N * sizeof (*arr));
-
#if ACC_MEM_SHARED
if (devptr[0] != &var)
__builtin_abort ();
__builtin_abort ();
#endif
+#pragma acc parallel no_create(var, arr[0:N]) copyout(devptr) async
+ {
+ devptr[0] = &arr[N - 2];
+ devptr[1] = &var;
+ }
+#pragma acc wait
+ if (acc_hostptr (devptr[0]) != (void *) &arr[N - 2])
+ __builtin_abort ();
+ if (acc_hostptr (devptr[1]) != (void *) &var)
+ __builtin_abort ();
+#if ACC_MEM_SHARED
+ if (devptr[0] != &arr[N - 2])
+ __builtin_abort ();
+ if (devptr[1] != &var)
+ __builtin_abort ();
+#else
+ if (devptr[0] == &arr[N - 2])
+ __builtin_abort ();
+ if (devptr[1] == &var)
+ __builtin_abort ();
+#endif
+
+ acc_delete (&var, sizeof (var));
+ acc_delete (arr, N * sizeof (*arr));
+
free (arr);
return 0;
devptr[0] = &var;
devptr[1] = &arr[2];
}
-
if (devptr[0] != &var)
__builtin_abort ();
if (devptr[1] != &arr[2])
__builtin_abort ();
+#pragma acc parallel no_create(var, arr[0:N]) copyout(devptr) async
+ {
+ devptr[0] = &arr[N - 2];
+ devptr[1] = &var;
+ }
+#pragma acc wait
+ if (devptr[0] != &arr[N - 2])
+ __builtin_abort ();
+ if (devptr[1] != &var)
+ __builtin_abort ();
+
free (arr);
return 0;