]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Tweak error return value for acc_set_cuda_stream.
authorJulian Brown <julian@codesourcery.com>
Tue, 12 Feb 2019 14:36:03 +0000 (06:36 -0800)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Fri, 12 May 2023 18:13:43 +0000 (19:13 +0100)
The return value of acc_set_cuda_stream is unspecified in OpenACC 2.6.
The testsuite changes might be unnecessary with the current async code.

libgomp/
* oacc-cuda.c (acc_set_cuda_stream): Return 0 on error/invalid
arguments.
* testsuite/libgomp.oacc-c-c++-common/lib-84.c: Handle unnumbered
async stream being an alias for a numbered async stream.
* testsuite/libgomp.oacc-c-c++-common/lib-85.c: Likewise.

libgomp/ChangeLog.omp
libgomp/oacc-cuda.c
libgomp/testsuite/libgomp.oacc-c-c++-common/lib-84.c
libgomp/testsuite/libgomp.oacc-c-c++-common/lib-85.c

index 1bfebcb32170734512f5e0756a397b1307810252..2769eb88dad686ad5a698456e73dffecdd1db1d3 100644 (file)
@@ -1,3 +1,11 @@
+2019-02-12  Julian Brown <julian@codesourcery.com>
+
+       * oacc-cuda.c (acc_set_cuda_stream): Return 0 on error/invalid
+       arguments.
+       * testsuite/libgomp.oacc-c-c++-common/lib-84.c: Handle unnumbered
+       async stream being an alias for a numbered async stream.
+       * testsuite/libgomp.oacc-c-c++-common/lib-85.c: Likewise.
+
 2020-04-19  Chung-Lin Tang  <cltang@codesourcery.com>
 
        PR other/76739
index 314b2da592d29074a80cc7d418b9f05b2efc24db..b0c9251754046272c214f4c8b77779021c4cd5f1 100644 (file)
@@ -115,6 +115,9 @@ acc_get_cuda_stream (int async)
   return ret;
 }
 
+/* As of OpenACC 2.6, the return code of this function appears to be
+   unspecified.  We choose to return 1 for success, or 0 for failure.  */
+
 int
 acc_set_cuda_stream (int async, void *stream)
 {
@@ -127,7 +130,7 @@ acc_set_cuda_stream (int async, void *stream)
 
   thr = goacc_thread ();
 
-  int ret = -1;
+  int ret = 0;
   if (thr && thr->dev && thr->dev->openacc.cuda.set_stream_func)
     {
       acc_prof_info prof_info;
index c1ff76372fcbecb2bdc659f917d72b210c518214..674e09a251dcabdb2d804b675aa7599035fa6704 100644 (file)
@@ -39,6 +39,12 @@ main (int argc, char **argv)
       if (streams[i] != NULL)
        abort ();
 
+      /* The no-value async may be an alias for a numbered async stream.
+        Skip over setting it below else the above NULL check will fail for
+        the aliased stream.  */
+      if (i == acc_async_noval)
+       continue;
+
       r = cuStreamCreate (&streams[i], CU_STREAM_DEFAULT);
       if (r != CUDA_SUCCESS)
        {
index db250657ac5b7e3460ba812fb37759edefad8045..4e5c7b1b9057b869645efde5c4b319a00f275e8b 100644 (file)
@@ -39,6 +39,12 @@ main (int argc, char **argv)
       if (streams[i] != NULL)
        abort ();
 
+      /* The no-value async may be an alias for a numbered async stream.
+         Skip over setting it below else the above NULL check will fail for
+         the aliased stream.  */
+      if (i == acc_async_noval)
+       continue;
+
       r = cuStreamCreate (&streams[i], CU_STREAM_DEFAULT);
       if (r != CUDA_SUCCESS)
        {