Skip to content

Commit 46262ca

Browse files
committed
[OpenMP] Remove uses of ATOMIC_VAR_INIT
ATOMIC_VAR_INIT has a trivial definition `#define ATOMIC_VAR_INIT(value) (value)`, is deprecated in C17/C++20, and will be removed in newer standards in newer GCC/Clang (e.g. https://reviews.llvm.org/D144196).
1 parent 1c417da commit 46262ca

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

openmp/runtime/src/kmp_global.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ int __kmp_init_counter = 0;
6363
int __kmp_root_counter = 0;
6464
int __kmp_version = 0;
6565

66-
std::atomic<kmp_int32> __kmp_team_counter = ATOMIC_VAR_INIT(0);
67-
std::atomic<kmp_int32> __kmp_task_counter = ATOMIC_VAR_INIT(0);
66+
std::atomic<kmp_int32> __kmp_team_counter = 0;
67+
std::atomic<kmp_int32> __kmp_task_counter = 0;
6868

6969
size_t __kmp_stksize = KMP_DEFAULT_STKSIZE;
7070
#if KMP_USE_MONITOR
@@ -386,7 +386,7 @@ int __kmp_debug_buf_atomic =
386386

387387
char *__kmp_debug_buffer = NULL; /* Debug buffer itself */
388388
std::atomic<int> __kmp_debug_count =
389-
ATOMIC_VAR_INIT(0); /* number of lines printed in buffer so far */
389+
0; /* number of lines printed in buffer so far */
390390
int __kmp_debug_buf_warn_chars =
391391
0; /* Keep track of char increase recommended in warnings */
392392
/* end rotating debug buffer */
@@ -454,7 +454,7 @@ volatile kmp_info_t *__kmp_thread_pool = NULL;
454454
volatile kmp_team_t *__kmp_team_pool = NULL;
455455

456456
KMP_ALIGN_CACHE
457-
std::atomic<int> __kmp_thread_pool_active_nth = ATOMIC_VAR_INIT(0);
457+
std::atomic<int> __kmp_thread_pool_active_nth = 0;
458458

459459
/* -------------------------------------------------
460460
* GLOBAL/ROOT STATE */

openmp/runtime/src/kmp_lock.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ typedef union kmp_tas_lock kmp_tas_lock_t;
138138
// kmp_tas_lock_t xlock = KMP_TAS_LOCK_INITIALIZER( xlock );
139139
#define KMP_TAS_LOCK_INITIALIZER(lock) \
140140
{ \
141-
{ ATOMIC_VAR_INIT(KMP_LOCK_FREE(tas)), 0 } \
141+
{ KMP_LOCK_FREE(tas), 0 } \
142142
}
143143

144144
extern int __kmp_acquire_tas_lock(kmp_tas_lock_t *lck, kmp_int32 gtid);
@@ -276,11 +276,7 @@ typedef union kmp_ticket_lock kmp_ticket_lock_t;
276276
// Note the macro argument. It is important to make var properly initialized.
277277
#define KMP_TICKET_LOCK_INITIALIZER(lock) \
278278
{ \
279-
{ \
280-
ATOMIC_VAR_INIT(true) \
281-
, &(lock), NULL, ATOMIC_VAR_INIT(0U), ATOMIC_VAR_INIT(0U), \
282-
ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(-1) \
283-
} \
279+
{ true, &(lock), NULL, 0U, 0U, 0, -1 } \
284280
}
285281

286282
extern int __kmp_acquire_ticket_lock(kmp_ticket_lock_t *lck, kmp_int32 gtid);

openmp/runtime/src/kmp_taskdeps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// TODO: Any ITT support needed?
3131

3232
#ifdef KMP_SUPPORT_GRAPH_OUTPUT
33-
static std::atomic<kmp_int32> kmp_node_id_seed = ATOMIC_VAR_INIT(0);
33+
static std::atomic<kmp_int32> kmp_node_id_seed = 0;
3434
#endif
3535

3636
static void __kmp_init_node(kmp_depnode_t *node) {

0 commit comments

Comments
 (0)