fortran: Factor the evaluation of MINLOC/MAXLOC's BACK argument
[official-gcc.git] / libgomp / testsuite / libgomp.c / omp_alloc-5.c
blob26bf38c1ca6589992a476c9bb39ae8de520e2c54
1 /* { dg-do run } */
3 /* Test calloc with omp_alloc. */
5 #include <omp.h>
7 #pragma omp requires dynamic_allocators
9 void
10 test (int n, omp_allocator_handle_t allocator)
12 #pragma omp target map(to:n) map(to:allocator)
14 int *a;
15 a = (int *) omp_calloc (n, sizeof (int), allocator);
17 for (int i = 0; i < n; i++)
18 if (a[i] != 0)
20 __builtin_printf ("memory not zeroed at %i\n", i);
21 __builtin_abort ();
24 #pragma omp parallel
25 for (int i = 0; i < n; i++)
26 a[i] = i;
28 for (int i = 0; i < n; i++)
29 if (a[i] != i)
31 __builtin_printf ("data mismatch at %i\n", i);
32 __builtin_abort ();
35 omp_free (a, allocator);
39 int
40 main ()
42 /* omp_low_lat_mem_alloc doesn't actually get low-latency memory on GPU. */
43 omp_alloctrait_t traits[1] = { { omp_atk_access, omp_atv_cgroup } };
44 omp_allocator_handle_t gpu_lowlat;
45 #pragma omp target map(from:gpu_lowlat)
46 gpu_lowlat = omp_init_allocator (omp_low_lat_mem_space, 1, traits);
48 // Smaller than low-latency memory limit
49 test (10, omp_default_mem_alloc);
50 test (10, omp_large_cap_mem_alloc);
51 test (10, omp_const_mem_alloc);
52 test (10, omp_high_bw_mem_alloc);
53 test (10, omp_low_lat_mem_alloc);
54 test (10, gpu_lowlat);
55 test (10, omp_cgroup_mem_alloc);
56 test (10, omp_pteam_mem_alloc);
57 test (10, omp_thread_mem_alloc);
59 // Larger than low-latency memory limit
60 test (100000, omp_default_mem_alloc);
61 test (100000, omp_large_cap_mem_alloc);
62 test (100000, omp_const_mem_alloc);
63 test (100000, omp_high_bw_mem_alloc);
64 test (100000, omp_low_lat_mem_alloc);
65 test (100000, gpu_lowlat);
66 test (100000, omp_cgroup_mem_alloc);
67 test (100000, omp_pteam_mem_alloc);
68 test (100000, omp_thread_mem_alloc);
70 return 0;