LLVM OpenMP 19.0.0git
omp_monotonic_env.c
Go to the documentation of this file.
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
7
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
11
12#include <stdio.h>
13#include <string.h>
14#include <omp.h>
15
16int err = 0;
17
19 return (omp_sched_t)((int)sched & ~((int)omp_sched_monotonic));
20}
21
23 return (int)sched & (int)modifiers;
24}
25
26// check that sched = hope | modifiers
27void check_schedule(const char *extra, const omp_sched_t sched, int chunk,
28 omp_sched_t hope_sched, int hope_chunk) {
29
30 if (sched != hope_sched || chunk != hope_chunk) {
31 ++err;
32 printf("Error: %s: schedule: (%d, %d) is not equal to (%d, %d)\n", extra,
33 (int)hope_sched, hope_chunk, (int)sched, chunk);
34 }
35}
36
37omp_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);
45 exit(1);
46}
47
48int is_monotonic(const char *str) { return !strcmp(str, "monotonic"); }
49
50int main(int argc, char **argv) {
51 int i, monotonic, chunk, ref_chunk;
52 omp_sched_t sched, ref_sched;
53
54 if (argc != 4) {
55 printf("Error: usage: <executable> monotonic|nonmonotonic <schedule> "
56 "<chunk-size>\n");
57 exit(1);
58 }
59
60 monotonic = is_monotonic(argv[1]);
61 ref_sched = str2omp_sched(argv[2]);
62 ref_chunk = atoi(argv[3]);
63
64 omp_get_schedule(&sched, &chunk);
65
66 if (monotonic && !sched_has_modifiers(sched, omp_sched_monotonic)) {
67 printf("Error: sched (0x%x) does not have monotonic modifier\n",
68 (int)sched);
69 ++err;
70 }
72 if (sched != ref_sched) {
73 printf("Error: sched (0x%x) is not 0x%x\n", (int)sched, (int)ref_sched);
74 ++err;
75 }
76 if (chunk != ref_chunk) {
77 printf("Error: chunk is not %d\n", ref_chunk);
78 ++err;
79 }
80 if (err > 0) {
81 printf("Failed\n");
82 return 1;
83 }
84 printf("Passed\n");
85 return 0;
86}
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d int
omp_sched_t
Definition: kmp.h:4475
@ omp_sched_dynamic
Definition: kmp.h:4477
@ omp_sched_guided
Definition: kmp.h:4478
@ omp_sched_static
Definition: kmp.h:4476
#define i
Definition: kmp_stub.cpp:87
int is_monotonic(const char *str)
int err
int sched_has_modifiers(omp_sched_t sched, omp_sched_t modifiers)
omp_sched_t sched_without_modifiers(omp_sched_t sched)
omp_sched_t str2omp_sched(const char *str)
void check_schedule(const char *extra, const omp_sched_t sched, int chunk, omp_sched_t hope_sched, int hope_chunk)
int main()
Definition: test-touch.c:21