LLVM OpenMP
20.0.0git
runtime
test
worksharing
for
omp_for_schedule_runtime.c
Go to the documentation of this file.
1
// RUN: %libomp-compile
2
// RUN: env OMP_SCHEDULE=static %libomp-run 1 0
3
// RUN: env OMP_SCHEDULE=static,10 %libomp-run 1 10
4
// RUN: env OMP_SCHEDULE=dynamic %libomp-run 2 1
5
// RUN: env OMP_SCHEDULE=dynamic,11 %libomp-run 2 11
6
// RUN: env OMP_SCHEDULE=guided %libomp-run 3 1
7
// RUN: env OMP_SCHEDULE=guided,12 %libomp-run 3 12
8
// RUN: env OMP_SCHEDULE=auto %libomp-run 4 1
9
// RUN: env OMP_SCHEDULE=trapezoidal %libomp-run 101 1
10
// RUN: env OMP_SCHEDULE=trapezoidal,13 %libomp-run 101 13
11
// RUN: env OMP_SCHEDULE=static_steal %libomp-run 2 1
12
// RUN: env OMP_SCHEDULE=static_steal,14 %libomp-run 2 14
13
14
#include <stdio.h>
15
#include <stdlib.h>
16
#include <math.h>
17
#include "
omp_testsuite.h
"
18
19
int
sum
;
20
char
*
correct_kind_string
;
21
omp_sched_t
correct_kind
;
22
int
correct_chunk_size
;
23
24
int
test_omp_for_runtime
()
25
{
26
int
sum
;
27
int
known_sum;
28
int
chunk_size
;
29
int
error;
30
omp_sched_t
kind;
31
32
sum
= 0;
33
error = 0;
34
known_sum = (
LOOPCOUNT
* (
LOOPCOUNT
+ 1)) / 2;
35
omp_get_schedule(&kind, &
chunk_size
);
36
37
printf(
"omp_get_schedule() returns: Schedule = %d, Chunk Size = %d\n"
,
38
kind,
chunk_size
);
39
if
(kind !=
correct_kind
) {
40
printf(
"kind(%d) != correct_kind(%d)\n"
, kind,
correct_kind
);
41
error = 1;
42
}
43
if
(
chunk_size
!=
correct_chunk_size
) {
44
printf(
"chunk_size(%d) != correct_chunk_size(%d)\n"
,
chunk_size
,
45
correct_chunk_size
);
46
error = 1;
47
}
48
49
#pragma omp parallel
50
{
51
int
i
;
52
#pragma omp for schedule(runtime)
53
for
(
i
= 1;
i
<=
LOOPCOUNT
;
i
++) {
54
#pragma omp critical
55
sum
+=
i
;
56
}
57
}
58
if
(known_sum !=
sum
) {
59
printf(
"Known Sum = %d, Calculated Sum = %d\n"
, known_sum,
sum
);
60
error = 1;
61
}
62
return
!error;
63
}
64
65
int
main
(
int
argc,
char
** argv)
66
{
67
int
i
;
68
int
num_failed=0;
69
if
(argc != 3) {
70
fprintf(stderr,
"usage: %s schedule_kind chunk_size\n"
, argv[0]);
71
fprintf(stderr,
" Run with envirable OMP_SCHEDULE=kind[,chunk_size]\n"
);
72
return
1;
73
}
74
correct_kind
= atoi(argv[1]);
75
correct_chunk_size
= atoi(argv[2]);
76
77
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
78
if
(!
test_omp_for_runtime
()) {
79
num_failed++;
80
}
81
}
82
return
num_failed;
83
}
omp_sched_t
omp_sched_t
Definition:
kmp.h:4503
i
#define i
Definition:
kmp_stub.cpp:87
chunk_size
const int chunk_size
Definition:
omp_for_schedule_dynamic.c:17
correct_chunk_size
int correct_chunk_size
Definition:
omp_for_schedule_runtime.c:22
correct_kind
omp_sched_t correct_kind
Definition:
omp_for_schedule_runtime.c:21
test_omp_for_runtime
int test_omp_for_runtime()
Definition:
omp_for_schedule_runtime.c:24
sum
int sum
Definition:
omp_for_schedule_runtime.c:19
correct_kind_string
char * correct_kind_string
Definition:
omp_for_schedule_runtime.c:20
omp_testsuite.h
LOOPCOUNT
#define LOOPCOUNT
Definition:
omp_testsuite.h:12
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
main
int main()
Definition:
test-touch.c:21
Generated on Wed Jan 29 2025 20:58:03 for LLVM OpenMP by
1.9.6