1 // RUN: %libomp-compile
2 // RUN: env OMP_SCHEDULE=monotonic:dynamic,50 %libomp-run monotonic dynamic 50
3 // RUN: env OMP_SCHEDULE=monotonic:guided,51 %libomp-run monotonic guided 51
4 // RUN: env OMP_SCHEDULE=monotonic:static,52 %libomp-run monotonic static 52
5 // RUN: env OMP_SCHEDULE=nonmonotonic:dynamic,53 %libomp-run nonmonotonic dynamic 53
6 // RUN: env OMP_SCHEDULE=nonmonotonic:guided,54 %libomp-run nonmonotonic guided 54
8 // The test checks OMP 5.0 monotonic/nonmonotonic OMP_SCHEDULE parsing
9 // The nonmonotonic tests see if the parser accepts nonmonotonic, if the
10 // parser doesn't then a static schedule is assumed
18 omp_sched_t
sched_without_modifiers(omp_sched_t sched
) {
19 return (omp_sched_t
)((int)sched
& ~((int)omp_sched_monotonic
));
22 int sched_has_modifiers(omp_sched_t sched
, omp_sched_t modifiers
) {
23 return (int)sched
& (int)modifiers
;
26 // check that sched = hope | modifiers
27 void check_schedule(const char *extra
, const omp_sched_t sched
, int chunk
,
28 omp_sched_t hope_sched
, int hope_chunk
) {
30 if (sched
!= hope_sched
|| chunk
!= hope_chunk
) {
32 printf("Error: %s: schedule: (%d, %d) is not equal to (%d, %d)\n", extra
,
33 (int)hope_sched
, hope_chunk
, (int)sched
, chunk
);
37 omp_sched_t
str2omp_sched(const char *str
) {
38 if (!strcmp(str
, "dynamic"))
39 return omp_sched_dynamic
;
40 if (!strcmp(str
, "static"))
41 return omp_sched_static
;
42 if (!strcmp(str
, "guided"))
43 return omp_sched_guided
;
44 printf("Error: Unknown schedule type: %s\n", str
);
48 int is_monotonic(const char *str
) { return !strcmp(str
, "monotonic"); }
50 int main(int argc
, char **argv
) {
51 int i
, monotonic
, chunk
, ref_chunk
;
52 omp_sched_t sched
, ref_sched
;
55 printf("Error: usage: <executable> monotonic|nonmonotonic <schedule> "
60 monotonic
= is_monotonic(argv
[1]);
61 ref_sched
= str2omp_sched(argv
[2]);
62 ref_chunk
= atoi(argv
[3]);
64 omp_get_schedule(&sched
, &chunk
);
66 if (monotonic
&& !sched_has_modifiers(sched
, omp_sched_monotonic
)) {
67 printf("Error: sched (0x%x) does not have monotonic modifier\n",
71 sched
= sched_without_modifiers(sched
);
72 if (sched
!= ref_sched
) {
73 printf("Error: sched (0x%x) is not 0x%x\n", (int)sched
, (int)ref_sched
);
76 if (chunk
!= ref_chunk
) {
77 printf("Error: chunk is not %d\n", ref_chunk
);