Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / alloc-7.c
blobd66e25ac7d61cca225e22fca54594c1750921c9e
1 #include <omp.h>
2 #include <stdint.h>
3 #include <stdlib.h>
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 } };
25 int
26 main ()
28 int *volatile p = (int *) omp_calloc (3, sizeof (int), omp_default_mem_alloc);
29 int *volatile q;
30 int *volatile r;
31 int i;
32 omp_alloctrait_t traits[3]
33 = { { omp_atk_alignment, 64 },
34 { omp_atk_fallback, omp_atv_null_fb },
35 { omp_atk_pool_size, 4096 } };
36 omp_allocator_handle_t a, a2;
38 if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] || p[1] || p[2])
39 abort ();
40 p[0] = 1;
41 p[1] = 2;
42 p[2] = 3;
43 omp_free (p, omp_default_mem_alloc);
44 p = (int *) omp_calloc (2, sizeof (int), omp_default_mem_alloc);
45 if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0] || p[1])
46 abort ();
47 p[0] = 1;
48 p[1] = 2;
49 omp_free (p, omp_null_allocator);
50 omp_set_default_allocator (omp_default_mem_alloc);
51 p = (int *) omp_calloc (1, sizeof (int), omp_null_allocator);
52 if ((((uintptr_t) p) % __alignof (int)) != 0 || p[0])
53 abort ();
54 p[0] = 3;
55 omp_free (p, omp_get_default_allocator ());
57 a = omp_init_allocator (omp_default_mem_space, 3, traits);
58 if (a == omp_null_allocator)
59 abort ();
60 p = (int *) omp_calloc (3, 1024, a);
61 if ((((uintptr_t) p) % 64) != 0)
62 abort ();
63 for (i = 0; i < 3072 / sizeof (int); i++)
64 if (p[i])
65 abort ();
66 p[0] = 1;
67 p[3071 / sizeof (int)] = 2;
68 if (omp_calloc (1024, 3, a) != NULL)
69 abort ();
70 omp_free (p, a);
71 p = (int *) omp_calloc (512, 6, a);
72 for (i = 0; i < 3072 / sizeof (int); i++)
73 if (p[i])
74 abort ();
75 p[0] = 3;
76 p[3071 / sizeof (int)] = 4;
77 omp_free (p, omp_null_allocator);
78 omp_set_default_allocator (a);
79 if (omp_get_default_allocator () != a)
80 abort ();
81 p = (int *) omp_calloc (12, 256, omp_null_allocator);
82 for (i = 0; i < 3072 / sizeof (int); i++)
83 if (p[i])
84 abort ();
85 if (omp_calloc (128, 24, omp_null_allocator) != NULL)
86 abort ();
87 omp_free (p, a);
88 omp_destroy_allocator (a);
90 a = omp_init_allocator (omp_default_mem_space,
91 sizeof (traits2) / sizeof (traits2[0]),
92 traits2);
93 if (a == omp_null_allocator)
94 abort ();
95 if (traits3[5].key != omp_atk_fb_data)
96 abort ();
97 traits3[5].value = (uintptr_t) a;
98 a2 = omp_init_allocator (omp_default_mem_space,
99 sizeof (traits3) / sizeof (traits3[0]),
100 traits3);
101 if (a2 == omp_null_allocator)
102 abort ();
103 p = (int *) omp_calloc (10, 42, a2);
104 for (i = 0; i < 420 / sizeof (int); i++)
105 if (p[i])
106 abort ();
107 if ((((uintptr_t) p) % 32) != 0)
108 abort ();
109 p[0] = 5;
110 p[419 / sizeof (int)] = 6;
111 q = (int *) omp_calloc (24, 32, a2);
112 if ((((uintptr_t) q) % 16) != 0)
113 abort ();
114 for (i = 0; i < 768 / sizeof (int); i++)
115 if (q[i])
116 abort ();
117 q[0] = 7;
118 q[767 / sizeof (int)] = 8;
119 r = (int *) omp_calloc (128, 4, a2);
120 if ((((uintptr_t) r) % __alignof (int)) != 0)
121 abort ();
122 for (i = 0; i < 512 / sizeof (int); i++)
123 if (r[i])
124 abort ();
125 r[0] = 9;
126 r[511 / sizeof (int)] = 10;
127 omp_free (p, omp_null_allocator);
128 omp_free (q, a2);
129 omp_free (r, omp_null_allocator);
130 omp_destroy_allocator (a2);
131 omp_destroy_allocator (a);
133 a = omp_init_allocator (omp_default_mem_space,
134 sizeof (traits4) / sizeof (traits4[0]),
135 traits4);
136 if (a == omp_null_allocator)
137 abort ();
138 if (traits3[5].key != omp_atk_fb_data)
139 abort ();
140 traits3[5].value = (uintptr_t) a;
141 a2 = omp_init_allocator (omp_default_mem_space,
142 sizeof (traits3) / sizeof (traits3[0]),
143 traits3);
144 if (a2 == omp_null_allocator)
145 abort ();
146 omp_set_default_allocator (a2);
147 #ifdef __cplusplus
148 p = static_cast <int *> (omp_calloc (42, 10));
149 #else
150 p = (int *) omp_calloc (42, 10, omp_null_allocator);
151 #endif
152 if ((((uintptr_t) p) % 32) != 0)
153 abort ();
154 for (i = 0; i < 420 / sizeof (int); i++)
155 if (p[i])
156 abort ();
157 p[0] = 5;
158 p[419 / sizeof (int)] = 6;
159 q = (int *) omp_calloc (32, 24, omp_null_allocator);
160 if ((((uintptr_t) q) % 128) != 0)
161 abort ();
162 for (i = 0; i < 768 / sizeof (int); i++)
163 if (q[i])
164 abort ();
165 q[0] = 7;
166 q[767 / sizeof (int)] = 8;
167 if (omp_calloc (24, 32, omp_null_allocator) != NULL)
168 abort ();
169 #ifdef __cplusplus
170 omp_free (p);
171 omp_free (q);
172 omp_free (NULL);
173 #else
174 omp_free (p, omp_null_allocator);
175 omp_free (q, omp_null_allocator);
176 omp_free (NULL, omp_null_allocator);
177 #endif
178 omp_free (NULL, omp_null_allocator);
179 omp_destroy_allocator (a2);
180 omp_destroy_allocator (a);
181 return 0;