| 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_alloctrait_t traits5[2] |
| 36 |
= { { omp_atk_fallback, omp_atv_null_fb }, |
| 37 |
{ omp_atk_pool_size, 4096 } }; |
| 38 |
omp_allocator_handle_t a, a2; |
| 39 |
|
| 40 |
if ((((uintptr_t) p) % __alignof (int)) != 0) |
| 41 |
abort (); |
| 42 |
p[0] = 1; |
| 43 |
p[1] = 2; |
| 44 |
p[2] = 3; |
| 45 |
p = (int *) omp_realloc (p, 4 * sizeof (int), omp_default_mem_alloc, omp_default_mem_alloc); |
| 46 |
if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] != 1 || p[1] != 2 || p[2] != 3) |
| 47 |
abort (); |
| 48 |
p[0] = 4; |
| 49 |
p[1] = 5; |
| 50 |
p[2] = 6; |
| 51 |
p[3] = 7; |
| 52 |
p = (int *) omp_realloc (p, 2 * sizeof (int), omp_default_mem_alloc, omp_default_mem_alloc); |
| 53 |
if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] != 4 || p[1] != 5) |
| 54 |
abort (); |
| 55 |
p[0] = 8; |
| 56 |
p[1] = 9; |
| 57 |
if (omp_realloc (p, 0, omp_null_allocator, omp_default_mem_alloc) != NULL) |
| 58 |
abort (); |
| 59 |
p = (int *) omp_realloc (NULL, 2 * sizeof (int), omp_default_mem_alloc, omp_null_allocator); |
| 60 |
if ((((uintptr_t) p) % __alignof (int)) != 0) |
| 61 |
abort (); |
| 62 |
p[0] = 1; |
| 63 |
p[1] = 2; |
| 64 |
p = (int *) omp_realloc (p, 5 * sizeof (int), omp_default_mem_alloc, omp_default_mem_alloc); |
| 65 |
if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] != 1 || p[1] != 2) |
| 66 |
abort (); |
| 67 |
p[0] = 3; |
| 68 |
p[1] = 4; |
| 69 |
p[2] = 5; |
| 70 |
p[3] = 6; |
| 71 |
p[4] = 7; |
| 72 |
omp_free (p, omp_null_allocator); |
| 73 |
omp_set_default_allocator (omp_default_mem_alloc); |
| 74 |
if (omp_realloc (NULL, 0, omp_null_allocator, omp_null_allocator) != NULL) |
| 75 |
abort (); |
| 76 |
p = (int *) omp_alloc (sizeof (int), omp_null_allocator); |
| 77 |
if ((((uintptr_t) p) % __alignof (int)) != 0) |
| 78 |
abort (); |
| 79 |
p[0] = 3; |
| 80 |
p = (int *) omp_realloc (p, 3 * sizeof (int), omp_null_allocator, omp_null_allocator); |
| 81 |
if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] != 3) |
| 82 |
abort (); |
| 83 |
p[0] = 4; |
| 84 |
p[1] = 5; |
| 85 |
p[2] = 6; |
| 86 |
if (omp_realloc (p, 0, omp_null_allocator, omp_get_default_allocator ()) != NULL) |
| 87 |
abort (); |
| 88 |
a = omp_init_allocator (omp_default_mem_space, 3, traits); |
| 89 |
if (a == omp_null_allocator) |
| 90 |
abort (); |
| 91 |
p = (int *) omp_alloc (sizeof (int), a); |
| 92 |
if ((((uintptr_t) p) % 64) != 0) |
| 93 |
abort (); |
| 94 |
p[0] = 7; |
| 95 |
p = (int *) omp_realloc (p, 3072, a, a); |
| 96 |
if ((((uintptr_t) p) % 64) != 0 || p[0] != 7) |
| 97 |
abort (); |
| 98 |
p[0] = 1; |
| 99 |
p[3071 / sizeof (int)] = 2; |
| 100 |
q = (int *) omp_alloc (sizeof (int), a); |
| 101 |
if ((((uintptr_t) q) % 64) != 0) |
| 102 |
abort (); |
| 103 |
q[0] = 8; |
| 104 |
if (omp_realloc (q, 3072, a, a) != NULL) |
| 105 |
abort (); |
| 106 |
omp_free (p, a); |
| 107 |
omp_free (q, a); |
| 108 |
p = (int *) omp_alloc (sizeof (int), a); |
| 109 |
p[0] = 42; |
| 110 |
p = (int *) omp_realloc (p, 3072, a, a); |
| 111 |
if (p[0] != 42) |
| 112 |
abort (); |
| 113 |
p[0] = 3; |
| 114 |
p[3071 / sizeof (int)] = 4; |
| 115 |
omp_realloc (p, 0, omp_null_allocator, omp_null_allocator); |
| 116 |
omp_set_default_allocator (a); |
| 117 |
if (omp_get_default_allocator () != a) |
| 118 |
abort (); |
| 119 |
p = (int *) omp_alloc (31, omp_null_allocator); |
| 120 |
if (p == NULL) |
| 121 |
abort (); |
| 122 |
p = (int *) omp_realloc (p, 3072, omp_null_allocator, omp_null_allocator); |
| 123 |
if (p == NULL) |
| 124 |
abort (); |
| 125 |
q = (int *) omp_alloc (sizeof (int), omp_null_allocator); |
| 126 |
if (q == NULL) |
| 127 |
abort (); |
| 128 |
if (omp_realloc (q, 3072, omp_null_allocator, omp_null_allocator) != NULL) |
| 129 |
abort (); |
| 130 |
omp_free (p, a); |
| 131 |
omp_free (q, a); |
| 132 |
omp_destroy_allocator (a); |
| 133 |
|
| 134 |
a = omp_init_allocator (omp_default_mem_space, 2, traits5); |
| 135 |
if (a == omp_null_allocator) |
| 136 |
abort (); |
| 137 |
omp_set_default_allocator (a); |
| 138 |
if (omp_get_default_allocator () != a) |
| 139 |
abort (); |
| 140 |
p = (int *) omp_alloc (3071, omp_null_allocator); |
| 141 |
if (p == NULL) |
| 142 |
abort (); |
| 143 |
p = (int *) omp_realloc (p, 3072, omp_null_allocator, omp_null_allocator); |
| 144 |
if (p == NULL) |
| 145 |
abort (); |
| 146 |
q = (int *) omp_alloc (sizeof (int), omp_null_allocator); |
| 147 |
if (q == NULL) |
| 148 |
abort (); |
| 149 |
if (omp_realloc (q, 3072, omp_null_allocator, omp_null_allocator) != NULL) |
| 150 |
abort (); |
| 151 |
omp_free (p, a); |
| 152 |
omp_free (q, a); |
| 153 |
omp_destroy_allocator (a); |
| 154 |
|
| 155 |
a = omp_init_allocator (omp_default_mem_space, |
| 156 |
sizeof (traits2) / sizeof (traits2[0]), |
| 157 |
traits2); |
| 158 |
if (a == omp_null_allocator) |
| 159 |
abort (); |
| 160 |
if (traits3[5].key != omp_atk_fb_data) |
| 161 |
abort (); |
| 162 |
traits3[5].value = (uintptr_t) a; |
| 163 |
a2 = omp_init_allocator (omp_default_mem_space, |
| 164 |
sizeof (traits3) / sizeof (traits3[0]), |
| 165 |
traits3); |
| 166 |
if (a2 == omp_null_allocator) |
| 167 |
abort (); |
| 168 |
p = (int *) omp_alloc (sizeof (int), a2); |
| 169 |
if ((((uintptr_t) p) % 32) != 0) |
| 170 |
abort (); |
| 171 |
p[0] = 84; |
| 172 |
p = (int *) omp_realloc (p, 380, a2, a2); |
| 173 |
if ((((uintptr_t) p) % 32) != 0 || p[0] != 84) |
| 174 |
abort (); |
| 175 |
p[0] = 5; |
| 176 |
p[379 / sizeof (int)] = 6; |
| 177 |
q = (int *) omp_alloc (sizeof (int), a2); |
| 178 |
if ((((uintptr_t) q) % 32) != 0) |
| 179 |
abort (); |
| 180 |
q[0] = 42; |
| 181 |
q = (int *) omp_realloc (q, 768, a2, a2); |
| 182 |
if ((((uintptr_t) q) % 16) != 0 || q[0] != 42) |
| 183 |
abort (); |
| 184 |
q[0] = 7; |
| 185 |
q[767 / sizeof (int)] = 8; |
| 186 |
r = (int *) omp_realloc (NULL, 512, a2, omp_null_allocator); |
| 187 |
if ((((uintptr_t) r) % __alignof (int)) != 0) |
| 188 |
abort (); |
| 189 |
r[0] = 9; |
| 190 |
r[511 / sizeof (int)] = 10; |
| 191 |
omp_free (p, omp_null_allocator); |
| 192 |
omp_free (q, a2); |
| 193 |
omp_free (r, omp_null_allocator); |
| 194 |
p = (int *) omp_alloc (sizeof (int), a2); |
| 195 |
if ((((uintptr_t) p) % 32) != 0) |
| 196 |
abort (); |
| 197 |
p[0] = 85; |
| 198 |
p = (int *) omp_realloc (p, 320, a, a2); |
| 199 |
if ((((uintptr_t) p) % 16) != 0 || p[0] != 85) |
| 200 |
abort (); |
| 201 |
p[0] = 5; |
| 202 |
p[319 / sizeof (int)] = 6; |
| 203 |
q = (int *) omp_alloc (sizeof (int), a); |
| 204 |
if ((((uintptr_t) q) % 16) != 0) |
| 205 |
abort (); |
| 206 |
q[0] = 43; |
| 207 |
q = (int *) omp_realloc (q, 320, a2, a); |
| 208 |
if ((((uintptr_t) q) % 32) != 0 || q[0] != 43) |
| 209 |
abort (); |
| 210 |
q[0] = 44; |
| 211 |
q[319 / sizeof (int)] = 8; |
| 212 |
q = (int *) omp_realloc (q, 568, a2, a2); |
| 213 |
if ((((uintptr_t) q) % 16) != 0 || q[0] != 44) |
| 214 |
abort (); |
| 215 |
q[0] = 7; |
| 216 |
q[567 / sizeof (int)] = 8; |
| 217 |
omp_free (p, omp_null_allocator); |
| 218 |
omp_free (q, a2); |
| 219 |
omp_destroy_allocator (a2); |
| 220 |
omp_destroy_allocator (a); |
| 221 |
|
| 222 |
a = omp_init_allocator (omp_default_mem_space, |
| 223 |
sizeof (traits4) / sizeof (traits4[0]), |
| 224 |
traits4); |
| 225 |
if (a == omp_null_allocator) |
| 226 |
abort (); |
| 227 |
if (traits3[5].key != omp_atk_fb_data) |
| 228 |
abort (); |
| 229 |
traits3[5].value = (uintptr_t) a; |
| 230 |
a2 = omp_init_allocator (omp_default_mem_space, |
| 231 |
sizeof (traits3) / sizeof (traits3[0]), |
| 232 |
traits3); |
| 233 |
if (a2 == omp_null_allocator) |
| 234 |
abort (); |
| 235 |
omp_set_default_allocator (a2); |
| 236 |
#ifdef __cplusplus |
| 237 |
p = static_cast <int *> (omp_realloc (NULL, 420)); |
| 238 |
#else |
| 239 |
p = (int *) omp_realloc (NULL, 420, omp_null_allocator, omp_null_allocator); |
| 240 |
#endif |
| 241 |
if ((((uintptr_t) p) % 32) != 0) |
| 242 |
abort (); |
| 243 |
p[0] = 5; |
| 244 |
p[419 / sizeof (int)] = 6; |
| 245 |
q = (int *) omp_realloc (NULL, sizeof (int), omp_null_allocator, omp_null_allocator); |
| 246 |
if ((((uintptr_t) q) % 32) != 0) |
| 247 |
abort (); |
| 248 |
q[0] = 99; |
| 249 |
q = (int *) omp_realloc (q, 700, omp_null_allocator, omp_null_allocator); |
| 250 |
if ((((uintptr_t) q) % 128) != 0 || q[0] != 99) |
| 251 |
abort (); |
| 252 |
q[0] = 7; |
| 253 |
q[699 / sizeof (int)] = 8; |
| 254 |
if (omp_realloc (NULL, 768, omp_null_allocator, omp_null_allocator) != NULL) |
| 255 |
abort (); |
| 256 |
#ifdef __cplusplus |
| 257 |
omp_free (p); |
| 258 |
if (omp_realloc (q, 0) != NULL) |
| 259 |
abort (); |
| 260 |
omp_free (NULL); |
| 261 |
#else |
| 262 |
omp_free (p, omp_null_allocator); |
| 263 |
if (omp_realloc (q, 0, omp_null_allocator, omp_null_allocator) != NULL) |
| 264 |
abort (); |
| 265 |
omp_free (NULL, omp_null_allocator); |
| 266 |
#endif |
| 267 |
omp_free (NULL, omp_null_allocator); |
| 268 |
omp_destroy_allocator (a2); |
| 269 |
omp_destroy_allocator (a); |
| 270 |
return 0; |
| 271 |
} |