address-space-1.c 483 B

123456789101112131415161718192021222324
  1. /* Verify OMP instances of variables with address space. */
  2. /* { dg-do run { target i?86-*-* x86_64-*-* } } */
  3. /* { dg-require-effective-target offload_device_nonshared_as } */
  4. #include <assert.h>
  5. int __seg_fs a;
  6. int
  7. main (void)
  8. {
  9. // a = 123; // SIGSEGV
  10. int b;
  11. #pragma omp target map(alloc: a) map(from: b)
  12. {
  13. a = 321; // no SIGSEGV (given 'offload_device_nonshared_as')
  14. asm volatile ("" : : "g" (&a) : "memory");
  15. b = a;
  16. }
  17. assert (b == 321);
  18. return 0;
  19. }