Snitch Runtime
Loading...
Searching...
No Matches
kmp.h
1// Copyright 2021 ETH Zurich and University of Bologna.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef KMP_H
6#define KMP_H
7
9// debug
11
12#ifdef KMP_DEBUG_LEVEL
13#include "../../../deps/riscv-opcodes/encoding.h"
14#include "printf.h"
15#define _KMP_PRINTF(...) \
16 if (1) { \
17 printf("[kmc] "__VA_ARGS__); \
18 }
19#define KMP_PRINTF(d, ...) \
20 if (KMP_DEBUG_LEVEL >= d) { \
21 _KMP_PRINTF(__VA_ARGS__); \
22 }
23#else
24#define KMP_PRINTF(d, ...)
25#endif
26
28// kmp specific types
29// Code taken from
30// https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp.h
32
38typedef int32_t kmp_int32;
39typedef uint32_t kmp_uint32;
40typedef int64_t kmp_int64;
41typedef uint64_t kmp_uint64;
42typedef kmp_uint64 _kmp_ptr64;
43typedef kmp_uint32 _kmp_ptr32;
44
45typedef struct ident {
46 kmp_int32 reserved_1;
47 kmp_int32 flags;
49 kmp_int32
51 kmp_int32 reserved_3;
52 char const *psource;
56} ident_t;
57
62enum sched_type : kmp_int32 {
63 kmp_sch_lower = 32,
64 kmp_sch_static_chunked = 33,
65 kmp_sch_static = 34,
66 kmp_sch_dynamic_chunked = 35,
67 kmp_sch_guided_chunked = 36,
68 kmp_sch_runtime = 37,
69 kmp_sch_auto = 38,
70 kmp_sch_trapezoidal = 39,
71
72 /* accessible only through KMP_SCHEDULE environment variable */
73 kmp_sch_static_greedy = 40,
74 kmp_sch_static_balanced = 41,
75 /* accessible only through KMP_SCHEDULE environment variable */
76 kmp_sch_guided_iterative_chunked = 42,
77 kmp_sch_guided_analytical_chunked = 43,
78 /* accessible only through KMP_SCHEDULE environment variable */
79 kmp_sch_static_steal = 44,
80
81 /* static with chunk adjustment (e.g., simd) */
82 kmp_sch_static_balanced_chunked = 45,
83 kmp_sch_guided_simd = 46,
84 kmp_sch_runtime_simd = 47,
86 /* accessible only through KMP_SCHEDULE environment variable */
87 kmp_sch_upper,
89 kmp_ord_lower =
90 64,
91 kmp_ord_static_chunked = 65,
92 kmp_ord_static = 66,
93 kmp_ord_dynamic_chunked = 67,
94 kmp_ord_guided_chunked = 68,
95 kmp_ord_runtime = 69,
96 kmp_ord_auto = 70,
97 kmp_ord_trapezoidal = 71,
98 kmp_ord_upper,
100 /* Schedules for Distribute construct */
101 kmp_distribute_static_chunked = 91,
102 kmp_distribute_static = 92,
104 /* For the "nomerge" versions, kmp_dispatch_next*() will always return a
105 single iteration/chunk, even if the loop is serialized. For the schedule
106 types listed above, the entire iteration vector is returned if the loop
107 is serialized. This doesn't work for gcc/gcomp sections. */
108 kmp_nm_lower = 160,
110 kmp_nm_static_chunked =
111 (kmp_sch_static_chunked - kmp_sch_lower + kmp_nm_lower),
112 kmp_nm_static = 162,
113 kmp_nm_dynamic_chunked = 163,
114 kmp_nm_guided_chunked = 164,
115 kmp_nm_runtime = 165,
116 kmp_nm_auto = 166,
117 kmp_nm_trapezoidal = 167,
118
119 /* accessible only through KMP_SCHEDULE environment variable */
120 kmp_nm_static_greedy = 168,
121 kmp_nm_static_balanced = 169,
122 /* accessible only through KMP_SCHEDULE environment variable */
123 kmp_nm_guided_iterative_chunked = 170,
124 kmp_nm_guided_analytical_chunked = 171,
125 kmp_nm_static_steal =
126 172, /* accessible only through OMP_SCHEDULE environment variable */
127
128 kmp_nm_ord_static_chunked = 193,
129 kmp_nm_ord_static = 194,
130 kmp_nm_ord_dynamic_chunked = 195,
131 kmp_nm_ord_guided_chunked = 196,
132 kmp_nm_ord_runtime = 197,
133 kmp_nm_ord_auto = 198,
134 kmp_nm_ord_trapezoidal = 199,
135 kmp_nm_upper,
137 /* Support for OpenMP 4.5 monotonic and nonmonotonic schedule modifiers.
138 Since we need to distinguish the three possible cases (no modifier,
139 monotonic modifier, nonmonotonic modifier), we need separate bits for
140 each modifier. The absence of monotonic does not imply nonmonotonic,
141 especially since 4.5 says that the behaviour of the "no modifier" case is
142 implementation defined in 4.5, but will become "nonmonotonic" in 5.0.
143
144 Since we're passing a full 32 bit value, we can use a couple of high bits
145 for these flags; out of paranoia we avoid the sign bit.
146
147 These modifiers can be or-ed into non-static schedules by the compiler to
148 pass the additional information. They will be stripped early in the
149 processing in __kmp_dispatch_init when setting up schedules, so most of
150 the code won't ever see schedules with these bits set. */
151 kmp_sch_modifier_monotonic =
152 (1 << 29),
153 kmp_sch_modifier_nonmonotonic =
154 (1 << 30),
156#define SCHEDULE_WITHOUT_MODIFIERS(s) \
157 (enum sched_type)( \
158 (s) & ~(kmp_sch_modifier_nonmonotonic | kmp_sch_modifier_monotonic))
159#define SCHEDULE_HAS_MONOTONIC(s) (((s)&kmp_sch_modifier_monotonic) != 0)
160#define SCHEDULE_HAS_NONMONOTONIC(s) (((s)&kmp_sch_modifier_nonmonotonic) != 0)
161#define SCHEDULE_HAS_NO_MODIFIERS(s) \
162 (((s) & (kmp_sch_modifier_nonmonotonic | kmp_sch_modifier_monotonic)) == 0)
163#define SCHEDULE_GET_MODIFIERS(s) \
164 ((enum sched_type)( \
165 (s) & (kmp_sch_modifier_nonmonotonic | kmp_sch_modifier_monotonic)))
166#define SCHEDULE_SET_MODIFIERS(s, m) \
167 (s = (enum sched_type)((kmp_int32)s | (kmp_int32)m))
168#define SCHEDULE_NONMONOTONIC 0
169#define SCHEDULE_MONOTONIC 1
170
171 kmp_sch_default = kmp_sch_static
172};
173
174typedef void (*kmpc_micro)(kmp_int32 *global_tid, kmp_int32 *bound_tid, ...);
175
177// data
179
180extern _kmp_ptr32 *kmpc_args;
181
182#endif /* KMP_H */
Definition interface.h:28
char const * psource
Definition interface.h:35
kmp_int32 reserved_1
Definition interface.h:29
kmp_int32 reserved_2
Definition interface.h:33
kmp_int32 reserved_3
Definition interface.h:34
kmp_int32 flags
Definition interface.h:30