Skip to content

Commit 64874e5

Browse files
committed
[openmp] Silence warnings when building the LLVM release with MSVC
1 parent 8ef7aaa commit 64874e5

File tree

9 files changed

+84
-15
lines changed

9 files changed

+84
-15
lines changed

openmp/runtime/src/kmp.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,13 +502,21 @@ static inline kmp_sched_t __kmp_sched_without_mods(kmp_sched_t kind) {
502502
}
503503

504504
/* Type to keep runtime schedule set via OMP_SCHEDULE or omp_set_schedule() */
505+
#if KMP_COMPILER_MSVC
506+
#pragma warning(push)
507+
// warning C4201: nonstandard extension used: nameless struct/union
508+
#pragma warning(disable : 4201)
509+
#endif
505510
typedef union kmp_r_sched {
506511
struct {
507512
enum sched_type r_sched_type;
508513
int chunk;
509514
};
510515
kmp_int64 sched;
511516
} kmp_r_sched_t;
517+
#if KMP_COMPILER_MSVC
518+
#pragma warning(pop)
519+
#endif
512520

513521
extern enum sched_type __kmp_sch_map[]; // map OMP 3.0 schedule types with our
514522
// internal schedule types
@@ -602,6 +610,8 @@ typedef int PACKED_REDUCTION_METHOD_T;
602610
#pragma warning(push)
603611
#pragma warning(disable : 271 310)
604612
#endif
613+
// Don't include everything related to NT status code, we'll do that explicitely
614+
#define WIN32_NO_STATUS
605615
#include <windows.h>
606616
#if KMP_MSVC_COMPAT
607617
#pragma warning(pop)
@@ -1897,12 +1907,20 @@ typedef struct KMP_ALIGN_CACHE dispatch_private_info32 {
18971907
// Because of parm1-4 are used together, performance seems to be better
18981908
// if they are on the same cache line (not measured though).
18991909

1910+
#if KMP_COMPILER_MSVC
1911+
#pragma warning(push)
1912+
// warning C4201: nonstandard extension used: nameless struct/union
1913+
#pragma warning(disable : 4201)
1914+
#endif
19001915
struct KMP_ALIGN(32) {
19011916
kmp_int32 parm1;
19021917
kmp_int32 parm2;
19031918
kmp_int32 parm3;
19041919
kmp_int32 parm4;
19051920
};
1921+
#if KMP_COMPILER_MSVC
1922+
#pragma warning(pop)
1923+
#endif
19061924

19071925
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
19081926
kmp_uint32 pchunks;
@@ -1936,12 +1954,20 @@ typedef struct KMP_ALIGN_CACHE dispatch_private_info64 {
19361954
// b) all parm1-4 are in the same cache line.
19371955
// Because of parm1-4 are used together, performance seems to be better
19381956
// if they are in the same line (not measured though).
1957+
#if KMP_COMPILER_MSVC
1958+
#pragma warning(push)
1959+
// warning C4201: nonstandard extension used: nameless struct/union
1960+
#pragma warning(disable : 4201)
1961+
#endif
19391962
struct KMP_ALIGN(32) {
19401963
kmp_int64 parm1;
19411964
kmp_int64 parm2;
19421965
kmp_int64 parm3;
19431966
kmp_int64 parm4;
19441967
};
1968+
#if KMP_COMPILER_MSVC
1969+
#pragma warning(pop)
1970+
#endif
19451971

19461972
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
19471973
kmp_uint64 pchunks;
@@ -2223,6 +2249,11 @@ union KMP_ALIGN_CACHE kmp_barrier_union {
22232249

22242250
typedef union kmp_barrier_union kmp_balign_t;
22252251

2252+
#if KMP_COMPILER_MSVC
2253+
#pragma warning(push)
2254+
// warning C4201: nonstandard extension used: nameless struct/union
2255+
#pragma warning(disable : 4201)
2256+
#endif
22262257
/* Team barrier needs only non-volatile arrived counter */
22272258
union KMP_ALIGN_CACHE kmp_barrier_team_union {
22282259
double b_align; /* use worst case alignment */
@@ -2239,6 +2270,9 @@ union KMP_ALIGN_CACHE kmp_barrier_team_union {
22392270
#endif
22402271
};
22412272
};
2273+
#if KMP_COMPILER_MSVC
2274+
#pragma warning(pop)
2275+
#endif
22422276

22432277
typedef union kmp_barrier_team_union kmp_balign_team_t;
22442278

openmp/runtime/src/kmp_affinity.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ const char *__kmp_hw_get_catalog_string(kmp_hw_t type, bool plural) {
127127
return ((plural) ? KMP_I18N_STR(Threads) : KMP_I18N_STR(Thread));
128128
case KMP_HW_PROC_GROUP:
129129
return ((plural) ? KMP_I18N_STR(ProcGroups) : KMP_I18N_STR(ProcGroup));
130+
default:
131+
return KMP_I18N_STR(Unknown);
130132
}
131-
return KMP_I18N_STR(Unknown);
132133
}
133134

134135
const char *__kmp_hw_get_keyword(kmp_hw_t type, bool plural) {
@@ -157,8 +158,9 @@ const char *__kmp_hw_get_keyword(kmp_hw_t type, bool plural) {
157158
return ((plural) ? "threads" : "thread");
158159
case KMP_HW_PROC_GROUP:
159160
return ((plural) ? "proc_groups" : "proc_group");
161+
default:
162+
return ((plural) ? "unknowns" : "unknown");
160163
}
161-
return ((plural) ? "unknowns" : "unknown");
162164
}
163165

164166
const char *__kmp_hw_get_core_type_string(kmp_hw_core_type_t type) {
@@ -171,8 +173,9 @@ const char *__kmp_hw_get_core_type_string(kmp_hw_core_type_t type) {
171173
case KMP_HW_CORE_TYPE_CORE:
172174
return "Intel(R) Core(TM) processor";
173175
#endif
176+
default:
177+
return "unknown";
174178
}
175-
return "unknown";
176179
}
177180

178181
#if KMP_AFFINITY_SUPPORTED
@@ -1246,9 +1249,10 @@ bool kmp_topology_t::filter_hw_subset() {
12461249
#endif
12471250
case KMP_HW_CORE_TYPE_UNKNOWN:
12481251
return 0;
1252+
default:
1253+
KMP_ASSERT(0);
1254+
return 0;
12491255
}
1250-
KMP_ASSERT(0);
1251-
return 0;
12521256
}
12531257
};
12541258
struct core_eff_indexer {

openmp/runtime/src/kmp_atomic.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,14 @@ void __kmpc_atomic_cmplx4_rd(kmp_cmplx32 *out, ident_t *id_ref, int gtid,
10291029
kmp_cmplx32 __kmpc_atomic_cmplx4_rd(ident_t *id_ref, int gtid,
10301030
kmp_cmplx32 *loc);
10311031
#endif
1032+
1033+
#if KMP_COMPILER_MSVC
1034+
#pragma warning(push)
1035+
// warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns
1036+
// UDT '__kmp_cmplx64_t' which is incompatible with C
1037+
#pragma warning(disable : 4190)
1038+
#endif
1039+
10321040
kmp_cmplx64 __kmpc_atomic_cmplx8_rd(ident_t *id_ref, int gtid,
10331041
kmp_cmplx64 *loc);
10341042
kmp_cmplx80 __kmpc_atomic_cmplx10_rd(ident_t *id_ref, int gtid,
@@ -1589,6 +1597,10 @@ kmp_cmplx128_a16_t __kmpc_atomic_cmplx16_a16_swp(ident_t *id_ref, int gtid,
15891597
#endif
15901598
#endif
15911599

1600+
#if KMP_COMPILER_MSVC
1601+
#pragma warning(pop)
1602+
#endif
1603+
15921604
// Capture routines for mixed types (RHS=float16)
15931605
#if KMP_HAVE_QUAD
15941606

openmp/runtime/src/kmp_barrier.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,9 +2405,10 @@ void __kmp_fork_barrier(int gtid, int tid) {
24052405
#endif /* USE_ITT_BUILD */
24062406
if (team)
24072407

2408-
KA_TRACE(10, ("__kmp_fork_barrier: T#%d(%d:%d) has arrived\n", gtid,
2409-
(team != NULL) ? team->t.t_id : -1, tid));
2410-
2408+
#ifdef KMP_DEBUG
2409+
KA_TRACE(10, ("__kmp_fork_barrier: T#%d(%d:%d) has arrived\n", gtid,
2410+
(team != NULL) ? team->t.t_id : -1, tid));
2411+
#endif
24112412
// th_team pointer only valid for primary thread here
24122413
if (KMP_MASTER_TID(tid)) {
24132414
#if USE_ITT_BUILD && USE_ITT_NOTIFY

openmp/runtime/src/kmp_dispatch.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ template <typename T> struct dispatch_private_infoXX_template {
8181

8282
/* parm[1-4] are used in different ways by different scheduling algorithms */
8383

84+
#if KMP_COMPILER_MSVC
85+
#pragma warning(push)
86+
// warning C4201: nonstandard extension used: nameless struct/union
87+
#pragma warning(disable : 4201)
88+
#endif
8489
// KMP_ALIGN(32) ensures ( if the KMP_ALIGN macro is turned on )
8590
// a) parm3 is properly aligned and
8691
// b) all parm1-4 are in the same cache line.
@@ -92,6 +97,9 @@ template <typename T> struct dispatch_private_infoXX_template {
9297
T parm3;
9398
T parm4;
9499
};
100+
#if KMP_COMPILER_MSVC
101+
#pragma warning(pop)
102+
#endif
95103

96104
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
97105
UT pchunks; // total number of chunks for processes with p-core

openmp/runtime/src/kmp_io.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static HANDLE __kmp_stderr = NULL;
5050
static int __kmp_console_exists = FALSE;
5151
static kmp_str_buf_t __kmp_console_buf;
5252

53+
#if 0
5354
static int is_console(void) {
5455
char buffer[128];
5556
DWORD rc = 0;
@@ -67,6 +68,7 @@ static int is_console(void) {
6768
}
6869
return rc > 0 || err == 0;
6970
}
71+
#endif
7072

7173
void __kmp_close_console(void) {
7274
/* wait until user presses return before closing window */
@@ -84,7 +86,6 @@ void __kmp_close_console(void) {
8486
static void __kmp_redirect_output(void) {
8587
__kmp_acquire_bootstrap_lock(&__kmp_console_lock);
8688

87-
(void)is_console;
8889
if (!__kmp_console_exists) {
8990
HANDLE ho;
9091
HANDLE he;

openmp/runtime/src/kmp_settings.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,10 @@ static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name,
873873
case library_throughput: {
874874
value = "PASSIVE";
875875
} break;
876+
case library_none:
877+
case library_serial: {
878+
value = NULL;
879+
} break;
876880
}
877881
} else {
878882
switch (__kmp_library) {
@@ -885,6 +889,9 @@ static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name,
885889
case library_throughput: {
886890
value = "throughput";
887891
} break;
892+
case library_none: {
893+
value = NULL;
894+
} break;
888895
}
889896
}
890897
if (value != NULL) {
@@ -2003,16 +2010,15 @@ static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
20032010
static inline const char *
20042011
__kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
20052012
switch (type) {
2006-
case KMP_HW_CORE_TYPE_UNKNOWN:
2007-
return "unknown";
20082013
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
20092014
case KMP_HW_CORE_TYPE_ATOM:
20102015
return "intel_atom";
20112016
case KMP_HW_CORE_TYPE_CORE:
20122017
return "intel_core";
20132018
#endif
2019+
default:
2020+
return "unknown";
20142021
}
2015-
return "unknown";
20162022
}
20172023

20182024
#if KMP_AFFINITY_SUPPORTED
@@ -4428,6 +4434,8 @@ static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
44284434
case kmp_sch_auto:
44294435
__kmp_str_buf_print(buffer, "%s,%d'\n", "auto", __kmp_chunk);
44304436
break;
4437+
default:
4438+
break;
44314439
}
44324440
} else {
44334441
switch (sched) {
@@ -4453,6 +4461,8 @@ static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
44534461
case kmp_sch_auto:
44544462
__kmp_str_buf_print(buffer, "%s'\n", "auto");
44554463
break;
4464+
default:
4465+
break;
44564466
}
44574467
}
44584468
} // __kmp_stg_print_omp_schedule

openmp/runtime/src/kmp_wait_release.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,15 +1038,13 @@ static inline void __kmp_null_resume_wrapper(kmp_info_t *thr) {
10381038
case flag_oncore:
10391039
__kmp_resume_oncore(gtid, RCAST(kmp_flag_oncore *, flag));
10401040
break;
1041-
#ifdef KMP_DEBUG
10421041
case flag_unset:
10431042
KF_TRACE(100, ("__kmp_null_resume_wrapper: flag type %d is unset\n", type));
10441043
break;
10451044
default:
10461045
KF_TRACE(100, ("__kmp_null_resume_wrapper: flag type %d does not match any "
10471046
"known flag type\n",
10481047
type));
1049-
#endif
10501048
}
10511049
}
10521050

openmp/runtime/src/z_Windows_NT_util.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
number of running threads in the system. */
2323

2424
#include <ntsecapi.h> // UNICODE_STRING
25+
#undef WIN32_NO_STATUS
2526
#include <ntstatus.h>
2627
#include <psapi.h>
2728
#ifdef _MSC_VER
@@ -1635,7 +1636,7 @@ int __kmp_get_load_balance(int max) {
16351636
// threads on all cores. So, we don't consider the running threads of this
16361637
// process.
16371638
if (pid != 0) {
1638-
for (int i = 0; i < num; ++i) {
1639+
for (ULONG i = 0; i < num; ++i) {
16391640
THREAD_STATE state = spi->Threads[i].State;
16401641
// Count threads that have Ready or Running state.
16411642
// !!! TODO: Why comment does not match the code???

0 commit comments

Comments
 (0)