11#if defined(WIN32) || defined(_WIN32)
13#define delay() Sleep(1);
14#define seten(a,b,c) _putenv_s((a),(b))
17#define delay() usleep(10);
18#define seten(a,b,c) setenv((a),(b),(c))
33typedef unsigned long long u64;
56static id loc = {0, 2, 0, 0,
";file;func;0;0;;"};
66 static int volatile loop_sync = 0;
72 int tid = omp_get_thread_num();
75 int tc = (loop_ub - loop_lb) / loop_st + 1;
84 printf(
"run_loop gtid %d tid %d (lb=%d, ub=%d, st=%d, ch=%d)\n",
85 gtid, tid, (
int)loop_lb, (
int)loop_ub, (
int)loop_st, lchunk);
90 if (loop_st > 0 ? loop_lb > loop_ub : loop_lb < loop_ub)
93 loop_lb, loop_ub, loop_st,
SIMD_LEN);
103 max = (loop_ub - loop_lb) / loop_st + 1;
108 printf(
"th %d: chunk=%d, lb=%d, ub=%d ch %d\n",
109 tid, chunk, (
int)lb, (
int)ub, (
int)(ub-lb+1));
113 printf(
"Error with chunk %d, th %d, err %d\n", chunk, tid, ++
err);
115 if (!(ub <= loop_ub))
116 printf(
"Error with ub %d, %d, ch %d, err %d\n",
117 (
int)ub, (
int)loop_ub, chunk, ++
err);
119 printf(
"Error with bounds %d, %d, %d, err %d\n",
120 (
int)lb, (
int)ub, chunk, ++
err);
122 if (!(ub >= loop_ub))
123 printf(
"Error with ub %d, %d, %d, err %d\n",
124 (
int)ub, (
int)loop_ub, chunk, ++
err);
126 printf(
"Error with bounds %d, %d, %d, err %d\n",
127 (
int)lb, (
int)ub, chunk, ++
err);
130 if (!(st == loop_st))
131 printf(
"Error with st %d, %d, ch %d, err %d\n",
132 (
int)st, (
int)loop_st, chunk, ++
err);
133 cur = ( ub - lb ) / loop_st + 1;
136 if (!( cur <= max + 1))
137 printf(
"Error with iter %llu, %llu, err %d\n", cur, max, ++
err);
140 if (!no_chunk && cur > ch && nthreads > 1)
141 printf(
"Error: too big last chunk %d (%d), tid %d, err %d\n",
142 (
int)cur, ch, tid, ++
err);
145 printf(
"Error with chunk %d, %d, ch %d, tid %d, err %d\n",
146 chunk, (
int)cur, ch, tid, ++
err);
151 undersized = (cur < ch);
154 printf(
"under%d cur %d, ch %d, tid %d, ub %d, lb %d, st %d =======\n",
155 undersized,cur,ch,tid,ub,lb,loop_st);
160 if (!(last_ub <= loop_ub))
161 printf(
"Error with last1 %d, %d, ch %d, err %d\n",
162 (
int)last_ub, (
int)loop_ub, chunk, ++
err);
163 if (last && !(last_ub + loop_st > loop_ub))
164 printf(
"Error with last2 %d, %d, %d, ch %d, err %d\n",
165 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk, ++
err);
167 if (!(last_ub >= loop_ub))
168 printf(
"Error with last1 %d, %d, ch %d, err %d\n",
169 (
int)last_ub, (
int)loop_ub, chunk, ++
err);
170 if (last && !(last_ub + loop_st < loop_ub))
171 printf(
"Error with last2 %d, %d, %d, ch %d, err %d\n",
172 (
int)last_ub, (
int)loop_st, (
int)loop_ub, chunk, ++
err);
178int main(
int argc,
char *argv[])
182 char *
buf = malloc(8 + strlen(argv[1]));
184 chunk = atoi(argv[1]);
185 strcpy(
buf,
"static,");
188 printf(
"Testing schedule(simd:%s)\n",
buf);
191 seten(
"OMP_SCHEDULE",
"static",1);
192 printf(
"Testing schedule(simd:static)\n");
197 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()