[Openmp-commits] [openmp] [openmp] Fix warnings when building on Windows with latest MSVC or Clang ToT (PR #77853)
Alexandre Ganea via Openmp-commits
openmp-commits at lists.llvm.org
Sat Jan 20 10:52:06 PST 2024
https://github.com/aganea updated https://github.com/llvm/llvm-project/pull/77853
>From db61229866c124e432943e9309d6df98634e86d4 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Thu, 11 Jan 2024 13:26:28 -0500
Subject: [PATCH 1/6] [openmp] Fix warnings when building on Windows with
latest MSVC or Clang ToT.
---
openmp/runtime/src/kmp.h | 32 ++++++++++++++++++++++++
openmp/runtime/src/kmp_affinity.cpp | 14 +++++++----
openmp/runtime/src/kmp_atomic.h | 12 +++++++++
openmp/runtime/src/kmp_barrier.cpp | 7 +++---
openmp/runtime/src/kmp_dispatch.h | 8 ++++++
openmp/runtime/src/kmp_io.cpp | 3 ++-
openmp/runtime/src/kmp_os.h | 2 ++
openmp/runtime/src/kmp_settings.cpp | 16 +++++++++---
openmp/runtime/src/kmp_wait_release.h | 2 --
openmp/runtime/src/z_Windows_NT_util.cpp | 3 ++-
10 files changed, 84 insertions(+), 15 deletions(-)
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index c287a31e0b1b54..b02ccc8ba837b6 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -502,6 +502,11 @@ static inline kmp_sched_t __kmp_sched_without_mods(kmp_sched_t kind) {
}
/* Type to keep runtime schedule set via OMP_SCHEDULE or omp_set_schedule() */
+#if KMP_COMPILER_MSVC
+#pragma warning(push)
+// warning C4201: nonstandard extension used: nameless struct/union
+#pragma warning(disable : 4201)
+#endif
typedef union kmp_r_sched {
struct {
enum sched_type r_sched_type;
@@ -509,6 +514,9 @@ typedef union kmp_r_sched {
};
kmp_int64 sched;
} kmp_r_sched_t;
+#if KMP_COMPILER_MSVC
+#pragma warning(pop)
+#endif
extern enum sched_type __kmp_sch_map[]; // map OMP 3.0 schedule types with our
// internal schedule types
@@ -1897,12 +1905,20 @@ typedef struct KMP_ALIGN_CACHE dispatch_private_info32 {
// Because of parm1-4 are used together, performance seems to be better
// if they are on the same cache line (not measured though).
+#if KMP_COMPILER_MSVC
+#pragma warning(push)
+// warning C4201: nonstandard extension used: nameless struct/union
+#pragma warning(disable : 4201)
+#endif
struct KMP_ALIGN(32) {
kmp_int32 parm1;
kmp_int32 parm2;
kmp_int32 parm3;
kmp_int32 parm4;
};
+#if KMP_COMPILER_MSVC
+#pragma warning(pop)
+#endif
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
kmp_uint32 pchunks;
@@ -1936,12 +1952,20 @@ typedef struct KMP_ALIGN_CACHE dispatch_private_info64 {
// b) all parm1-4 are in the same cache line.
// Because of parm1-4 are used together, performance seems to be better
// if they are in the same line (not measured though).
+#if KMP_COMPILER_MSVC
+#pragma warning(push)
+// warning C4201: nonstandard extension used: nameless struct/union
+#pragma warning(disable : 4201)
+#endif
struct KMP_ALIGN(32) {
kmp_int64 parm1;
kmp_int64 parm2;
kmp_int64 parm3;
kmp_int64 parm4;
};
+#if KMP_COMPILER_MSVC
+#pragma warning(pop)
+#endif
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
kmp_uint64 pchunks;
@@ -2223,6 +2247,11 @@ union KMP_ALIGN_CACHE kmp_barrier_union {
typedef union kmp_barrier_union kmp_balign_t;
+#if KMP_COMPILER_MSVC
+#pragma warning(push)
+// warning C4201: nonstandard extension used: nameless struct/union
+#pragma warning(disable : 4201)
+#endif
/* Team barrier needs only non-volatile arrived counter */
union KMP_ALIGN_CACHE kmp_barrier_team_union {
double b_align; /* use worst case alignment */
@@ -2239,6 +2268,9 @@ union KMP_ALIGN_CACHE kmp_barrier_team_union {
#endif
};
};
+#if KMP_COMPILER_MSVC
+#pragma warning(pop)
+#endif
typedef union kmp_barrier_team_union kmp_balign_team_t;
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp
index 7009730a49ba7d..673b9f5793b866 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -127,8 +127,9 @@ const char *__kmp_hw_get_catalog_string(kmp_hw_t type, bool plural) {
return ((plural) ? KMP_I18N_STR(Threads) : KMP_I18N_STR(Thread));
case KMP_HW_PROC_GROUP:
return ((plural) ? KMP_I18N_STR(ProcGroups) : KMP_I18N_STR(ProcGroup));
+ default:
+ return KMP_I18N_STR(Unknown);
}
- return KMP_I18N_STR(Unknown);
}
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) {
return ((plural) ? "threads" : "thread");
case KMP_HW_PROC_GROUP:
return ((plural) ? "proc_groups" : "proc_group");
+ default:
+ return ((plural) ? "unknowns" : "unknown");
}
- return ((plural) ? "unknowns" : "unknown");
}
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) {
case KMP_HW_CORE_TYPE_CORE:
return "Intel(R) Core(TM) processor";
#endif
+ default:
+ return "unknown";
}
- return "unknown";
}
#if KMP_AFFINITY_SUPPORTED
@@ -1246,9 +1249,10 @@ bool kmp_topology_t::filter_hw_subset() {
#endif
case KMP_HW_CORE_TYPE_UNKNOWN:
return 0;
+ default:
+ KMP_ASSERT(0);
+ return 0;
}
- KMP_ASSERT(0);
- return 0;
}
};
struct core_eff_indexer {
diff --git a/openmp/runtime/src/kmp_atomic.h b/openmp/runtime/src/kmp_atomic.h
index 4fc51ee4289bd2..1cf17018a958fe 100644
--- a/openmp/runtime/src/kmp_atomic.h
+++ b/openmp/runtime/src/kmp_atomic.h
@@ -1029,6 +1029,14 @@ void __kmpc_atomic_cmplx4_rd(kmp_cmplx32 *out, ident_t *id_ref, int gtid,
kmp_cmplx32 __kmpc_atomic_cmplx4_rd(ident_t *id_ref, int gtid,
kmp_cmplx32 *loc);
#endif
+
+#if KMP_COMPILER_MSVC
+#pragma warning(push)
+// warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns
+// UDT '__kmp_cmplx64_t' which is incompatible with C
+#pragma warning(disable : 4190)
+#endif
+
kmp_cmplx64 __kmpc_atomic_cmplx8_rd(ident_t *id_ref, int gtid,
kmp_cmplx64 *loc);
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,
#endif
#endif
+#if KMP_COMPILER_MSVC
+#pragma warning(pop)
+#endif
+
// Capture routines for mixed types (RHS=float16)
#if KMP_HAVE_QUAD
diff --git a/openmp/runtime/src/kmp_barrier.cpp b/openmp/runtime/src/kmp_barrier.cpp
index 281b8e9c2883d0..c58eb27b109c58 100644
--- a/openmp/runtime/src/kmp_barrier.cpp
+++ b/openmp/runtime/src/kmp_barrier.cpp
@@ -2405,9 +2405,10 @@ void __kmp_fork_barrier(int gtid, int tid) {
#endif /* USE_ITT_BUILD */
if (team)
- KA_TRACE(10, ("__kmp_fork_barrier: T#%d(%d:%d) has arrived\n", gtid,
- (team != NULL) ? team->t.t_id : -1, tid));
-
+#ifdef KMP_DEBUG
+ KA_TRACE(10, ("__kmp_fork_barrier: T#%d(%d:%d) has arrived\n", gtid,
+ (team != NULL) ? team->t.t_id : -1, tid));
+#endif
// th_team pointer only valid for primary thread here
if (KMP_MASTER_TID(tid)) {
#if USE_ITT_BUILD && USE_ITT_NOTIFY
diff --git a/openmp/runtime/src/kmp_dispatch.h b/openmp/runtime/src/kmp_dispatch.h
index cf19eb52662cec..340fe5738c6a82 100644
--- a/openmp/runtime/src/kmp_dispatch.h
+++ b/openmp/runtime/src/kmp_dispatch.h
@@ -81,6 +81,11 @@ template <typename T> struct dispatch_private_infoXX_template {
/* parm[1-4] are used in different ways by different scheduling algorithms */
+#if KMP_COMPILER_MSVC
+#pragma warning(push)
+// warning C4201: nonstandard extension used: nameless struct/union
+#pragma warning(disable : 4201)
+#endif
// KMP_ALIGN(32) ensures ( if the KMP_ALIGN macro is turned on )
// a) parm3 is properly aligned and
// b) all parm1-4 are in the same cache line.
@@ -92,6 +97,9 @@ template <typename T> struct dispatch_private_infoXX_template {
T parm3;
T parm4;
};
+#if KMP_COMPILER_MSVC
+#pragma warning(pop)
+#endif
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
UT pchunks; // total number of chunks for processes with p-core
diff --git a/openmp/runtime/src/kmp_io.cpp b/openmp/runtime/src/kmp_io.cpp
index 578e6e671cdf2d..421bfe7e51f524 100644
--- a/openmp/runtime/src/kmp_io.cpp
+++ b/openmp/runtime/src/kmp_io.cpp
@@ -50,6 +50,7 @@ static HANDLE __kmp_stderr = NULL;
static int __kmp_console_exists = FALSE;
static kmp_str_buf_t __kmp_console_buf;
+#if 0
static int is_console(void) {
char buffer[128];
DWORD rc = 0;
@@ -67,6 +68,7 @@ static int is_console(void) {
}
return rc > 0 || err == 0;
}
+#endif
void __kmp_close_console(void) {
/* wait until user presses return before closing window */
@@ -84,7 +86,6 @@ void __kmp_close_console(void) {
static void __kmp_redirect_output(void) {
__kmp_acquire_bootstrap_lock(&__kmp_console_lock);
- (void)is_console;
if (!__kmp_console_exists) {
HANDLE ho;
HANDLE he;
diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h
index 6862fd89b6302e..1ed3abf745fc98 100644
--- a/openmp/runtime/src/kmp_os.h
+++ b/openmp/runtime/src/kmp_os.h
@@ -306,6 +306,8 @@ template <> struct traits_t<unsigned long long> {
!KMP_MIC)
#if KMP_OS_WINDOWS
+// Don't include everything related to NT status code, we'll do that explicitely
+#define WIN32_NO_STATUS
#include <windows.h>
static inline int KMP_GET_PAGE_SIZE(void) {
diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index 30a4c05fe76b32..6ee9a893b0f846 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -873,6 +873,10 @@ static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name,
case library_throughput: {
value = "PASSIVE";
} break;
+ case library_none:
+ case library_serial: {
+ value = NULL;
+ } break;
}
} else {
switch (__kmp_library) {
@@ -885,6 +889,9 @@ static void __kmp_stg_print_wait_policy(kmp_str_buf_t *buffer, char const *name,
case library_throughput: {
value = "throughput";
} break;
+ case library_none: {
+ value = NULL;
+ } break;
}
}
if (value != NULL) {
@@ -2003,16 +2010,15 @@ static void __kmp_stg_print_foreign_threads_threadprivate(kmp_str_buf_t *buffer,
static inline const char *
__kmp_hw_get_core_type_keyword(kmp_hw_core_type_t type) {
switch (type) {
- case KMP_HW_CORE_TYPE_UNKNOWN:
- return "unknown";
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
case KMP_HW_CORE_TYPE_ATOM:
return "intel_atom";
case KMP_HW_CORE_TYPE_CORE:
return "intel_core";
#endif
+ default:
+ return "unknown";
}
- return "unknown";
}
#if KMP_AFFINITY_SUPPORTED
@@ -4428,6 +4434,8 @@ static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
case kmp_sch_auto:
__kmp_str_buf_print(buffer, "%s,%d'\n", "auto", __kmp_chunk);
break;
+ default:
+ break;
}
} else {
switch (sched) {
@@ -4453,6 +4461,8 @@ static void __kmp_stg_print_omp_schedule(kmp_str_buf_t *buffer,
case kmp_sch_auto:
__kmp_str_buf_print(buffer, "%s'\n", "auto");
break;
+ default:
+ break;
}
}
} // __kmp_stg_print_omp_schedule
diff --git a/openmp/runtime/src/kmp_wait_release.h b/openmp/runtime/src/kmp_wait_release.h
index 3fcae5687d124f..36a28e695dc20c 100644
--- a/openmp/runtime/src/kmp_wait_release.h
+++ b/openmp/runtime/src/kmp_wait_release.h
@@ -1038,7 +1038,6 @@ static inline void __kmp_null_resume_wrapper(kmp_info_t *thr) {
case flag_oncore:
__kmp_resume_oncore(gtid, RCAST(kmp_flag_oncore *, flag));
break;
-#ifdef KMP_DEBUG
case flag_unset:
KF_TRACE(100, ("__kmp_null_resume_wrapper: flag type %d is unset\n", type));
break;
@@ -1046,7 +1045,6 @@ static inline void __kmp_null_resume_wrapper(kmp_info_t *thr) {
KF_TRACE(100, ("__kmp_null_resume_wrapper: flag type %d does not match any "
"known flag type\n",
type));
-#endif
}
}
diff --git a/openmp/runtime/src/z_Windows_NT_util.cpp b/openmp/runtime/src/z_Windows_NT_util.cpp
index 9e264ab45b87f0..d75b48b2c1bcf7 100644
--- a/openmp/runtime/src/z_Windows_NT_util.cpp
+++ b/openmp/runtime/src/z_Windows_NT_util.cpp
@@ -22,6 +22,7 @@
number of running threads in the system. */
#include <ntsecapi.h> // UNICODE_STRING
+#undef WIN32_NO_STATUS
#include <ntstatus.h>
#include <psapi.h>
#ifdef _MSC_VER
@@ -1635,7 +1636,7 @@ int __kmp_get_load_balance(int max) {
// threads on all cores. So, we don't consider the running threads of this
// process.
if (pid != 0) {
- for (int i = 0; i < num; ++i) {
+ for (ULONG i = 0; i < num; ++i) {
THREAD_STATE state = spi->Threads[i].State;
// Count threads that have Ready or Running state.
// !!! TODO: Why comment does not match the code???
>From fc29f9564de29a678e733020bf5e8d254c4a9823 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Mon, 15 Jan 2024 08:23:16 -0500
Subject: [PATCH 2/6] Disable MSVC warnings in cmake instead
---
openmp/cmake/HandleOpenMPOptions.cmake | 9 ++++++++
openmp/runtime/src/kmp.h | 32 --------------------------
openmp/runtime/src/kmp_atomic.h | 11 ---------
openmp/runtime/src/kmp_dispatch.h | 8 -------
4 files changed, 9 insertions(+), 51 deletions(-)
diff --git a/openmp/cmake/HandleOpenMPOptions.cmake b/openmp/cmake/HandleOpenMPOptions.cmake
index b0fd0b7de4bf7c..201aeabbd3df9c 100644
--- a/openmp/cmake/HandleOpenMPOptions.cmake
+++ b/openmp/cmake/HandleOpenMPOptions.cmake
@@ -41,3 +41,12 @@ append_if(OPENMP_HAVE_WMAYBE_UNINITIALIZED_FLAG "-Wno-maybe-uninitialized" CMAKE
append_if(OPENMP_HAVE_NO_SEMANTIC_INTERPOSITION "-fno-semantic-interposition" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
append_if(OPENMP_HAVE_FUNCTION_SECTIONS "-ffunction-section" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
append_if(OPENMP_HAVE_DATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
+if (MSVC)
+ # Disable "warning C4201: nonstandard extension used: nameless struct/union"
+ append("-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
+ # Disable "warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns
+ # UDT '__kmp_cmplx64_t' which is incompatible with C"
+ append("-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+endif()
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index b02ccc8ba837b6..c287a31e0b1b54 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -502,11 +502,6 @@ static inline kmp_sched_t __kmp_sched_without_mods(kmp_sched_t kind) {
}
/* Type to keep runtime schedule set via OMP_SCHEDULE or omp_set_schedule() */
-#if KMP_COMPILER_MSVC
-#pragma warning(push)
-// warning C4201: nonstandard extension used: nameless struct/union
-#pragma warning(disable : 4201)
-#endif
typedef union kmp_r_sched {
struct {
enum sched_type r_sched_type;
@@ -514,9 +509,6 @@ typedef union kmp_r_sched {
};
kmp_int64 sched;
} kmp_r_sched_t;
-#if KMP_COMPILER_MSVC
-#pragma warning(pop)
-#endif
extern enum sched_type __kmp_sch_map[]; // map OMP 3.0 schedule types with our
// internal schedule types
@@ -1905,20 +1897,12 @@ typedef struct KMP_ALIGN_CACHE dispatch_private_info32 {
// Because of parm1-4 are used together, performance seems to be better
// if they are on the same cache line (not measured though).
-#if KMP_COMPILER_MSVC
-#pragma warning(push)
-// warning C4201: nonstandard extension used: nameless struct/union
-#pragma warning(disable : 4201)
-#endif
struct KMP_ALIGN(32) {
kmp_int32 parm1;
kmp_int32 parm2;
kmp_int32 parm3;
kmp_int32 parm4;
};
-#if KMP_COMPILER_MSVC
-#pragma warning(pop)
-#endif
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
kmp_uint32 pchunks;
@@ -1952,20 +1936,12 @@ typedef struct KMP_ALIGN_CACHE dispatch_private_info64 {
// b) all parm1-4 are in the same cache line.
// Because of parm1-4 are used together, performance seems to be better
// if they are in the same line (not measured though).
-#if KMP_COMPILER_MSVC
-#pragma warning(push)
-// warning C4201: nonstandard extension used: nameless struct/union
-#pragma warning(disable : 4201)
-#endif
struct KMP_ALIGN(32) {
kmp_int64 parm1;
kmp_int64 parm2;
kmp_int64 parm3;
kmp_int64 parm4;
};
-#if KMP_COMPILER_MSVC
-#pragma warning(pop)
-#endif
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
kmp_uint64 pchunks;
@@ -2247,11 +2223,6 @@ union KMP_ALIGN_CACHE kmp_barrier_union {
typedef union kmp_barrier_union kmp_balign_t;
-#if KMP_COMPILER_MSVC
-#pragma warning(push)
-// warning C4201: nonstandard extension used: nameless struct/union
-#pragma warning(disable : 4201)
-#endif
/* Team barrier needs only non-volatile arrived counter */
union KMP_ALIGN_CACHE kmp_barrier_team_union {
double b_align; /* use worst case alignment */
@@ -2268,9 +2239,6 @@ union KMP_ALIGN_CACHE kmp_barrier_team_union {
#endif
};
};
-#if KMP_COMPILER_MSVC
-#pragma warning(pop)
-#endif
typedef union kmp_barrier_team_union kmp_balign_team_t;
diff --git a/openmp/runtime/src/kmp_atomic.h b/openmp/runtime/src/kmp_atomic.h
index 1cf17018a958fe..19fa67b3eedee6 100644
--- a/openmp/runtime/src/kmp_atomic.h
+++ b/openmp/runtime/src/kmp_atomic.h
@@ -1030,13 +1030,6 @@ kmp_cmplx32 __kmpc_atomic_cmplx4_rd(ident_t *id_ref, int gtid,
kmp_cmplx32 *loc);
#endif
-#if KMP_COMPILER_MSVC
-#pragma warning(push)
-// warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns
-// UDT '__kmp_cmplx64_t' which is incompatible with C
-#pragma warning(disable : 4190)
-#endif
-
kmp_cmplx64 __kmpc_atomic_cmplx8_rd(ident_t *id_ref, int gtid,
kmp_cmplx64 *loc);
kmp_cmplx80 __kmpc_atomic_cmplx10_rd(ident_t *id_ref, int gtid,
@@ -1597,10 +1590,6 @@ kmp_cmplx128_a16_t __kmpc_atomic_cmplx16_a16_swp(ident_t *id_ref, int gtid,
#endif
#endif
-#if KMP_COMPILER_MSVC
-#pragma warning(pop)
-#endif
-
// Capture routines for mixed types (RHS=float16)
#if KMP_HAVE_QUAD
diff --git a/openmp/runtime/src/kmp_dispatch.h b/openmp/runtime/src/kmp_dispatch.h
index 340fe5738c6a82..cf19eb52662cec 100644
--- a/openmp/runtime/src/kmp_dispatch.h
+++ b/openmp/runtime/src/kmp_dispatch.h
@@ -81,11 +81,6 @@ template <typename T> struct dispatch_private_infoXX_template {
/* parm[1-4] are used in different ways by different scheduling algorithms */
-#if KMP_COMPILER_MSVC
-#pragma warning(push)
-// warning C4201: nonstandard extension used: nameless struct/union
-#pragma warning(disable : 4201)
-#endif
// KMP_ALIGN(32) ensures ( if the KMP_ALIGN macro is turned on )
// a) parm3 is properly aligned and
// b) all parm1-4 are in the same cache line.
@@ -97,9 +92,6 @@ template <typename T> struct dispatch_private_infoXX_template {
T parm3;
T parm4;
};
-#if KMP_COMPILER_MSVC
-#pragma warning(pop)
-#endif
#if KMP_WEIGHTED_ITERATIONS_SUPPORTED
UT pchunks; // total number of chunks for processes with p-core
>From b5d4357a1ff0e5879a919d77ae1bf8b13bc9f5cc Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Fri, 19 Jan 2024 08:27:07 -0500
Subject: [PATCH 3/6] Remove unused `is_console` function.
---
openmp/runtime/src/kmp_io.cpp | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/openmp/runtime/src/kmp_io.cpp b/openmp/runtime/src/kmp_io.cpp
index 421bfe7e51f524..0c52662bc2357c 100644
--- a/openmp/runtime/src/kmp_io.cpp
+++ b/openmp/runtime/src/kmp_io.cpp
@@ -50,26 +50,6 @@ static HANDLE __kmp_stderr = NULL;
static int __kmp_console_exists = FALSE;
static kmp_str_buf_t __kmp_console_buf;
-#if 0
-static int is_console(void) {
- char buffer[128];
- DWORD rc = 0;
- DWORD err = 0;
- // Try to get console title.
- SetLastError(0);
- // GetConsoleTitle does not reset last error in case of success or short
- // buffer, so we need to clear it explicitly.
- rc = GetConsoleTitle(buffer, sizeof(buffer));
- if (rc == 0) {
- // rc == 0 means getting console title failed. Let us find out why.
- err = GetLastError();
- // err == 0 means buffer too short (we suppose console exists).
- // In Window applications we usually have err == 6 (invalid handle).
- }
- return rc > 0 || err == 0;
-}
-#endif
-
void __kmp_close_console(void) {
/* wait until user presses return before closing window */
/* TODO only close if a window was opened */
>From 299bc6a85dc036809fdd18f16e65df259697c0b9 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Fri, 19 Jan 2024 08:43:38 -0500
Subject: [PATCH 4/6] Remove default case to avoid a warning with Clang
---
openmp/runtime/src/kmp_wait_release.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/openmp/runtime/src/kmp_wait_release.h b/openmp/runtime/src/kmp_wait_release.h
index 36a28e695dc20c..12d5d0677a90a2 100644
--- a/openmp/runtime/src/kmp_wait_release.h
+++ b/openmp/runtime/src/kmp_wait_release.h
@@ -1041,10 +1041,6 @@ static inline void __kmp_null_resume_wrapper(kmp_info_t *thr) {
case flag_unset:
KF_TRACE(100, ("__kmp_null_resume_wrapper: flag type %d is unset\n", type));
break;
- default:
- KF_TRACE(100, ("__kmp_null_resume_wrapper: flag type %d does not match any "
- "known flag type\n",
- type));
}
}
>From 546d8ff9a1644763e02e628a88059996767cd31f Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Fri, 19 Jan 2024 08:44:39 -0500
Subject: [PATCH 5/6] Cover explicitely switch cases instead of using default
---
openmp/runtime/src/kmp_affinity.cpp | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp
index 673b9f5793b866..73ac1b36ff89f5 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -127,9 +127,11 @@ const char *__kmp_hw_get_catalog_string(kmp_hw_t type, bool plural) {
return ((plural) ? KMP_I18N_STR(Threads) : KMP_I18N_STR(Thread));
case KMP_HW_PROC_GROUP:
return ((plural) ? KMP_I18N_STR(ProcGroups) : KMP_I18N_STR(ProcGroup));
- default:
+ case KMP_HW_UNKNOWN:
+ case KMP_HW_LAST:
return KMP_I18N_STR(Unknown);
}
+ llvm_unreachable("Unhandled kmp_hw_t enumeration");
}
const char *__kmp_hw_get_keyword(kmp_hw_t type, bool plural) {
@@ -158,14 +160,17 @@ const char *__kmp_hw_get_keyword(kmp_hw_t type, bool plural) {
return ((plural) ? "threads" : "thread");
case KMP_HW_PROC_GROUP:
return ((plural) ? "proc_groups" : "proc_group");
- default:
+ case KMP_HW_UNKNOWN:
+ case KMP_HW_LAST:
return ((plural) ? "unknowns" : "unknown");
}
+ llvm_unreachable("Unhandled kmp_hw_t enumeration");
}
const char *__kmp_hw_get_core_type_string(kmp_hw_core_type_t type) {
switch (type) {
case KMP_HW_CORE_TYPE_UNKNOWN:
+ case KMP_HW_MAX_NUM_CORE_TYPES:
return "unknown";
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
case KMP_HW_CORE_TYPE_ATOM:
@@ -173,9 +178,8 @@ const char *__kmp_hw_get_core_type_string(kmp_hw_core_type_t type) {
case KMP_HW_CORE_TYPE_CORE:
return "Intel(R) Core(TM) processor";
#endif
- default:
- return "unknown";
}
+ llvm_unreachable("Unhandled kmp_hw_core_type_t enumeration");
}
#if KMP_AFFINITY_SUPPORTED
@@ -1241,18 +1245,17 @@ bool kmp_topology_t::filter_hw_subset() {
struct core_type_indexer {
int operator()(const kmp_hw_thread_t &t) const {
switch (t.attrs.get_core_type()) {
+ case KMP_HW_CORE_TYPE_UNKNOWN:
+ case KMP_HW_MAX_NUM_CORE_TYPES:
+ return 0;
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
case KMP_HW_CORE_TYPE_ATOM:
return 1;
case KMP_HW_CORE_TYPE_CORE:
return 2;
#endif
- case KMP_HW_CORE_TYPE_UNKNOWN:
- return 0;
- default:
- KMP_ASSERT(0);
- return 0;
}
+ llvm_unreachable("Unhandled kmp_hw_core_type_t enumeration");
}
};
struct core_eff_indexer {
>From ed5b40202a67d2ac7bd7ec559caf9c020138c0f6 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Sat, 20 Jan 2024 13:51:45 -0500
Subject: [PATCH 6/6] Fix unreachable code.
---
openmp/runtime/src/kmp_affinity.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp
index 73ac1b36ff89f5..be5d0626935767 100644
--- a/openmp/runtime/src/kmp_affinity.cpp
+++ b/openmp/runtime/src/kmp_affinity.cpp
@@ -28,6 +28,8 @@
#endif
#include <ctype.h>
+#include "llvm/Support/Compiler.h"
+
// The machine topology
kmp_topology_t *__kmp_topology = nullptr;
// KMP_HW_SUBSET environment variable
@@ -131,7 +133,7 @@ const char *__kmp_hw_get_catalog_string(kmp_hw_t type, bool plural) {
case KMP_HW_LAST:
return KMP_I18N_STR(Unknown);
}
- llvm_unreachable("Unhandled kmp_hw_t enumeration");
+ LLVM_BUILTIN_UNREACHABLE;
}
const char *__kmp_hw_get_keyword(kmp_hw_t type, bool plural) {
@@ -164,7 +166,7 @@ const char *__kmp_hw_get_keyword(kmp_hw_t type, bool plural) {
case KMP_HW_LAST:
return ((plural) ? "unknowns" : "unknown");
}
- llvm_unreachable("Unhandled kmp_hw_t enumeration");
+ LLVM_BUILTIN_UNREACHABLE;
}
const char *__kmp_hw_get_core_type_string(kmp_hw_core_type_t type) {
@@ -179,7 +181,7 @@ const char *__kmp_hw_get_core_type_string(kmp_hw_core_type_t type) {
return "Intel(R) Core(TM) processor";
#endif
}
- llvm_unreachable("Unhandled kmp_hw_core_type_t enumeration");
+ LLVM_BUILTIN_UNREACHABLE;
}
#if KMP_AFFINITY_SUPPORTED
@@ -1255,7 +1257,7 @@ bool kmp_topology_t::filter_hw_subset() {
return 2;
#endif
}
- llvm_unreachable("Unhandled kmp_hw_core_type_t enumeration");
+ LLVM_BUILTIN_UNREACHABLE;
}
};
struct core_eff_indexer {
More information about the Openmp-commits
mailing list