Skip to content

Commit 8b81524

Browse files
[OpenMP][NFC] libomp: silence warnings on unused variables.
Put declarations/definitions of unused variables under corresponding macros to silence clang build warnings. Differential Revision: https://reviews.llvm.org/D106608
1 parent 0a175ad commit 8b81524

File tree

7 files changed

+37
-31
lines changed

7 files changed

+37
-31
lines changed

openmp/runtime/src/kmp_affinity.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4145,14 +4145,19 @@ int __kmp_aux_set_affinity(void **mask) {
41454145
int __kmp_aux_get_affinity(void **mask) {
41464146
int gtid;
41474147
int retval;
4148+
#if KMP_OS_WINDOWS || KMP_DEBUG
41484149
kmp_info_t *th;
4149-
4150+
#endif
41504151
if (!KMP_AFFINITY_CAPABLE()) {
41514152
return -1;
41524153
}
41534154

41544155
gtid = __kmp_entry_gtid();
4156+
#if KMP_OS_WINDOWS || KMP_DEBUG
41554157
th = __kmp_threads[gtid];
4158+
#else
4159+
(void)gtid; // unused variable
4160+
#endif
41564161
KMP_DEBUG_ASSERT(th->th.th_affin_mask != NULL);
41574162

41584163
KA_TRACE(

openmp/runtime/src/kmp_alloc.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,9 +1924,10 @@ void *___kmp_page_allocate(size_t size KMP_SRC_LOC_DECL) {
19241924
In debug mode, fill the memory block with 0xEF before call to free(). */
19251925
void ___kmp_free(void *ptr KMP_SRC_LOC_DECL) {
19261926
kmp_mem_descr_t descr;
1927+
#if KMP_DEBUG
19271928
kmp_uintptr_t addr_allocated; // Address returned by malloc().
19281929
kmp_uintptr_t addr_aligned; // Aligned address passed by caller.
1929-
1930+
#endif
19301931
KE_TRACE(25,
19311932
("-> __kmp_free( %p ) called from %s:%d\n", ptr KMP_SRC_LOC_PARM));
19321933
KMP_ASSERT(ptr != NULL);
@@ -1938,18 +1939,15 @@ void ___kmp_free(void *ptr KMP_SRC_LOC_DECL) {
19381939
"ptr_aligned=%p, size_aligned=%d\n",
19391940
descr.ptr_allocated, (int)descr.size_allocated,
19401941
descr.ptr_aligned, (int)descr.size_aligned));
1941-
1942+
#if KMP_DEBUG
19421943
addr_allocated = (kmp_uintptr_t)descr.ptr_allocated;
19431944
addr_aligned = (kmp_uintptr_t)descr.ptr_aligned;
1944-
19451945
KMP_DEBUG_ASSERT(addr_aligned % CACHE_LINE == 0);
19461946
KMP_DEBUG_ASSERT(descr.ptr_aligned == ptr);
19471947
KMP_DEBUG_ASSERT(addr_allocated + sizeof(kmp_mem_descr_t) <= addr_aligned);
19481948
KMP_DEBUG_ASSERT(descr.size_aligned < descr.size_allocated);
19491949
KMP_DEBUG_ASSERT(addr_aligned + descr.size_aligned <=
19501950
addr_allocated + descr.size_allocated);
1951-
1952-
#ifdef KMP_DEBUG
19531951
memset(descr.ptr_allocated, 0xEF, descr.size_allocated);
19541952
// Fill memory block with 0xEF, it helps catch using freed memory.
19551953
#endif

openmp/runtime/src/kmp_barrier.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,6 @@ void __kmp_join_barrier(int gtid) {
21622162
kmp_info_t *this_thr = __kmp_threads[gtid];
21632163
kmp_team_t *team;
21642164
kmp_uint nproc;
2165-
kmp_info_t *master_thread;
21662165
int tid;
21672166
#ifdef KMP_DEBUG
21682167
int team_id;
@@ -2184,9 +2183,7 @@ void __kmp_join_barrier(int gtid) {
21842183
tid = __kmp_tid_from_gtid(gtid);
21852184
#ifdef KMP_DEBUG
21862185
team_id = team->t.t_id;
2187-
#endif /* KMP_DEBUG */
2188-
master_thread = this_thr->th.th_team_master;
2189-
#ifdef KMP_DEBUG
2186+
kmp_info_t *master_thread = this_thr->th.th_team_master;
21902187
if (master_thread != team->t.t_threads[0]) {
21912188
__kmp_print_structure();
21922189
}
@@ -2339,8 +2336,6 @@ void __kmp_join_barrier(int gtid) {
23392336
kmp_uint64 cur_time = __itt_get_timestamp();
23402337
ident_t *loc = team->t.t_ident;
23412338
kmp_info_t **other_threads = team->t.t_threads;
2342-
int nproc = this_thr->th.th_team_nproc;
2343-
int i;
23442339
switch (__kmp_forkjoin_frames_mode) {
23452340
case 1:
23462341
__kmp_itt_frame_submit(gtid, this_thr->th.th_frame_time, cur_time, 0,
@@ -2357,7 +2352,7 @@ void __kmp_join_barrier(int gtid) {
23572352
// Set arrive time to zero to be able to check it in
23582353
// __kmp_invoke_task(); the same is done inside the loop below
23592354
this_thr->th.th_bar_arrive_time = 0;
2360-
for (i = 1; i < nproc; ++i) {
2355+
for (kmp_uint i = 1; i < nproc; ++i) {
23612356
delta += (cur_time - other_threads[i]->th.th_bar_arrive_time);
23622357
other_threads[i]->th.th_bar_arrive_time = 0;
23632358
}

openmp/runtime/src/kmp_lock.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,14 +1344,15 @@ static int __kmp_test_queuing_lock_with_checks(kmp_queuing_lock_t *lck,
13441344
}
13451345

13461346
int __kmp_release_queuing_lock(kmp_queuing_lock_t *lck, kmp_int32 gtid) {
1347-
kmp_info_t *this_thr;
13481347
volatile kmp_int32 *head_id_p = &lck->lk.head_id;
13491348
volatile kmp_int32 *tail_id_p = &lck->lk.tail_id;
13501349

13511350
KA_TRACE(1000,
13521351
("__kmp_release_queuing_lock: lck:%p, T#%d entering\n", lck, gtid));
13531352
KMP_DEBUG_ASSERT(gtid >= 0);
1354-
this_thr = __kmp_thread_from_gtid(gtid);
1353+
#if KMP_DEBUG || DEBUG_QUEUING_LOCKS
1354+
kmp_info_t *this_thr = __kmp_thread_from_gtid(gtid);
1355+
#endif
13551356
KMP_DEBUG_ASSERT(this_thr != NULL);
13561357
#ifdef DEBUG_QUEUING_LOCKS
13571358
TRACE_LOCK(gtid + 1, "rel ent");

openmp/runtime/src/kmp_runtime.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5537,7 +5537,6 @@ void __kmp_free_team(kmp_root_t *root,
55375537
int use_hot_team = team == root->r.r_hot_team;
55385538
#if KMP_NESTED_HOT_TEAMS
55395539
int level;
5540-
kmp_hot_team_ptr_t *hot_teams;
55415540
if (master) {
55425541
level = team->t.t_active_level - 1;
55435542
if (master->th.th_teams_microtask) { // in teams construct?
@@ -5551,7 +5550,9 @@ void __kmp_free_team(kmp_root_t *root,
55515550
// team_of_workers before the parallel
55525551
} // team->t.t_level will be increased inside parallel
55535552
}
5554-
hot_teams = master->th.th_hot_teams;
5553+
#if KMP_DEBUG
5554+
kmp_hot_team_ptr_t *hot_teams = master->th.th_hot_teams;
5555+
#endif
55555556
if (level < __kmp_hot_teams_max_level) {
55565557
KMP_DEBUG_ASSERT(team == hot_teams[level].hot_team);
55575558
use_hot_team = 1;

openmp/runtime/src/kmp_tasking.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,9 @@ static void __kmp_task_finish(kmp_int32 gtid, kmp_task_t *task,
825825
kmp_info_t *thread = __kmp_threads[gtid];
826826
kmp_task_team_t *task_team =
827827
thread->th.th_task_team; // might be NULL for serial teams...
828+
#if KMP_DEBUG
828829
kmp_int32 children = 0;
829-
830+
#endif
830831
KA_TRACE(10, ("__kmp_task_finish(enter): T#%d finishing task %p and resuming "
831832
"task %p\n",
832833
gtid, taskdata, resumed_task));
@@ -942,8 +943,10 @@ static void __kmp_task_finish(kmp_int32 gtid, kmp_task_t *task,
942943
taskdata->td_flags.hidden_helper) {
943944
__kmp_release_deps(gtid, taskdata);
944945
// Predecrement simulated by "- 1" calculation
945-
children =
946-
KMP_ATOMIC_DEC(&taskdata->td_parent->td_incomplete_child_tasks) - 1;
946+
#if KMP_DEBUG
947+
children = -1 +
948+
#endif
949+
KMP_ATOMIC_DEC(&taskdata->td_parent->td_incomplete_child_tasks);
947950
KMP_DEBUG_ASSERT(children >= 0);
948951
if (taskdata->td_taskgroup)
949952
KMP_ATOMIC_DEC(&taskdata->td_taskgroup->count);
@@ -2832,15 +2835,14 @@ static kmp_task_t *__kmp_steal_task(kmp_info_t *victim_thr, kmp_int32 gtid,
28322835
// We need to un-mark this victim as a finished victim. This must be done
28332836
// before releasing the lock, or else other threads (starting with the
28342837
// primary thread victim) might be prematurely released from the barrier!!!
2835-
kmp_int32 count;
2836-
2837-
count = KMP_ATOMIC_INC(unfinished_threads);
2838-
2838+
#if KMP_DEBUG
2839+
kmp_int32 count =
2840+
#endif
2841+
KMP_ATOMIC_INC(unfinished_threads);
28392842
KA_TRACE(
28402843
20,
28412844
("__kmp_steal_task: T#%d inc unfinished_threads to %d: task_team=%p\n",
28422845
gtid, count + 1, task_team));
2843-
28442846
*thread_finished = FALSE;
28452847
}
28462848
TCW_4(victim_td->td.td_deque_ntasks, ntasks - 1);
@@ -3032,9 +3034,10 @@ static inline int __kmp_execute_tasks_template(
30323034
// done. This decrement might be to the spin location, and result in the
30333035
// termination condition being satisfied.
30343036
if (!*thread_finished) {
3035-
kmp_int32 count;
3036-
3037-
count = KMP_ATOMIC_DEC(unfinished_threads) - 1;
3037+
#if KMP_DEBUG
3038+
kmp_int32 count = -1 +
3039+
#endif
3040+
KMP_ATOMIC_DEC(unfinished_threads);
30383041
KA_TRACE(20, ("__kmp_execute_tasks_template: T#%d dec "
30393042
"unfinished_threads to %d task_team=%p\n",
30403043
gtid, count, task_team));
@@ -3885,11 +3888,12 @@ static void __kmp_first_top_half_finish_proxy(kmp_taskdata_t *taskdata) {
38853888
}
38863889

38873890
static void __kmp_second_top_half_finish_proxy(kmp_taskdata_t *taskdata) {
3891+
#if KMP_DEBUG
38883892
kmp_int32 children = 0;
3889-
38903893
// Predecrement simulated by "- 1" calculation
3891-
children =
3892-
KMP_ATOMIC_DEC(&taskdata->td_parent->td_incomplete_child_tasks) - 1;
3894+
children = -1 +
3895+
#endif
3896+
KMP_ATOMIC_DEC(&taskdata->td_parent->td_incomplete_child_tasks);
38933897
KMP_DEBUG_ASSERT(children >= 0);
38943898

38953899
// Remove the imaginary children

openmp/runtime/src/z_Linux_util.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,8 @@ void __kmp_reap_worker(kmp_info_t *th) {
10511051
"exit_val = %p\n",
10521052
th->th.th_info.ds.ds_gtid, exit_val));
10531053
}
1054+
#else
1055+
(void)status; // unused variable
10541056
#endif /* KMP_DEBUG */
10551057

10561058
KA_TRACE(10, ("__kmp_reap_worker: done reaping T#%d\n",

0 commit comments

Comments
 (0)