16#if defined(WIN32) || defined(_WIN32)
18#define delay() Sleep(1);
19#define seten(a,b,c) _putenv_s((a),(b))
22#define delay() usleep(10);
23#define seten(a,b,c) setenv((a),(b),(c))
39typedef unsigned long long u64;
62static id loc = {0, 2, 0, 0,
";file;func;0;0;;"};
72 static int volatile loop_sync = 0;
78 int tid = omp_get_thread_num();
81 int tc = (loop_ub - loop_lb) / loop_st + 1;
90 printf(
"run_loop gtid %d tid %d (lb=%d, ub=%d, st=%d, ch=%d)\n",
91 gtid, tid, (
int)loop_lb, (
int)loop_ub, (
int)loop_st, lchunk);
96 if (loop_st > 0 ? loop_lb > loop_ub : loop_lb < loop_ub)
99 loop_lb, loop_ub, loop_st,
SIMD_LEN);
109 max = (loop_ub - loop_lb) / loop_st + 1;
114 printf(
"th %d: chunk=%d, lb=%d, ub=%d ch %d\n",
115 tid, chunk, (
int)lb, (
int)ub, (
int)(ub-lb+1));
119 printf(
"Error with chunk %d, th %d, err %d\n", chunk, tid, ++
err);
121 if (!(ub <= loop_ub))
122 printf(
"Error with ub %d, %d, ch %d, err %d\n",
123 (
int)ub, (
int)loop_ub, chunk, ++
err);
125 printf(
"Error with bounds %d, %d, %d, err %d\n",
126 (
int)lb, (
int)ub, chunk, ++
err);
128 if (!(ub >= loop_ub))
129 printf(
"Error with ub %d, %d, %d, err %d\n",
130 (
int)ub, (
int)loop_ub, chunk, ++
err);
132 printf(
"Error with bounds %d, %d, %d, err %d\n",
133 (
int)lb, (
int)ub, chunk, ++
err);
136 if (!(st == loop_st))
137 printf(
"Error with st %d, %d, ch %d, err %d\n",
138 (
int)st, (
int)loop_st, chunk, ++
err);
139 cur = ( ub - lb ) / loop_st + 1;
142 if (!( cur <= max + 1))
143 printf(
"Error with iter %llu, %llu, err %d\n", cur, max, ++
err);
145 if (!last && cur % ch)
146 printf(
"Error with chunk %d, %d, ch %d, tid %d, err %d\n",
147 chunk, (
int)cur, ch, tid, ++
err);
148 if (last && !no_chunk && cur > ch && nthreads > 1)
149 printf(
"Error: too big last chunk %d (%d), tid %d, err %d\n",
150 (
int)cur, ch, tid, ++
err);
154 undersized = (cur < ch);
157 printf(
"under%d cur %d, ch %d, tid %d, ub %d, lb %d, st %d =======\n",
158 undersized,cur,ch,tid,ub,lb,loop_st);
163 if (!(last_ub <= loop_ub))
164 printf(
"Error with last1 %d, %d, ch %d, err %d\n",
165 (
int)last_ub, (
int)loop_ub, chunk, ++
err);
166 if (last && !(last_ub + loop_st > loop_ub))
167 printf(
"Error with last2 %d, %d, %d, ch %d, err %d\n",
168 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk, ++
err);
170 if (!(last_ub >= loop_ub))
171 printf(
"Error with last1 %d, %d, ch %d, err %d\n",
172 (
int)last_ub, (
int)loop_ub, chunk, ++
err);
173 if (last && !(last_ub + loop_st < loop_ub))
174 printf(
"Error with last2 %d, %d, %d, ch %d, err %d\n",
175 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk, ++
err);
181int main(
int argc,
char *argv[])
186 chunk = atoi(argv[1]);
191 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()