target-has-device-addr-6.C 604 B

1234567891011121314151617181920212223242526272829303132
  1. /* Testing 'has_device_addr' clause on the target construct with reference. */
  2. #include <omp.h>
  3. int
  4. main ()
  5. {
  6. int *dpx = (int*)omp_target_alloc (sizeof(int), 0);
  7. double *dpy = (double*)omp_target_alloc (sizeof(double), 0);
  8. #pragma omp target is_device_ptr(dpx, dpy)
  9. {
  10. *dpx = 42;
  11. *dpy = 43.5;
  12. }
  13. int &x = *dpx;
  14. double &y = *dpy;
  15. #pragma omp target has_device_addr(x, y)
  16. {
  17. x = 24;
  18. y = 25.7;
  19. }
  20. #pragma omp target has_device_addr(y, x)
  21. if (x != 24 || y != 25.7)
  22. __builtin_abort ();
  23. omp_target_free(dpx, 0);
  24. omp_target_free(dpy, 0);
  25. }