(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.oacc-c-c++-common/
asyncwait-nop-1.c
       1  /* Several of the async/wait combinations invoked here are no-ops -- they don't
       2     effect anything, but are still valid.
       3  
       4     This doesn't verify that the asynchronous operations synchronize correctly,
       5     but just verifies that we don't refuse any variants.  */
       6  
       7  #undef NDEBUG
       8  #include <assert.h>
       9  #include <openacc.h>
      10  
      11  int values[] = { acc_async_sync,
      12  		 acc_async_noval,
      13  		 0,
      14  		 1,
      15  		 2,
      16  		 36,
      17  		 1982, };
      18  const size_t values_n = sizeof values / sizeof values[0];
      19  
      20  int
      21  main ()
      22  {
      23    /* Explicitly initialize: it's not clear whether the following OpenACC
      24       runtime library calls implicitly initialize;
      25       <https://github.com/OpenACC/openacc-spec/issues/102>.  */
      26    acc_device_t d;
      27  #if defined ACC_DEVICE_TYPE_nvidia
      28    d = acc_device_nvidia;
      29  #elif defined ACC_DEVICE_TYPE_radeon
      30    d = acc_device_radeon;
      31  #elif defined ACC_DEVICE_TYPE_host
      32    d = acc_device_host;
      33  #else
      34  # error Not ported to this ACC_DEVICE_TYPE
      35  #endif
      36    acc_init (d);
      37  
      38  
      39    for (size_t i = 0; i < values_n; ++i)
      40      assert (acc_async_test (values[i]) == 1);
      41  
      42  
      43    for (size_t i = 0; i < values_n; ++i)
      44      {
      45  #pragma acc parallel wait (values[i])
      46        ;
      47  #pragma acc wait (values[i])
      48        acc_wait (values[i]);
      49      }
      50  
      51  
      52    for (size_t i = 0; i < values_n; ++i)
      53      {
      54        for (size_t j = 0; j < values_n; ++j)
      55  	{
      56  #pragma acc parallel wait (values[i]) async (values[j])
      57  	  ;
      58  #pragma acc wait (values[i]) async (values[j])
      59  	  acc_wait_async (values[i], values[j]);
      60  	}
      61      }
      62  
      63  
      64    for (size_t i = 0; i < values_n; ++i)
      65      {
      66  #pragma acc parallel wait async (values[i])
      67        ;
      68  #pragma acc wait async (values[i])
      69        acc_wait_all_async (values[i]);
      70      }
      71  
      72  
      73    /* Clean up.  */
      74    acc_wait_all ();
      75  
      76    return 0;
      77  }