1 /* TODO: move to ../libgomp.c-c++-common once C++ is implemented. */
2 /* NOTE: { target c } is unsupported with with the C compiler. */
5 /* { dg-additional-options "-fdump-tree-gimple" } */
10 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_alloc \\(" 5 "gimple" } } */
11 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(" 5 "gimple" } } */
17 #pragma omp allocate(sum)
18 /* { dg-final { scan-tree-dump-times "sum\\.\[0-9\]+ = __builtin_GOMP_alloc \\(4, 4, 0B\\);" 1 "gimple" } } */
19 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(sum\\.\[0-9\]+, 0B\\);" 1 "gimple" } } */
21 /* NOTE: Initializer cannot be omp_init_allocator - as 'A' is
22 in the same scope and the auto-omp_free comes later than
23 any omp_destroy_allocator. */
24 omp_allocator_handle_t my_allocator
= omp_low_lat_mem_alloc
;
27 #pragma omp allocate(A) align(128) allocator(my_allocator)
28 /* { dg-final { scan-tree-dump-times "A\\.\[0-9\]+ = __builtin_GOMP_alloc \\(128, _\[0-9\]+, my_allocator\\);" 1 "gimple" } } */
29 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(A\\.\[0-9\]+, 0B\\);" 1 "gimple" } } */
31 if (((intptr_t)A
) % 128 != 0)
33 for (int i
= 0; i
< n
; ++i
)
36 omp_alloctrait_t traits
[1] = { { omp_atk_alignment
, 64 } };
37 my_allocator
= omp_init_allocator(omp_low_lat_mem_space
,1,traits
);
40 int C
[5] = {1,2,3,4,5};
41 #pragma omp allocate(B,C) allocator(my_allocator)
42 /* { dg-final { scan-tree-dump-times "B\\.\[0-9\]+ = __builtin_GOMP_alloc \\(\[0-9\]+, _\[0-9\]+, my_allocator\\);" 1 "gimple" } } */
43 /* { dg-final { scan-tree-dump-times "C\\.\[0-9\]+ = __builtin_GOMP_alloc \\(\[0-9\]+, 20, my_allocator\\);" 1 "gimple" } } */
44 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(B\\.\[0-9\]+, 0B\\);" 1 "gimple" } } */
45 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(C\\.\[0-9\]+, 0B\\);" 1 "gimple" } } */
47 int D
[5] = {11,22,33,44,55};
48 #pragma omp allocate(D) align(256)
49 /* { dg-final { scan-tree-dump-times "D\\.\[0-9\]+ = __builtin_GOMP_alloc \\(256, 20, 0B\\);" 1 "gimple" } } */
50 /* { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(D\\.\[0-9\]+, 0B\\);" 1 "gimple" } } */
52 if (((intptr_t) B
) % 64 != 0)
54 if (((intptr_t) C
) % 64 != 0)
56 if (((intptr_t) D
) % 64 != 0)
59 for (int i
= 0; i
< 5; ++i
)
63 if (D
[i
] != i
+1 + 10*(i
+1))
67 for (int i
= 0; i
< n
; ++i
)
71 sum
+= A
[i
]+B
[i
]+C
[i
%5]+D
[i
%5];
74 omp_destroy_allocator (my_allocator
);