fortran: Factor the evaluation of MINLOC/MAXLOC's BACK argument
[official-gcc.git] / libgomp / testsuite / libgomp.c / omp_alloc-3.c
blob682d149d3790aa23c5aad22cfc92ad0debcf9793
1 /* { dg-do run } */
3 /* Stress-test omp_alloc/omp_malloc under concurrency. */
5 #include <omp.h>
6 #include <stdio.h>
7 #include <stdlib.h>
9 #pragma omp requires dynamic_allocators
11 #define N 1000
13 void
14 test (omp_allocator_handle_t allocator)
16 #pragma omp target map(to:allocator)
18 #pragma omp parallel for
19 for (int i = 0; i < N; i++)
20 for (int j = 0; j < N; j++)
22 int *p = omp_alloc (sizeof (int), allocator);
23 omp_free (p, allocator);
28 int
29 main ()
31 /* omp_low_lat_mem_alloc doesn't actually get low-latency memory on GPU. */
32 omp_alloctrait_t traits[1] = { { omp_atk_access, omp_atv_cgroup } };
33 omp_allocator_handle_t gpu_lowlat;
34 #pragma omp target map(from:gpu_lowlat)
35 gpu_lowlat = omp_init_allocator (omp_low_lat_mem_space, 1, traits);
37 // Smaller than low-latency memory limit
38 test (omp_default_mem_alloc);
39 test (omp_large_cap_mem_alloc);
40 test (omp_const_mem_alloc);
41 test (omp_high_bw_mem_alloc);
42 test (omp_low_lat_mem_alloc);
43 test (gpu_lowlat);
44 test (omp_cgroup_mem_alloc);
45 test (omp_pteam_mem_alloc);
46 test (omp_thread_mem_alloc);
48 return 0;