summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-20 17:31:46 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-20 17:31:46 +0000
commit933b05823148c458e8c591a9cb8c72cd2c668ab1 (patch)
tree828f194bd1d3ecfa54cee8c29cceabdc3b74ef9d
parent7da522b3c34abcc4e4b31cb6fbec3778c0d39a3f (diff)
downloadgcc-933b05823148c458e8c591a9cb8c72cd2c668ab1.tar.gz
* oacc-parallel.c (GOACC_parallel): Move variadic handling into
wait=-specific if. (GOACC_enter_exit_data, GOACC_update): Use consistent num_waits !=0 condition. (goacc_waits): Move !num_waits handling to ... (GOACC_wait): ... here, the only caller that might have zero waits. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226011 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libgomp/ChangeLog7
-rw-r--r--libgomp/oacc-parallel.c79
2 files changed, 34 insertions, 52 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 6c7b9421320..0628b77d523 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,5 +1,12 @@
2015-07-20 Nathan Sidwell <nathan@codesourcery.com>
+ * oacc-parallel.c (GOACC_parallel): Move variadic handling into
+ wait=-specific if.
+ (GOACC_enter_exit_data, GOACC_update): Use consistent num_waits
+ !=0 condition.
+ (goacc_waits): Move !num_waits handling to ...
+ (GOACC_wait): ... here, the only caller that might have zero waits.
+
* plugin/plugin-nvptx.c (struct targ_fn_descriptor): Move later.
(struct ptx_image_data): Move earlier, add fns field.
(struct ptx_device): Add images and image_lock fields.
diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c
index d8999463d6d..e1ea2c62c44 100644
--- a/libgomp/oacc-parallel.c
+++ b/libgomp/oacc-parallel.c
@@ -105,13 +105,13 @@ GOACC_parallel (int device, void (*fn) (void *),
return;
}
- va_start (ap, num_waits);
+ if (num_waits)
+ {
+ va_start (ap, num_waits);
+ goacc_wait (async, num_waits, ap);
+ va_end (ap);
+ }
- if (num_waits > 0)
- goacc_wait (async, num_waits, ap);
-
- va_end (ap);
-
acc_dev->openacc.async_set_async_func (async);
if (!(acc_dev->capabilities & GOMP_OFFLOAD_CAP_NATIVE_EXEC))
@@ -225,14 +225,12 @@ GOACC_enter_exit_data (int device, size_t mapnum,
|| host_fallback)
return;
- if (num_waits > 0)
+ if (num_waits)
{
va_list ap;
va_start (ap, num_waits);
-
goacc_wait (async, num_waits, ap);
-
va_end (ap);
}
@@ -350,47 +348,21 @@ goacc_wait (int async, int num_waits, va_list ap)
{
struct goacc_thread *thr = goacc_thread ();
struct gomp_device_descr *acc_dev = thr->dev;
- int i;
- assert (num_waits >= 0);
-
- if (async == acc_async_sync && num_waits == 0)
- {
- acc_wait_all ();
- return;
- }
-
- if (async == acc_async_sync && num_waits)
- {
- for (i = 0; i < num_waits; i++)
- {
- int qid = va_arg (ap, int);
-
- if (acc_async_test (qid))
- continue;
-
- acc_wait (qid);
- }
- return;
- }
-
- if (async == acc_async_noval && num_waits == 0)
- {
- acc_dev->openacc.async_wait_all_async_func (acc_async_noval);
- return;
- }
-
- for (i = 0; i < num_waits; i++)
+ while (num_waits--)
{
int qid = va_arg (ap, int);
if (acc_async_test (qid))
continue;
- /* If we're waiting on the same asynchronous queue as we're launching on,
- the queue itself will order work as required, so there's no need to
- wait explicitly. */
- if (qid != async)
+ if (async == acc_async_sync)
+ acc_wait (qid);
+ else if (qid == async)
+ ;/* If we're waiting on the same asynchronous queue as we're
+ launching on, the queue itself will order work as
+ required, so there's no need to wait explicitly. */
+ else
acc_dev->openacc.async_wait_async_func (qid, async);
}
}
@@ -412,14 +384,12 @@ GOACC_update (int device, size_t mapnum,
|| host_fallback)
return;
- if (num_waits > 0)
+ if (num_waits)
{
va_list ap;
va_start (ap, num_waits);
-
goacc_wait (async, num_waits, ap);
-
va_end (ap);
}
@@ -455,13 +425,18 @@ GOACC_update (int device, size_t mapnum,
void
GOACC_wait (int async, int num_waits, ...)
{
- va_list ap;
-
- va_start (ap, num_waits);
-
- goacc_wait (async, num_waits, ap);
+ if (num_waits)
+ {
+ va_list ap;
- va_end (ap);
+ va_start (ap, num_waits);
+ goacc_wait (async, num_waits, ap);
+ va_end (ap);
+ }
+ else if (async == acc_async_sync)
+ acc_wait_all ();
+ else if (async == acc_async_noval)
+ acc_dev->openacc.async_wait_all_async_func (acc_async_noval);
}
int