9#if defined(WIN32) || defined(_WIN32)
11#define delay() Sleep(1);
12#define seten(a,b,c) _putenv_s((a),(b))
15#define delay() usleep(10);
16#define seten(a,b,c) setenv((a),(b),(c))
31typedef unsigned long long u64;
54static id loc = {0, 2, 0, 0,
";file;func;0;0;;"};
64 static int volatile loop_sync = 0;
70 int tid = omp_get_thread_num();
73 int tc = (loop_ub - loop_lb) / loop_st + 1;
82 printf(
"run_loop gtid %d tid %d (lb=%d, ub=%d, st=%d, ch=%d)\n",
83 gtid, tid, (
int)loop_lb, (
int)loop_ub, (
int)loop_st, lchunk);
88 if (loop_st > 0 ? loop_lb > loop_ub : loop_lb < loop_ub)
91 loop_lb, loop_ub, loop_st,
SIMD_LEN);
101 max = (loop_ub - loop_lb) / loop_st + 1;
106 printf(
"th %d: chunk=%d, lb=%d, ub=%d ch %d\n",
107 tid, chunk, (
int)lb, (
int)ub, (
int)(ub-lb+1));
111 printf(
"Error with chunk %d, th %d, err %d\n", chunk, tid, ++
err);
113 if (!(ub <= loop_ub))
114 printf(
"Error with ub %d, %d, ch %d, err %d\n",
115 (
int)ub, (
int)loop_ub, chunk, ++
err);
117 printf(
"Error with bounds %d, %d, %d, err %d\n",
118 (
int)lb, (
int)ub, chunk, ++
err);
120 if (!(ub >= loop_ub))
121 printf(
"Error with ub %d, %d, %d, err %d\n",
122 (
int)ub, (
int)loop_ub, chunk, ++
err);
124 printf(
"Error with bounds %d, %d, %d, err %d\n",
125 (
int)lb, (
int)ub, chunk, ++
err);
128 if (!(st == loop_st))
129 printf(
"Error with st %d, %d, ch %d, err %d\n",
130 (
int)st, (
int)loop_st, chunk, ++
err);
131 cur = ( ub - lb ) / loop_st + 1;
134 if (!( cur <= max + 1))
135 printf(
"Error with iter %llu, %llu, err %d\n", cur, max, ++
err);
138 if (!no_chunk && cur > ch && nthreads > 1)
139 printf(
"Error: too big last chunk %d (%d), tid %d, err %d\n",
140 (
int)cur, ch, tid, ++
err);
143 printf(
"Error with chunk %d, %d, ch %d, tid %d, err %d\n",
144 chunk, (
int)cur, ch, tid, ++
err);
149 undersized = (cur < ch);
152 printf(
"under%d cur %d, ch %d, tid %d, ub %d, lb %d, st %d =======\n",
153 undersized,cur,ch,tid,ub,lb,loop_st);
158 if (!(last_ub <= loop_ub))
159 printf(
"Error with last1 %d, %d, ch %d, err %d\n",
160 (
int)last_ub, (
int)loop_ub, chunk, ++
err);
161 if (last && !(last_ub + loop_st > loop_ub))
162 printf(
"Error with last2 %d, %d, %d, ch %d, err %d\n",
163 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk, ++
err);
165 if (!(last_ub >= loop_ub))
166 printf(
"Error with last1 %d, %d, ch %d, err %d\n",
167 (
int)last_ub, (
int)loop_ub, chunk, ++
err);
168 if (last && !(last_ub + loop_st < loop_ub))
169 printf(
"Error with last2 %d, %d, %d, ch %d, err %d\n",
170 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk, ++
err);
176int main(
int argc,
char *argv[])
216 printf(
"failed, err = %d\n",
err);
void __kmpc_barrier(id *, int gtid)
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)
void run_loop(int loop_lb, int loop_ub, int loop_st, int lchunk)
int __kmpc_global_thread_num(id *)
@ kmp_sch_static_balanced_chunked
int __kmpc_dispatch_next_8(id *, int, void *, void *, void *, void *)
int __kmpc_dispatch_next_4(id *, int, void *, void *, void *, void *)
int omp_get_num_threads()