allocate-2.c 575 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <omp.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4. int zero;
  5. omp_allocator_handle_t
  6. allocator (omp_allocator_handle_t h)
  7. {
  8. if (zero)
  9. return h;
  10. else
  11. abort ();
  12. }
  13. omp_allocator_handle_t
  14. align (int a)
  15. {
  16. if (zero)
  17. return omp_default_mem_alloc;
  18. else
  19. abort ();
  20. }
  21. int
  22. main ()
  23. {
  24. int x = 1, y = 2;
  25. #pragma omp parallel num_threads(2) firstprivate (x, y) allocate (allocator (omp_default_mem_alloc) : x) allocate (align (16) : y)
  26. {
  27. if (x != 1 || y != 2)
  28. abort ();
  29. if ((((uintptr_t) &y) & 15) != 0)
  30. abort ();
  31. }
  32. return 0;
  33. }