aboutsummaryrefslogtreecommitdiff
path: root/libgomp/oacc-parallel.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@gcc.gnu.org>2015-09-28 19:37:33 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-09-28 19:37:33 +0000
commit3e32ee19a56d9defea32f54788e1ef12657bc307 (patch)
tree82bea03a2a53289a91a90b899f03a9be503a60df /libgomp/oacc-parallel.c
parent4e671509d92cd4dc7d28d7bb92e46092afcd7370 (diff)
downloadgcc-3e32ee19a56d9defea32f54788e1ef12657bc307.zip
gcc-3e32ee19a56d9defea32f54788e1ef12657bc307.tar.gz
gcc-3e32ee19a56d9defea32f54788e1ef12657bc307.tar.bz2
gomp-constants.h (GOMP_VERSION_NVIDIA_PTX): Increment.
inlude/ * gomp-constants.h (GOMP_VERSION_NVIDIA_PTX): Increment. (GOMP_DIM_GANG, GOMP_DIM_WORKER, GOMP_DIM_VECTOR, GOMP_DIM_MAX, GOMP_DIM_MASK): New. (GOMP_LAUNCH_DIM, GOMP_LAUNCH_ASYNC, GOMP_LAUNCH_WAIT): New. (GOMP_LAUNCH_CODE_SHIFT, GOMP_LAUNCH_DEVICE_SHIFT, GOMP_LAUNCH_OP_SHIFT): New. (GOMP_LAUNCH_PACK, GOMP_LAUNCH_CODE, GOMP_LAUNCH_DEVICE, GOMP_LAUNCH_OP): New. (GOMP_LAUNCH_OP_MAX): New. libgomp/ * libgomp.h (acc_dispatch_t): Replace separate geometry args with array. * libgomp.map (GOACC_parallel_keyed): New. * oacc-parallel.c (goacc_wait): Take pointer to va_list. Adjust all callers. (GOACC_parallel_keyed): New interface. Lose geometry arguments and take keyed varargs list. Adjust call to exec_func. (GOACC_parallel): Force host fallback. * libgomp_g.h (GOACC_parallel): Remove. (GOACC_parallel_keyed): Declare. * plugin/plugin-nvptx.c (struct targ_fn_launch): New struct. (stuct targ_gn_descriptor): Replace name field with launch field. (nvptx_exec): Lose separate geometry args, take array. Process dynamic dimensions and adjust. (struct nvptx_tdata): Replace fn_names field with fn_descs. (GOMP_OFFLOAD_load_image): Adjust for change in function table data. (GOMP_OFFLOAD_openacc_parallel): Adjust for change in dimension passing. * oacc-host.c (host_openacc_exec): Adjust for change in dimension passing. gcc/ * config/nvptx/nvptx.c: Include omp-low.h and gomp-constants.h. (nvptx_record_offload_symbol): Record function execution geometry. * config/nvptx/mkoffload.c (process): Include launch geometry in function data. * omp-low.c (oacc_launch_pack): New. (replace_oacc_fn_attrib): New. (set_oacc_fn_attrib): New. (get_oacc_fn_attrib): New. (expand_omp_target): Create keyed varargs for GOACC_parallel call generation. * omp-low.h (get_oacc_fn_attrib): Declare. * builtin-types.def (DEF_FUNCTION_TyPE_VAR_6): New. (DEF_FUNCTION_TYPE_VAR_11): Delete. * tree.h (OMP_CLAUSE_EXPR): New. * omp-builtins.def (BUILT_IN_GOACC_PARALLEL): Change target fn name. gcc/lto/ * lto-lang.c (DEF_FUNCTION_TYPE_VAR_6): New. (DEF_FUNCTION_TYPE_VAR_11): Delete. gcc/c-family/ * c-common.c (DEF_FUNCTION_TYPE_VAR_6): New. (DEF_FUNCTION_TYPE_VAR_11): Delete. gcc/fortran/ * f95-lang.c (DEF_FUNCTION_TYPE_VAR_6): New. (DEF_FUNCTION_TYPE_VAR_11): Delete. * types.def (DEF_FUNCTION_TYPE_VAR_6): New. (DEF_FUNCTION_TYPE_VAR_11): Delete. gcc/ada/ * gcc-interface/utils.c (DEF_FUNCTION_TYPE_VAR_6): Define From-SVN: r228220
Diffstat (limited to 'libgomp/oacc-parallel.c')
-rw-r--r--libgomp/oacc-parallel.c114
1 files changed, 82 insertions, 32 deletions
diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c
index d0e5f94..e31bc0a 100644
--- a/libgomp/oacc-parallel.c
+++ b/libgomp/oacc-parallel.c
@@ -49,14 +49,18 @@ find_pset (int pos, size_t mapnum, unsigned short *kinds)
return kind == GOMP_MAP_TO_PSET;
}
-static void goacc_wait (int async, int num_waits, va_list ap);
+static void goacc_wait (int async, int num_waits, va_list *ap);
+
+
+/* Launch a possibly offloaded function on DEVICE. FN is the host fn
+ address. MAPNUM, HOSTADDRS, SIZES & KINDS describe the memory
+ blocks to be copied to/from the device. Varadic arguments are
+ keyed optional parameters terminated with a zero. */
void
-GOACC_parallel (int device, void (*fn) (void *),
- size_t mapnum, void **hostaddrs, size_t *sizes,
- unsigned short *kinds,
- int num_gangs, int num_workers, int vector_length,
- int async, int num_waits, ...)
+GOACC_parallel_keyed (int device, void (*fn) (void *),
+ size_t mapnum, void **hostaddrs, size_t *sizes,
+ unsigned short *kinds, ...)
{
bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK;
va_list ap;
@@ -68,22 +72,16 @@ GOACC_parallel (int device, void (*fn) (void *),
struct splay_tree_key_s k;
splay_tree_key tgt_fn_key;
void (*tgt_fn);
-
- if (num_gangs != 1)
- gomp_fatal ("num_gangs (%d) different from one is not yet supported",
- num_gangs);
- if (num_workers != 1)
- gomp_fatal ("num_workers (%d) different from one is not yet supported",
- num_workers);
+ int async = GOMP_ASYNC_SYNC;
+ unsigned dims[GOMP_DIM_MAX];
+ unsigned tag;
#ifdef HAVE_INTTYPES_H
- gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p, "
- "async = %d\n",
- __FUNCTION__, (uint64_t) mapnum, hostaddrs, sizes, kinds, async);
+ gomp_debug (0, "%s: mapnum=%"PRIu64", hostaddrs=%p, size=%p, kinds=%p\n",
+ __FUNCTION__, (uint64_t) mapnum, hostaddrs, sizes, kinds);
#else
- gomp_debug (0, "%s: mapnum=%lu, hostaddrs=%p, sizes=%p, kinds=%p, async=%d\n",
- __FUNCTION__, (unsigned long) mapnum, hostaddrs, sizes, kinds,
- async);
+ gomp_debug (0, "%s: mapnum=%lu, hostaddrs=%p, sizes=%p, kinds=%p\n",
+ __FUNCTION__, (unsigned long) mapnum, hostaddrs, sizes, kinds);
#endif
goacc_lazy_initialize ();
@@ -105,12 +103,51 @@ GOACC_parallel (int device, void (*fn) (void *),
return;
}
- if (num_waits)
+ va_start (ap, kinds);
+ /* TODO: This will need amending when device_type is implemented. */
+ while ((tag = va_arg (ap, unsigned)) != 0)
{
- va_start (ap, num_waits);
- goacc_wait (async, num_waits, ap);
- va_end (ap);
+ if (GOMP_LAUNCH_DEVICE (tag))
+ gomp_fatal ("device_type '%d' offload parameters, libgomp is too old",
+ GOMP_LAUNCH_DEVICE (tag));
+
+ switch (GOMP_LAUNCH_CODE (tag))
+ {
+ case GOMP_LAUNCH_DIM:
+ {
+ unsigned mask = GOMP_LAUNCH_OP (tag);
+
+ for (i = 0; i != GOMP_DIM_MAX; i++)
+ if (mask & GOMP_DIM_MASK (i))
+ dims[i] = va_arg (ap, unsigned);
+ }
+ break;
+
+ case GOMP_LAUNCH_ASYNC:
+ {
+ /* Small constant values are encoded in the operand. */
+ async = GOMP_LAUNCH_OP (tag);
+
+ if (async == GOMP_LAUNCH_OP_MAX)
+ async = va_arg (ap, unsigned);
+ break;
+ }
+
+ case GOMP_LAUNCH_WAIT:
+ {
+ unsigned num_waits = GOMP_LAUNCH_OP (tag);
+
+ if (num_waits)
+ goacc_wait (async, num_waits, &ap);
+ break;
+ }
+
+ default:
+ gomp_fatal ("unrecognized offload code '%d',"
+ " libgomp is too old", GOMP_LAUNCH_CODE (tag));
+ }
}
+ va_end (ap);
acc_dev->openacc.async_set_async_func (async);
@@ -138,9 +175,8 @@ GOACC_parallel (int device, void (*fn) (void *),
devaddrs[i] = (void *) (tgt->list[i]->tgt->tgt_start
+ tgt->list[i]->tgt_offset);
- acc_dev->openacc.exec_func (tgt_fn, mapnum, hostaddrs, devaddrs, sizes, kinds,
- num_gangs, num_workers, vector_length, async,
- tgt);
+ acc_dev->openacc.exec_func (tgt_fn, mapnum, hostaddrs, devaddrs, sizes,
+ kinds, async, dims, tgt);
/* If running synchronously, unmap immediately. */
if (async < acc_async_noval)
@@ -154,6 +190,20 @@ GOACC_parallel (int device, void (*fn) (void *),
acc_dev->openacc.async_set_async_func (acc_async_sync);
}
+/* Legacy entry point, only provide host execution. */
+
+void
+GOACC_parallel (int device, void (*fn) (void *),
+ size_t mapnum, void **hostaddrs, size_t *sizes,
+ unsigned short *kinds,
+ int num_gangs, int num_workers, int vector_length,
+ int async, int num_waits, ...)
+{
+ goacc_save_and_set_bind (acc_device_host);
+ fn (hostaddrs);
+ goacc_restore_bind ();
+}
+
void
GOACC_data_start (int device, size_t mapnum,
void **hostaddrs, size_t *sizes, unsigned short *kinds)
@@ -230,7 +280,7 @@ GOACC_enter_exit_data (int device, size_t mapnum,
va_list ap;
va_start (ap, num_waits);
- goacc_wait (async, num_waits, ap);
+ goacc_wait (async, num_waits, &ap);
va_end (ap);
}
@@ -344,15 +394,15 @@ GOACC_enter_exit_data (int device, size_t mapnum,
}
static void
-goacc_wait (int async, int num_waits, va_list ap)
+goacc_wait (int async, int num_waits, va_list *ap)
{
struct goacc_thread *thr = goacc_thread ();
struct gomp_device_descr *acc_dev = thr->dev;
while (num_waits--)
{
- int qid = va_arg (ap, int);
-
+ int qid = va_arg (*ap, int);
+
if (acc_async_test (qid))
continue;
@@ -389,7 +439,7 @@ GOACC_update (int device, size_t mapnum,
va_list ap;
va_start (ap, num_waits);
- goacc_wait (async, num_waits, ap);
+ goacc_wait (async, num_waits, &ap);
va_end (ap);
}
@@ -430,7 +480,7 @@ GOACC_wait (int async, int num_waits, ...)
va_list ap;
va_start (ap, num_waits);
- goacc_wait (async, num_waits, ap);
+ goacc_wait (async, num_waits, &ap);
va_end (ap);
}
else if (async == acc_async_sync)