11#include " kmp/runtime.hpp"
2- #include " kmp/types.h"
32#include " kmp/team.hpp"
3+ #include " kmp/types.h"
4+
5+ using kmp::Mutex;
46
57extern " C" {
68#include " runtime.h"
79
8- // NOLINTBEGIN(bugprone-reserved-identifier)
9-
10- void __kmpc_barrier (ident_t *loc, kmp_int32 global_tid) {
11- // DEBUG_PRINT("__kmpc_barrier called by %d\n", global_tid);
12- kmp::runtime::getCurrentThread (global_tid)
10+ void __kmpc_barrier (ident_t * /* loc*/ , kmp_int32 global_tid) {
11+ kmp::runtime::getCurrentThread (static_cast <kmp_uint32>(global_tid))
1312 .getCurrentTeam ()
1413 ->getBarrier ()
1514 .wait ();
1615};
1716
1817// Parallel
19- void __kmpc_fork_call (ident_t *loc, kmp_int32 argc, kmpc_micro microtask, ...) {
20- // NOLINTBEGIN(cppcoreguidelines-pro-type-vararg,cppcoreguidelines-pro-bounds-array-to-pointer-decay)
18+ void __kmpc_fork_call (ident_t * /* loc*/ , kmp_int32 argc, kmpc_micro microtask,
19+ ...) {
20+ // NOLINTBEGIN(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
2121 va_list args;
2222 va_start (args, microtask);
2323 kmp::Microtask kmpMicrotask (microtask, args, argc);
2424 va_end (args);
25- // NOLINTEND(cppcoreguidelines-pro-type-vararg,cppcoreguidelines-pro- bounds-array-to-pointer-decay)
25+ // NOLINTEND(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
2626
2727 kmp::runtime::getCurrentThread ().forkCall (std::move (kmpMicrotask));
2828};
@@ -47,22 +47,24 @@ void __kmpc_for_static_init_4u(ident_t *loc, kmp_int32 gtid,
4747 pupper, pstride, incr, chunk);
4848};
4949
50- void __kmpc_for_static_init_8 (ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype,
51- kmp_int64 *plastiter, kmp_int64 *plower,
52- kmp_int64 *pupper, kmp_int64 *pstride,
53- kmp_int64 incr, kmp_int64 chunk) {
50+ void __kmpc_for_static_init_8 (ident_t * /* loc*/ , kmp_int32 /* gtid*/ ,
51+ kmp_int32 /* schedtype*/ ,
52+ kmp_int64 * /* plastiter*/ , kmp_int64 * /* plower*/ ,
53+ kmp_int64 * /* pupper*/ , kmp_int64 * /* pstride*/ ,
54+ kmp_int64 /* incr*/ , kmp_int64 /* chunk*/ ) {
5455 assert (false && " Unsupported loop index type" );
5556};
5657
57- void __kmpc_for_static_init_8u (ident_t *loc, kmp_int32 gtid,
58- kmp_int32 schedtype, kmp_uint64 *plastiter,
59- kmp_uint64 *plower, kmp_uint64 *pupper,
60- kmp_int64 *pstride, kmp_int64 incr,
61- kmp_int64 chunk) {
58+ void __kmpc_for_static_init_8u (ident_t * /* loc*/ , kmp_int32 /* gtid*/ ,
59+ kmp_int32 /* schedtype*/ ,
60+ kmp_uint64 * /* plastiter*/ ,
61+ kmp_uint64 * /* plower*/ , kmp_uint64 * /* pupper*/ ,
62+ kmp_int64 * /* pstride*/ , kmp_int64 /* incr*/ ,
63+ kmp_int64 /* chunk*/ ) {
6264 assert (false && " Unsupported loop index type" );
6365};
6466
65- void __kmpc_for_static_fini (ident_t *loc, kmp_int32 global_tid){};
67+ void __kmpc_for_static_fini (ident_t * /* loc*/ , kmp_int32 /* global_tid*/ ){};
6668
6769// Dynamic loops
6870void __kmpc_dispatch_init_4 (ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype,
@@ -83,75 +85,84 @@ void __kmpc_dispatch_init_4u(ident_t *loc, kmp_int32 gtid, kmp_int32 schedtype,
8385 upper, incr, chunk);
8486}
8587
86- void __kmpc_dispatch_init_8 (ident_t *loc, kmp_int64 gtid,
87- kmp_sched_type schedtype, kmp_int64 lower,
88- kmp_int64 upper, kmp_int64 incr, kmp_int64 chunk) {
88+ void __kmpc_dispatch_init_8 (ident_t * /* loc*/ , kmp_int64 /* gtid*/ ,
89+ kmp_sched_type /* schedtype*/ , kmp_int64 /* lower*/ ,
90+ kmp_int64 /* upper*/ , kmp_int64 /* incr*/ ,
91+ kmp_int64 /* chunk*/ ) {
8992 assert (false && " Unsupported loop index type" );
9093}
9194
92- void __kmpc_dispatch_init_8u (ident_t *loc, kmp_int64 gtid,
93- kmp_sched_type schedtype, kmp_uint64 lower,
94- kmp_uint64 upper, kmp_int64 incr,
95- kmp_int64 chunk) {
95+ void __kmpc_dispatch_init_8u (ident_t * /* loc*/ , kmp_int64 /* gtid*/ ,
96+ kmp_sched_type /* schedtype*/ , kmp_uint64 /* lower*/ ,
97+ kmp_uint64 /* upper*/ , kmp_int64 /* incr*/ ,
98+ kmp_int64 /* chunk*/ ) {
9699 assert (false && " Unsupported loop index type" );
97100}
98101
99102int __kmpc_dispatch_next_4 (ident_t *loc, kmp_int32 gtid, kmp_int32 *plastiter,
100103 kmp_int32 *plower, kmp_int32 *pupper,
101104 kmp_int32 *pstride) {
102- return kmp::runtime::getCurrentThread ().getCurrentTeam ()->dispatchNext (
103- loc, gtid, plastiter, plower, pupper, pstride);
105+ return static_cast <int >(
106+ kmp::runtime::getCurrentThread ().getCurrentTeam ()->dispatchNext (
107+ loc, gtid, plastiter, plower, pupper, pstride));
104108}
105109
106110int __kmpc_dispatch_next_4u (ident_t *loc, kmp_int32 gtid, kmp_int32 *plastiter,
107111 kmp_uint32 *plower, kmp_uint32 *pupper,
108112 kmp_int32 *pstride) {
109- return kmp::runtime::getCurrentThread ().getCurrentTeam ()->dispatchNext (
110- loc, gtid, plastiter, plower, pupper, pstride);
113+ return static_cast <int >(
114+ kmp::runtime::getCurrentThread ().getCurrentTeam ()->dispatchNext (
115+ loc, gtid, plastiter, plower, pupper, pstride));
111116}
112117
113- int __kmpc_dispatch_next_8 (ident_t *loc, kmp_int64 gtid, kmp_int64 *plastiter ,
114- kmp_int64 *plower , kmp_int64 *pupper ,
115- kmp_int64 *pstride) {
118+ int __kmpc_dispatch_next_8 (ident_t * /* loc*/ , kmp_int64 /* gtid*/ ,
119+ kmp_int64 * /* plastiter */ , kmp_int64 * /* plower */ ,
120+ kmp_int64 * /* pupper */ , kmp_int64 * /* pstride*/ ) {
116121 assert (false && " Unsupported loop index type" );
117122}
118123
119- int __kmpc_dispatch_next_8u (ident_t *loc, kmp_int64 gtid, kmp_int64 *plastiter ,
120- kmp_uint64 *plower , kmp_uint64 *pupper ,
121- kmp_int64 *pstride) {
124+ int __kmpc_dispatch_next_8u (ident_t * /* loc*/ , kmp_int64 /* gtid*/ ,
125+ kmp_int64 * /* plastiter */ , kmp_uint64 * /* plower */ ,
126+ kmp_uint64 * /* pupper */ , kmp_int64 * /* pstride*/ ) {
122127 assert (false && " Unsupported loop index type" );
123128}
124129
125- void __kmpc_push_num_threads (ident_t *loc, kmp_int32 global_tid,
130+ void __kmpc_push_num_threads (ident_t * /* loc*/ , kmp_int32 /* global_tid*/ ,
126131 kmp_int32 num_threads) {
127132 kmp::runtime::getCurrentThread ().requestNumThreads (num_threads);
128133};
129134
130135// Critical sections
131- void __kmpc_critical (ident_t *, kmp_int32 gtid, kmp_critical_name *crit) {
136+ void __kmpc_critical (ident_t * /* unused*/ , kmp_int32 /* gtid*/ ,
137+ kmp_critical_name *crit) {
132138 static_assert (sizeof (kmp::Mutex) <= sizeof (kmp_critical_name));
139+
140+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
133141 kmp::Mutex *mutex = reinterpret_cast <kmp::Mutex *>(*crit);
134142 mutex->lock ();
135143};
136144
137- void __kmpc_end_critical (ident_t *, kmp_int32 gtid, kmp_critical_name *crit) {
138- kmp::Mutex *mutex = reinterpret_cast <kmp::Mutex *>(*crit);
145+ void __kmpc_end_critical (ident_t * /* unused*/ , kmp_int32 /* gtid*/ ,
146+ kmp_critical_name *crit) {
147+
148+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
149+ Mutex *mutex = reinterpret_cast <kmp::Mutex *>(*crit);
139150 mutex->unlock ();
140151};
141152
142153// Master
143- kmp_int32 __kmpc_master (ident_t *loc, int32_t gtid) {
154+ kmp_int32 __kmpc_master (ident_t * /* loc*/ , kmp_int32 /* gtid*/ ) {
144155 return static_cast <kmp_int32>(kmp::runtime::getCurrentThread ().getTid () == 0 );
145156};
146157
147- void __kmpc_end_master (ident_t *loc, int32_t gtid){/* NOOP */ };
158+ void __kmpc_end_master (ident_t * /* loc*/ , kmp_int32 /* gtid*/ ){/* NOOP */ };
148159
149160// Single (same as master for now)
150- kmp_int32 __kmpc_single (ident_t *loc, int32_t gtid) {
161+ kmp_int32 __kmpc_single (ident_t * /* loc*/ , kmp_int32 /* gtid*/ ) {
151162 return static_cast <kmp_int32>(kmp::runtime::getCurrentThread ().getTid () == 0 );
152163};
153164
154- void __kmpc_end_single (ident_t *loc, int32_t gtid){/* NOOP */ };
165+ void __kmpc_end_single (ident_t * /* loc*/ , kmp_int32 /* gtid*/ ){/* NOOP */ };
155166
156167// Copyprivate
157168void __kmpc_copyprivate (ident_t *loc, kmp_int32 gtid, size_t cpy_size,
@@ -162,16 +173,17 @@ void __kmpc_copyprivate(ident_t *loc, kmp_int32 gtid, size_t cpy_size,
162173};
163174
164175// Reduction
165- kmp_int32
166- __kmpc_reduce_nowait (ident_t *loc, kmp_int32 global_tid, kmp_int32 num_vars,
167- size_t reduce_size, void *reduce_data,
168- void (*reduce_func)(void *lhs_data, void *rhs_data),
169- kmp_critical_name *lck) {
176+ kmp_int32 __kmpc_reduce_nowait (ident_t * /* loc*/ , kmp_int32 /* global_tid*/ ,
177+ kmp_int32 /* num_vars*/ , size_t /* reduce_size*/ ,
178+ void * /* reduce_data*/ ,
179+ void (* /* reduce_func*/ )(void *lhs_data,
180+ void *rhs_data),
181+ kmp_critical_name * /* lck*/ ) {
170182 return 2 ; // Atomic reduction
171183}
172184
173- void __kmpc_end_reduce_nowait (ident_t *loc, kmp_int32 global_tid,
174- kmp_critical_name *lck) {
185+ void __kmpc_end_reduce_nowait (ident_t * /* loc*/ , kmp_int32 /* global_tid*/ ,
186+ kmp_critical_name * /* lck*/ ) {
175187 /* NOOP */
176188}
177189
@@ -185,13 +197,11 @@ kmp_int32 __kmpc_reduce(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_vars,
185197}
186198
187199void __kmpc_end_reduce (ident_t *loc, kmp_int32 global_tid,
188- kmp_critical_name *lck) {
200+ kmp_critical_name * /* lck*/ ) {
189201 return __kmpc_barrier (loc, global_tid);
190202}
191203
192- kmp_int32 __kmpc_global_thread_num (ident_t *loc) {
193- return mempool_get_core_id ();
204+ kmp_int32 __kmpc_global_thread_num (ident_t * /* loc*/ ) {
205+ return static_cast <kmp_int32>( mempool_get_core_id () );
194206};
195-
196- // NOLINTEND(bugprone-reserved-identifier)
197207}
0 commit comments