LLVM OpenMP
runtime
test
worksharing
for
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
22
typedef
enum
kmp_sched
{
23
kmp_sched_lower
= 0,
24
kmp_sched_static
= 1,
25
kmp_sched_dynamic
= 2,
26
kmp_sched_guided
= 3,
27
kmp_sched_auto
= 4,
28
kmp_sched_upper_std
= 5,
29
kmp_sched_lower_ext
= 100,
30
kmp_sched_trapezoidal
= 101,
31
#if KMP_STATIC_STEAL_ENABLED
32
kmp_sched_static_steal
= 102,
33
#endif
34
kmp_sched_upper
,
35
kmp_sched_default
=
kmp_sched_static
,
36
kmp_sched_monotonic
= 0x80000000
37
}
kmp_sched_t
;
38
#endif
39
40
// ---------------------------------------------------------------------------
41
42
int
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
54
if
(k >=
kmp_sched_upper_std
&& k <=
kmp_sched_lower_ext
) {
55
continue
;
56
}
57
58
#ifdef DEBUG
59
printf(
"checking kind %u\n"
, k);
60
#endif
61
62
omp_set_schedule
((
omp_sched_t
)k, chunk);
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
}
kmp_sched_t
enum kmp_sched kmp_sched_t
omp_sched_t
omp_sched_t
Definition
kmp.h:4489
kmp_sched
kmp_sched
Definition
kmp.h:317
kmp_sched_upper
@ kmp_sched_upper
Definition
kmp.h:330
kmp_sched_lower
@ kmp_sched_lower
Definition
kmp.h:318
kmp_sched_trapezoidal
@ kmp_sched_trapezoidal
Definition
kmp.h:326
kmp_sched_upper_std
@ kmp_sched_upper_std
Definition
kmp.h:324
kmp_sched_dynamic
@ kmp_sched_dynamic
Definition
kmp.h:321
kmp_sched_auto
@ kmp_sched_auto
Definition
kmp.h:323
kmp_sched_guided
@ kmp_sched_guided
Definition
kmp.h:322
kmp_sched_lower_ext
@ kmp_sched_lower_ext
Definition
kmp.h:325
kmp_sched_default
@ kmp_sched_default
Definition
kmp.h:331
kmp_sched_monotonic
@ kmp_sched_monotonic
Definition
kmp.h:332
kmp_sched_static
@ kmp_sched_static
Definition
kmp.h:320
main
int main()
Definition
kmp_sched_set_get.c:42
kmp_sched_static_steal
@ kmp_sched_static_steal
Definition
kmp_sched_static_steal_ordered.c:14
omp_set_schedule
#define omp_set_schedule
Definition
kmp_stub.cpp:30
err
static int err
Definition
teams-no-par.c:16
Generated on
for LLVM OpenMP by
1.14.0