3 /* Test calloc with omp_alloc. */
7 #pragma omp requires dynamic_allocators
10 test (int n
, omp_allocator_handle_t allocator
)
12 #pragma omp target map(to:n) map(to:allocator)
15 a
= (int *) omp_calloc (n
, sizeof (int), allocator
);
17 for (int i
= 0; i
< n
; i
++)
20 __builtin_printf ("memory not zeroed at %i\n", i
);
25 for (int i
= 0; i
< n
; i
++)
28 for (int i
= 0; i
< n
; i
++)
31 __builtin_printf ("data mismatch at %i\n", i
);
35 omp_free (a
, allocator
);
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
);