11#if defined(WIN32) || defined(_WIN32)
13#define delay() Sleep(1);
16#define delay() usleep(10);
33typedef unsigned long long u64;
50static id loc = {0, 2, 0, 0,
";file;func;0;0;;"};
58 static int volatile loop_sync = 0;
63 int tid = omp_get_thread_num();
70 printf(
"run_loop_<%d>(lb=%d, ub=%d, st=%d, ch=%d)\n",
71 (
int)
sizeof(
i64), gtid, tid,
72 (
int)loop_lb, (
int)loop_ub, (
int)loop_st, loop_chunk);
77 if (loop_st > 0 ? loop_lb > loop_ub : loop_lb < loop_ub)
81 loop_lb, loop_ub, loop_st, loop_chunk);
93 max = (loop_ub - loop_lb) / loop_st + 1;
98 printf(
"chunk=%d, lb=%d, ub=%d\n", chunk, (
int)lb, (
int)ub);
102 printf(
"Error with chunk %d\n", chunk);
107 printf(
"Error with lb %d, %d, ch %d\n", (
int)lb, (
int)next_lb, chunk);
111 if (!(ub <= loop_ub)) {
112 printf(
"Error with ub %d, %d, ch %d\n", (
int)ub, (
int)loop_ub, chunk);
116 printf(
"Error with bounds %d, %d, %d\n", (
int)lb, (
int)ub, chunk);
120 if (!(ub >= loop_ub)) {
121 printf(
"Error with ub %d, %d, %d\n", (
int)ub, (
int)loop_ub, chunk);
125 printf(
"Error with bounds %d, %d, %d\n", (
int)lb, (
int)ub, chunk);
130 if (!(st == loop_st)) {
131 printf(
"Error with st %d, %d, ch %d\n", (
int)st, (
int)loop_st, chunk);
134 cur = (ub - lb) / loop_st + 1;
137 if (!(cur <= max + 1)) {
138 printf(
"Error with iter %llu, %llu\n", cur, max);
144 next_lb = ub + loop_st;
146 undersized = (cur < loop_chunk);
150 printf(
"Error with chunk %d\n", chunk);
155 if (!(last_ub <= loop_ub)) {
156 printf(
"Error with last1 %d, %d, ch %d\n",
157 (
int)last_ub, (
int)loop_ub, chunk);
160 if (!(last_ub + loop_st > loop_ub)) {
161 printf(
"Error with last2 %d, %d, %d, ch %d\n",
162 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk);
166 if (!(last_ub >= loop_ub)) {
167 printf(
"Error with last1 %d, %d, ch %d\n",
168 (
int)last_ub, (
int)loop_ub, chunk);
171 if (!(last_ub + loop_st < loop_ub)) {
172 printf(
"Error with last2 %d, %d, %d, ch %d\n",
173 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk);
182 for (
i = 0;
i < 1000000; ++
i) {
183 if (loop_sync != 0) {
187 while (loop_sync == 0) {
194 printf(
"Error return value\n");
203 printf(
"run_loop_64(): at the end\n");
211int run_loop_32(
int loop_lb,
int loop_ub,
int loop_st,
int loop_chunk) {
213 static int volatile loop_sync = 0;
218 int tid = omp_get_thread_num();
225 printf(
"run_loop_<%d>(lb=%d, ub=%d, st=%d, ch=%d)\n",
226 (
int)
sizeof(
int), gtid, tid,
227 (
int)loop_lb, (
int)loop_ub, (
int)loop_st, loop_chunk);
232 if (loop_st > 0 ? loop_lb > loop_ub : loop_lb < loop_ub)
236 loop_lb, loop_ub, loop_st, loop_chunk);
248 max = (loop_ub - loop_lb) / loop_st + 1;
253 printf(
"chunk=%d, lb=%d, ub=%d\n", chunk, (
int)lb, (
int)ub);
257 printf(
"Error with chunk %d\n", chunk);
262 printf(
"Error with lb %d, %d, ch %d\n", (
int)lb, (
int)next_lb, chunk);
266 if (!(ub <= loop_ub)) {
267 printf(
"Error with ub %d, %d, ch %d\n", (
int)ub, (
int)loop_ub, chunk);
271 printf(
"Error with bounds %d, %d, %d\n", (
int)lb, (
int)ub, chunk);
275 if (!(ub >= loop_ub)) {
276 printf(
"Error with ub %d, %d, %d\n", (
int)ub, (
int)loop_ub, chunk);
280 printf(
"Error with bounds %d, %d, %d\n", (
int)lb, (
int)ub, chunk);
285 if (!(st == loop_st)) {
286 printf(
"Error with st %d, %d, ch %d\n", (
int)st, (
int)loop_st, chunk);
289 cur = (ub - lb) / loop_st + 1;
292 if (!(cur <= max + 1)) {
293 printf(
"Error with iter %llu, %llu\n", cur, max);
299 next_lb = ub + loop_st;
301 undersized = (cur < loop_chunk);
305 printf(
"Error with chunk %d\n", chunk);
310 if (!(last_ub <= loop_ub)) {
311 printf(
"Error with last1 %d, %d, ch %d\n",
312 (
int)last_ub, (
int)loop_ub, chunk);
315 if (!(last_ub + loop_st > loop_ub)) {
316 printf(
"Error with last2 %d, %d, %d, ch %d\n",
317 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk);
321 if (!(last_ub >= loop_ub)) {
322 printf(
"Error with last1 %d, %d, ch %d\n",
323 (
int)last_ub, (
int)loop_ub, chunk);
326 if (!(last_ub + loop_st < loop_ub)) {
327 printf(
"Error with last2 %d, %d, %d, ch %d\n",
328 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk);
337 for (
i = 0;
i < 1000000; ++
i) {
338 if (loop_sync != 0) {
342 while (loop_sync == 0) {
349 printf(
"Error return value\n");
358 printf(
"run_loop<>(): at the end\n");
369#pragma omp parallel num_threads(num_th)
374 for (st = 1; st <= 3; ++ st) {
375 for (lb = -3 * num_th * st; lb <= 3 * num_th * st; ++ lb) {
376 for (ub = lb; ub < lb + num_th * (chunk+1) * st; ++ ub) {
390#pragma omp parallel num_threads(num_th)
392 int chunk, st, lb, ub;
394 for (st = 1; st <= 3; ++ st) {
395 for (lb = -3 * num_th * st; lb <= 3 * num_th * st; ++ lb) {
396 for (ub = lb; ub < lb + num_th * (chunk+1) * st; ++ ub) {
411 const char *env = getenv(
"LIBOMP_NUM_HIDDEN_HELPER_THREADS");
418 for (n = 1; n <= 4; ++ n) {
423 printf(
"failed with %d errors\n",
err);
void __kmpc_barrier(id *, int gtid)
int run_loop_32(int loop_lb, int loop_ub, int loop_st, int loop_chunk)
void __kmpc_dispatch_init_8(id *, int, enum sched, i64, i64, i64, i64)
void __kmpc_dispatch_init_4(id *, int, enum sched, int, int, int, int)
int __kmpc_global_thread_num(id *)
@ kmp_sch_static_balanced_chunked
int __kmpc_dispatch_next_8(id *, int, void *, void *, void *, void *)
static int __kmp_hidden_helper_threads_num
int __kmpc_dispatch_next_4(id *, int, void *, void *, void *, void *)
int run_loop_64(i64 loop_lb, i64 loop_ub, i64 loop_st, int loop_chunk)