LLVM OpenMP
kmp_sched_set_get.c
Go to the documentation of this file.
1// RUN: %libomp-compile-and-run
2
3// The test checks that every schedule kind accepted by omp_set_schedule(),
4// i.e. that is not considered out of range in __kmp_set_schedule in
5// kmp_runtime.cpp, can be set, and we can afterwards get the schedule back with
6// omp_get_schedule
7
8#include <omp.h>
9#include <stdio.h>
10
11// ---------------------------------------------------------------------------
12// As with kmp.h, static steal is by default enabled, but can be manually
13// disabled. If libomp is built with -DKMP_STATIC_STEAL_ENABLED=0, pass the
14// same flag to the tests (for example through OPENMP_TEST_FLAGS).
15#ifndef KMP_STATIC_STEAL_ENABLED
16#define KMP_STATIC_STEAL_ENABLED 1
17#endif
18
19// These definitions need to match kmp_sched_t in kmp.h.
20#ifndef KMP_SCHED_TYPE_DEFINED
21#define KMP_SCHED_TYPE_DEFINED
38#endif
39
40// ---------------------------------------------------------------------------
41
42int main() {
43 const int chunk = 5;
44 int err = 0;
45 unsigned k;
46
47 // Visit every kind that __kmp_set_schedule() accepts: the standard kinds
48 // between lower and upper_std, and the extension kinds between lower_ext
49 // and upper.
50 for (k = kmp_sched_lower + 1; k < kmp_sched_upper; ++k) {
51 omp_sched_t kind_get;
52 int chunk_get;
53
55 continue;
56 }
57
58#ifdef DEBUG
59 printf("checking kind %u\n", k);
60#endif
61
63 omp_get_schedule(&kind_get, &chunk_get);
64
65 // Check kind and chunk match.
66 // The chunk size is ignored for auto, so allow a mismatched chunk size.
67 if (kind_get != (omp_sched_t)k ||
68 (k != kmp_sched_auto && chunk_get != chunk)) {
69 printf("Error: kind %u: schedule: (%d, %d) is not equal to (%u, %d)\n", k,
70 (int)kind_get, chunk_get, k, chunk);
71 ++err;
72 }
73 }
74
75 if (err > 0) {
76 printf("Failed\n");
77 return 1;
78 }
79 printf("Passed\n");
80 return 0;
81}
enum kmp_sched kmp_sched_t
omp_sched_t
Definition kmp.h:4489
kmp_sched
Definition kmp.h:317
@ kmp_sched_upper
Definition kmp.h:330
@ kmp_sched_lower
Definition kmp.h:318
@ kmp_sched_trapezoidal
Definition kmp.h:326
@ kmp_sched_upper_std
Definition kmp.h:324
@ kmp_sched_dynamic
Definition kmp.h:321
@ kmp_sched_auto
Definition kmp.h:323
@ kmp_sched_guided
Definition kmp.h:322
@ kmp_sched_lower_ext
Definition kmp.h:325
@ kmp_sched_default
Definition kmp.h:331
@ kmp_sched_monotonic
Definition kmp.h:332
@ kmp_sched_static
Definition kmp.h:320
int main()
#define omp_set_schedule
Definition kmp_stub.cpp:30
static int err