11typedef unsigned long long ull_t;
13int main(
int argc,
char **argv) {
14 int i,
j, lb, ub, stride, nthreads, actual_nthreads, chunk;
16 ull_t counted_iters = 0;
19 fprintf(stderr,
"error: incorrect number of arguments\n");
20 fprintf(stderr,
"usage: %s <lb> <ub> <stride> <chunk>\n", argv[0]);
25 stride = atoi(argv[3]);
26 chunk = atoi(argv[4]);
29 fprintf(stderr,
"error: lb must be less than ub\n");
33 fprintf(stderr,
"error: stride must be positive integer\n");
37 fprintf(stderr,
"error: chunk must be positive integer\n");
40 for (
i = lb;
i < ub;
i += stride)
43 #pragma omp parallel num_threads(nthreads)
48 if (actual_nthreads != nthreads) {
49 printf(
"did not create enough threads, skipping test.\n");
51 #pragma omp for schedule(dynamic, chunk)
52 for (
i = lb;
i < ub;
i += stride) {
59 if (actual_nthreads == nthreads && counted_iters != num_iters) {
60 fprintf(stderr,
"error: wrong number of final iterations counted! "
61 "num_iters=%llu, counted_iters=%llu\n",
62 num_iters, counted_iters);
int omp_get_max_threads()
int omp_get_num_threads()