Mercurial > hg > CbC > CbC_gcc
comparison libgomp/testsuite/libgomp.c-c++-common/alloc-1.c @ 152:2b5abeee2509
update gcc11
author | anatofuz |
---|---|
date | Mon, 25 May 2020 07:50:57 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
145:1830386684a0 | 152:2b5abeee2509 |
---|---|
1 #include <omp.h> | |
2 #include <stdint.h> | |
3 #include <stdlib.h> | |
4 | |
5 const omp_alloctrait_t traits2[] | |
6 = { { omp_atk_alignment, 16 }, | |
7 { omp_atk_sync_hint, omp_atv_default }, | |
8 { omp_atk_access, omp_atv_default }, | |
9 { omp_atk_pool_size, 1024 }, | |
10 { omp_atk_fallback, omp_atv_default_mem_fb }, | |
11 { omp_atk_partition, omp_atv_environment } }; | |
12 omp_alloctrait_t traits3[] | |
13 = { { omp_atk_sync_hint, omp_atv_uncontended }, | |
14 { omp_atk_alignment, 32 }, | |
15 { omp_atk_access, omp_atv_all }, | |
16 { omp_atk_pool_size, 512 }, | |
17 { omp_atk_fallback, omp_atv_allocator_fb }, | |
18 { omp_atk_fb_data, 0 }, | |
19 { omp_atk_partition, omp_atv_default } }; | |
20 const omp_alloctrait_t traits4[] | |
21 = { { omp_atk_alignment, 128 }, | |
22 { omp_atk_pool_size, 1024 }, | |
23 { omp_atk_fallback, omp_atv_null_fb } }; | |
24 | |
25 int | |
26 main () | |
27 { | |
28 int *volatile p = (int *) omp_alloc (3 * sizeof (int), omp_default_mem_alloc); | |
29 int *volatile q; | |
30 int *volatile r; | |
31 omp_alloctrait_t traits[3] | |
32 = { { omp_atk_alignment, 64 }, | |
33 { omp_atk_fallback, omp_atv_null_fb }, | |
34 { omp_atk_pool_size, 4096 } }; | |
35 omp_allocator_handle_t a, a2; | |
36 | |
37 if ((((uintptr_t) p) % __alignof (int)) != 0) | |
38 abort (); | |
39 p[0] = 1; | |
40 p[1] = 2; | |
41 p[2] = 3; | |
42 omp_free (p, omp_default_mem_alloc); | |
43 p = (int *) omp_alloc (2 * sizeof (int), omp_default_mem_alloc); | |
44 if ((((uintptr_t) p) % __alignof (int)) != 0) | |
45 abort (); | |
46 p[0] = 1; | |
47 p[1] = 2; | |
48 omp_free (p, omp_null_allocator); | |
49 omp_set_default_allocator (omp_default_mem_alloc); | |
50 p = (int *) omp_alloc (sizeof (int), omp_null_allocator); | |
51 if ((((uintptr_t) p) % __alignof (int)) != 0) | |
52 abort (); | |
53 p[0] = 3; | |
54 omp_free (p, omp_get_default_allocator ()); | |
55 | |
56 a = omp_init_allocator (omp_default_mem_space, 3, traits); | |
57 if (a == omp_null_allocator) | |
58 abort (); | |
59 p = (int *) omp_alloc (3072, a); | |
60 if ((((uintptr_t) p) % 64) != 0) | |
61 abort (); | |
62 p[0] = 1; | |
63 p[3071 / sizeof (int)] = 2; | |
64 if (omp_alloc (3072, a) != NULL) | |
65 abort (); | |
66 omp_free (p, a); | |
67 p = (int *) omp_alloc (3072, a); | |
68 p[0] = 3; | |
69 p[3071 / sizeof (int)] = 4; | |
70 omp_free (p, omp_null_allocator); | |
71 omp_set_default_allocator (a); | |
72 if (omp_get_default_allocator () != a) | |
73 abort (); | |
74 p = (int *) omp_alloc (3072, omp_null_allocator); | |
75 if (omp_alloc (3072, omp_null_allocator) != NULL) | |
76 abort (); | |
77 omp_free (p, a); | |
78 omp_destroy_allocator (a); | |
79 | |
80 a = omp_init_allocator (omp_default_mem_space, | |
81 sizeof (traits2) / sizeof (traits2[0]), | |
82 traits2); | |
83 if (a == omp_null_allocator) | |
84 abort (); | |
85 if (traits3[5].key != omp_atk_fb_data) | |
86 abort (); | |
87 traits3[5].value = (uintptr_t) a; | |
88 a2 = omp_init_allocator (omp_default_mem_space, | |
89 sizeof (traits3) / sizeof (traits3[0]), | |
90 traits3); | |
91 if (a2 == omp_null_allocator) | |
92 abort (); | |
93 p = (int *) omp_alloc (420, a2); | |
94 if ((((uintptr_t) p) % 32) != 0) | |
95 abort (); | |
96 p[0] = 5; | |
97 p[419 / sizeof (int)] = 6; | |
98 q = (int *) omp_alloc (768, a2); | |
99 if ((((uintptr_t) q) % 16) != 0) | |
100 abort (); | |
101 q[0] = 7; | |
102 q[767 / sizeof (int)] = 8; | |
103 r = (int *) omp_alloc (512, a2); | |
104 if ((((uintptr_t) r) % __alignof (int)) != 0) | |
105 abort (); | |
106 r[0] = 9; | |
107 r[511 / sizeof (int)] = 10; | |
108 omp_free (p, omp_null_allocator); | |
109 omp_free (q, a2); | |
110 omp_free (r, omp_null_allocator); | |
111 omp_destroy_allocator (a2); | |
112 omp_destroy_allocator (a); | |
113 | |
114 a = omp_init_allocator (omp_default_mem_space, | |
115 sizeof (traits4) / sizeof (traits4[0]), | |
116 traits4); | |
117 if (a == omp_null_allocator) | |
118 abort (); | |
119 if (traits3[5].key != omp_atk_fb_data) | |
120 abort (); | |
121 traits3[5].value = (uintptr_t) a; | |
122 a2 = omp_init_allocator (omp_default_mem_space, | |
123 sizeof (traits3) / sizeof (traits3[0]), | |
124 traits3); | |
125 if (a2 == omp_null_allocator) | |
126 abort (); | |
127 omp_set_default_allocator (a2); | |
128 #ifdef __cplusplus | |
129 p = static_cast <int *> (omp_alloc (420)); | |
130 #else | |
131 p = (int *) omp_alloc (420, omp_null_allocator); | |
132 #endif | |
133 if ((((uintptr_t) p) % 32) != 0) | |
134 abort (); | |
135 p[0] = 5; | |
136 p[419 / sizeof (int)] = 6; | |
137 q = (int *) omp_alloc (768, omp_null_allocator); | |
138 if ((((uintptr_t) q) % 128) != 0) | |
139 abort (); | |
140 q[0] = 7; | |
141 q[767 / sizeof (int)] = 8; | |
142 if (omp_alloc (768, omp_null_allocator) != NULL) | |
143 abort (); | |
144 #ifdef __cplusplus | |
145 omp_free (p); | |
146 omp_free (q); | |
147 omp_free (NULL); | |
148 #else | |
149 omp_free (p, omp_null_allocator); | |
150 omp_free (q, omp_null_allocator); | |
151 omp_free (NULL, omp_null_allocator); | |
152 #endif | |
153 omp_free (NULL, omp_null_allocator); | |
154 omp_destroy_allocator (a2); | |
155 omp_destroy_allocator (a); | |
156 return 0; | |
157 } |