Debian Codegraph @

gcc/testsuite/c-c++-common/gomp/allocate-9.c

raw
1 typedef enum omp_allocator_handle_t
2 #if __cplusplus >= 201103L
3 : __UINTPTR_TYPE__
4 #endif
5 {
6 omp_null_allocator = 0,
7 omp_default_mem_alloc = 1,
8 omp_large_cap_mem_alloc = 2,
9 omp_const_mem_alloc = 3,
10 omp_high_bw_mem_alloc = 4,
11 omp_low_lat_mem_alloc = 5,
12 omp_cgroup_mem_alloc = 6,
13 omp_pteam_mem_alloc = 7,
14 omp_thread_mem_alloc = 8,
15 __ompx_last_mem_alloc = omp_thread_mem_alloc,
16 __omp_allocator_handle_t_max__ = __UINTPTR_MAX__
17 } omp_allocator_handle_t;
18
19
20 static int A[5] = {1,2,3,4,5};
21 static int A2[5] = {1,2,3,4,5};
22 static int A3[5] = {1,2,3,4,5};
23 static int A4[5] = {1,2,3,4,5};
24 static int A5[5] = {1,2,3,4,5};
25 int B, C, C2, D;
26
27 /* If the following fails because of added predefined allocators, please update
28 - c/c-parser.c's c_parser_omp_allocate
29 - fortran/openmp.cc's is_predefined_allocator
30 - libgomp/env.c's parse_allocator
31 - libgomp/libgomp.texi (document the new values - multiple locations)
32 + ensure that the memory-spaces are also up to date. */
33
34 #pragma omp allocate(A) align(32) allocator((omp_allocator_handle_t) 9) /* { dg-error "'allocator' clause requires a predefined allocator as 'A' is static" "" { xfail c++ } } */
35 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
36
37 // typo in allocator name:
38 #pragma omp allocate(A2) allocator(omp_low_latency_mem_alloc)
39 /* { dg-error "'omp_low_latency_mem_alloc' undeclared here \\(not in a function\\); did you mean 'omp_low_lat_mem_alloc'\\?" "" { target c } .-1 } */
40 /* { dg-error "'omp_low_latency_mem_alloc' was not declared in this scope; did you mean 'omp_low_lat_mem_alloc'\\?" "" { target c++ } .-2 } */
41 /* { dg-error "'allocator' clause required for static variable 'A2'" "" { target c } .-3 } */
42 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-4 } */
43
44 /* align be const multiple of 2 */
45 #pragma omp allocate(A3) align(31) allocator(omp_default_mem_alloc) /* { dg-error "'align' clause argument needs to be positive constant power of two integer expression" } */
46 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
47
48
49 /* allocator missing (required as A is static) */
50 #pragma omp allocate(A4) align(32) /* { dg-error "'allocator' clause required for static variable 'A4'" "" { xfail c++ } } */
51 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
52
53 /* "expression in the clause must be a constant expression that evaluates to one of the
54 predefined memory allocator values -> omp_low_lat_mem_alloc" */
55 #pragma omp allocate(B) allocator((omp_allocator_handle_t) (omp_high_bw_mem_alloc+1)) align(32) /* OK: omp_low_lat_mem_alloc */
56 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
57
58
59 #pragma omp allocate(C) allocator((omp_allocator_handle_t) 2) /* OK: omp_large_cap_mem_alloc */
60 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
61
62
63 #pragma omp allocate(A5) align(32) allocator(omp_null_allocator) /* { dg-error "'allocator' clause requires a predefined allocator as 'A5' is static" "" { xfail c++ } } */
64 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
65
66 #pragma omp allocate(C2) align(32) allocator(omp_large_cap_mem_alloc)
67 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
68
69
70 // allocate directive in same TU
71 int f()
72 {
73 #pragma omp allocate(D) align(32) allocator(omp_large_cap_mem_alloc) /* { dg-error "'allocate' directive must be in the same scope as 'D'" "" { xfail c++ } } */
74 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
75 /* { dg-note "declared here" "" { target c } 25 } */
76 return A[0];
77 }
78
79 int g()
80 {
81 int a2=1, b2=2;
82 #pragma omp allocate(a2)
83 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
84 #pragma omp allocate(a2) /* { dg-error "'a2' already appeared as list item in an 'allocate' directive" "" { xfail c++ } } */
85 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
86 {
87 int c2=3;
88 #pragma omp allocate(c2, b2) /* { dg-error "'allocate' directive must be in the same scope as 'b2'" "" { xfail c++ } } */
89 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
90 /* { dg-note "declared here" "" { target c } .-9 } */
91 return c2+a2+b2;
92 }
93 }
94
95 int h(int q)
96 {
97 #pragma omp allocate(q) /* { dg-error "function parameter 'q' may not appear as list item in an 'allocate' directive" "" { xfail c++ } } */
98 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
99 return q;
100 }
101
102 int
103 k ()
104 {
105 static int var3 = 8;
106 #pragma omp allocate(var3) allocator((omp_allocator_handle_t)-1L) /* { dg-error "'allocator' clause requires a predefined allocator as 'var3' is static" "" { target c } } */
107 /* { dg-message "sorry, unimplemented: '#pragma omp allocate' not yet supported" "" { target c++ } .-1 } */
108 return var3;
109 }