From 6724aa9091d55541fdb9ddd25a6bd9a8f7068782 Mon Sep 17 00:00:00 2001 From: Renbo Date: Tue, 31 Jan 2023 14:35:05 +0800 Subject: [PATCH] update to libomp-14.0.6-2.module+el8.7.0+16313+2fe5fb1f Signed-off-by: Renbo --- ...ke-Make-LIBOMP_HEADERS_INSTALL_PATH-.patch | 4 +- 1000-arch-support-loongarch64-platform.patch | 186 ------------------ download | 4 +- ...ct-aliasing-issue-in-cmpxchg-routine.patch | 44 +++++ gcc-workaround.patch | 12 ++ libomp.spec | 61 ++++-- 6 files changed, 106 insertions(+), 205 deletions(-) delete mode 100644 1000-arch-support-loongarch64-platform.patch create mode 100644 fix-strict-aliasing-issue-in-cmpxchg-routine.patch create mode 100644 gcc-workaround.patch diff --git a/0001-PATCH-openmp-CMake-Make-LIBOMP_HEADERS_INSTALL_PATH-.patch b/0001-PATCH-openmp-CMake-Make-LIBOMP_HEADERS_INSTALL_PATH-.patch index eedd1ee..e7febcf 100644 --- a/0001-PATCH-openmp-CMake-Make-LIBOMP_HEADERS_INSTALL_PATH-.patch +++ b/0001-PATCH-openmp-CMake-Make-LIBOMP_HEADERS_INSTALL_PATH-.patch @@ -13,11 +13,11 @@ diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.t index 822f9ca..583a3c3 100644 --- a/openmp/runtime/src/CMakeLists.txt +++ b/openmp/runtime/src/CMakeLists.txt -@@ -305,7 +305,7 @@ add_dependencies(libomp-micro-tests libomp-test-deps) +@@ -346,7 +346,7 @@ add_dependencies(libomp-micro-tests libomp-test-deps) # We want to install libomp in DESTDIR/CMAKE_INSTALL_PREFIX/lib # We want to install headers in DESTDIR/CMAKE_INSTALL_PREFIX/include if(${OPENMP_STANDALONE_BUILD}) -- set(LIBOMP_HEADERS_INSTALL_PATH include) +- set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}") + set(LIBOMP_HEADERS_INSTALL_PATH include CACHE PATH "Install path for OpenMP headers") else() string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) diff --git a/1000-arch-support-loongarch64-platform.patch b/1000-arch-support-loongarch64-platform.patch deleted file mode 100644 index 0c34f5d..0000000 --- a/1000-arch-support-loongarch64-platform.patch +++ /dev/null @@ -1,186 +0,0 @@ -From 396b6c91c0a46f7e64c276d5ab1c28af0ee0260f Mon Sep 17 00:00:00 2001 -From: Liwei Ge -Date: Wed, 19 Oct 2022 18:20:33 +0800 -Subject: [PATCH] arch: support loongarch64 platform - ---- - runtime/CMakeLists.txt | 4 +++- - runtime/cmake/LibompGetArchitecture.cmake | 2 ++ - runtime/cmake/LibompUtils.cmake | 2 ++ - runtime/src/kmp_csupport.cpp | 2 +- - runtime/src/kmp_os.h | 2 +- - runtime/src/kmp_platform.h | 6 +++++- - runtime/src/kmp_runtime.cpp | 2 +- - runtime/src/thirdparty/ittnotify/ittnotify_config.h | 10 +++++++++- - runtime/src/z_Linux_asm.S | 2 +- - 9 files changed, 25 insertions(+), 7 deletions(-) - -diff --git a/openmp/runtime/CMakeLists.txt b/openmp/runtime/CMakeLists.txt -index 7080f92..8900a9b 100644 ---- a/openmp/runtime/CMakeLists.txt -+++ b/openmp/runtime/CMakeLists.txt -@@ -54,6 +54,8 @@ else() # Part of LLVM build - set(LIBOMP_ARCH ppc64) - elseif(LIBOMP_NATIVE_ARCH MATCHES "aarch64") - set(LIBOMP_ARCH aarch64) -+ elseif(LIBOMP_NATIVE_ARCH MATCHES "loongarch64") -+ set(LIBOMP_ARCH loongarch64) - elseif(LIBOMP_NATIVE_ARCH MATCHES "arm64") - set(LIBOMP_ARCH aarch64) - elseif(LIBOMP_NATIVE_ARCH MATCHES "arm") -@@ -80,7 +82,7 @@ if(LIBOMP_ARCH STREQUAL "aarch64") - endif() - endif() - --libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 aarch64_a64fx mic mips mips64 riscv64) -+libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 loongarch64 aarch64_a64fx mic mips mips64 riscv64) - - set(LIBOMP_LIB_TYPE normal CACHE STRING - "Performance,Profiling,Stubs library (normal/profile/stubs)") -diff --git a/openmp/runtime/cmake/LibompGetArchitecture.cmake b/openmp/runtime/cmake/LibompGetArchitecture.cmake -index dd60a2d..294328a 100644 ---- a/openmp/runtime/cmake/LibompGetArchitecture.cmake -+++ b/openmp/runtime/cmake/LibompGetArchitecture.cmake -@@ -37,6 +37,8 @@ function(libomp_get_architecture return_arch) - #error ARCHITECTURE=arm - #elif defined(__aarch64__) - #error ARCHITECTURE=aarch64 -+ #elif defined(__loongarch__) -+ #error ARCHITECTURE=loongarch64 - #elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) - #error ARCHITECTURE=ppc64le - #elif defined(__powerpc64__) -diff --git a/openmp/runtime/cmake/LibompUtils.cmake b/openmp/runtime/cmake/LibompUtils.cmake -index b1de242..a5c2228 100644 ---- a/openmp/runtime/cmake/LibompUtils.cmake -+++ b/openmp/runtime/cmake/LibompUtils.cmake -@@ -101,6 +101,8 @@ function(libomp_get_legal_arch return_arch_string) - set(${return_arch_string} "PPC64LE" PARENT_SCOPE) - elseif(${AARCH64}) - set(${return_arch_string} "AARCH64" PARENT_SCOPE) -+ elseif(${LOONGARCH64}) -+ set(${return_arch_string} "LOONGARCH64" PARENT_SCOPE) - elseif(${AARCH64_A64FX}) - set(${return_arch_string} "AARCH64_A64FX" PARENT_SCOPE) - elseif(${MIPS}) -diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp -index 2a7c9a8..6d4250b 100644 ---- a/openmp/runtime/src/kmp_csupport.cpp -+++ b/openmp/runtime/src/kmp_csupport.cpp -@@ -699,7 +699,7 @@ void __kmpc_flush(ident_t *loc) { - } - #endif // KMP_MIC - #elif (KMP_ARCH_ARM || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS || KMP_ARCH_MIPS64 || \ -- KMP_ARCH_RISCV64) -+ KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64) - // Nothing to see here move along - #elif KMP_ARCH_PPC64 - // Nothing needed here (we have a real MB above). -diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h -index 4437cf2..309f90a 100644 ---- a/openmp/runtime/src/kmp_os.h -+++ b/openmp/runtime/src/kmp_os.h -@@ -167,7 +167,7 @@ typedef unsigned long long kmp_uint64; - #if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS - #define KMP_SIZE_T_SPEC KMP_UINT32_SPEC - #elif KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || \ -- KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 -+ KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 - #define KMP_SIZE_T_SPEC KMP_UINT64_SPEC - #else - #error "Can't determine size_t printf format specifier." -diff --git a/openmp/runtime/src/kmp_platform.h b/openmp/runtime/src/kmp_platform.h -index bbbd72d..2a1b08a 100644 ---- a/openmp/runtime/src/kmp_platform.h -+++ b/openmp/runtime/src/kmp_platform.h -@@ -86,6 +86,7 @@ - #define KMP_ARCH_X86 0 - #define KMP_ARCH_X86_64 0 - #define KMP_ARCH_AARCH64 0 -+#define KMP_ARCH_LOONGARCH64 0 - #define KMP_ARCH_PPC64_ELFv1 0 - #define KMP_ARCH_PPC64_ELFv2 0 - #define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_ELFv2 || KMP_ARCH_PPC64_ELFv1) -@@ -124,6 +125,9 @@ - #elif defined __aarch64__ - #undef KMP_ARCH_AARCH64 - #define KMP_ARCH_AARCH64 1 -+#elif defined __loongarch__ -+#undef KMP_ARCH_LOONGARCH64 -+#define KMP_ARCH_LOONGARCH64 1 - #elif defined __mips__ - #if defined __mips64 - #undef KMP_ARCH_MIPS64 -@@ -199,7 +203,7 @@ - // TODO: Fixme - This is clever, but really fugly - #if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + \ - KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64 + \ -- KMP_ARCH_RISCV64) -+ KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH64) - #error Unknown or unsupported architecture - #endif - -diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp -index 16d415d..f422979 100644 ---- a/openmp/runtime/src/kmp_runtime.cpp -+++ b/openmp/runtime/src/kmp_runtime.cpp -@@ -8501,7 +8501,7 @@ __kmp_determine_reduction_method( - int atomic_available = FAST_REDUCTION_ATOMIC_METHOD_GENERATED; - - #if KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || \ -- KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 -+ KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 - - #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \ - KMP_OS_OPENBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN || KMP_OS_HURD -diff --git a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h -index a49236b..eb0a360 100644 ---- a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h -+++ b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h -@@ -165,6 +165,11 @@ - #define ITT_ARCH_RISCV64 7 - #endif /* ITT_ARCH_RISCV64 */ - -+#ifndef ITT_ARCH_LOONGARCH64 -+#define ITT_ARCH_LOONGARCH64 8 -+#endif -+ -+ - #ifndef ITT_ARCH - #if defined _M_IX86 || defined __i386__ - #define ITT_ARCH ITT_ARCH_IA32 -@@ -178,6 +183,8 @@ - #define ITT_ARCH ITT_ARCH_PPC64 - #elif defined __aarch64__ - #define ITT_ARCH ITT_ARCH_AARCH64 -+#elif defined __loongarch__ -+#define ITT_ARCH ITT_ARCH_LOONGARCH64 - #elif defined __mips__ && !defined __mips64 - #define ITT_ARCH ITT_ARCH_MIPS - #elif defined __mips__ && defined __mips64 -@@ -344,7 +351,8 @@ ITT_INLINE long __TBB_machine_fetchadd4(volatile void *ptr, long addend) { - } - #elif ITT_ARCH == ITT_ARCH_ARM || ITT_ARCH == ITT_ARCH_PPC64 || \ - ITT_ARCH == ITT_ARCH_AARCH64 || ITT_ARCH == ITT_ARCH_MIPS || \ -- ITT_ARCH == ITT_ARCH_MIPS64 || ITT_ARCH == ITT_ARCH_RISCV64 -+ ITT_ARCH == ITT_ARCH_MIPS64 || ITT_ARCH == ITT_ARCH_RISCV64 || \ -+ ITT_ARCH == ITT_ARCH_LOONGARCH64 - #define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val) - #endif /* ITT_ARCH==ITT_ARCH_IA64 */ - #ifndef ITT_SIMPLE_INIT -diff --git a/openmp/runtime/src/z_Linux_asm.S b/openmp/runtime/src/z_Linux_asm.S -index b4a45c1..94cf4dc 100644 ---- a/openmp/runtime/src/z_Linux_asm.S -+++ b/openmp/runtime/src/z_Linux_asm.S -@@ -1736,7 +1736,7 @@ __kmp_unnamed_critical_addr: - .size __kmp_unnamed_critical_addr,4 - #endif /* KMP_ARCH_ARM */ - --#if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 -+#if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 - #ifndef KMP_PREFIX_UNDERSCORE - # define KMP_PREFIX_UNDERSCORE(x) x - #endif --- -2.27.0 - diff --git a/download b/download index 6ba7aab..918677a 100644 --- a/download +++ b/download @@ -1,2 +1,2 @@ -8a4a802287293e666f9969ced5db0c17 openmp-13.0.1.src.tar.xz -f8ed6db4b5a22edada5a503c4ed2ba62 openmp-13.0.1.src.tar.xz.sig +b94978b13a7d411f6a448322dcc4954e openmp-14.0.6.src.tar.xz +48ce510aeb2bbd4a8d1e39b41d35d19c openmp-14.0.6.src.tar.xz.sig diff --git a/fix-strict-aliasing-issue-in-cmpxchg-routine.patch b/fix-strict-aliasing-issue-in-cmpxchg-routine.patch new file mode 100644 index 0000000..db6ca9c --- /dev/null +++ b/fix-strict-aliasing-issue-in-cmpxchg-routine.patch @@ -0,0 +1,44 @@ +diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h +--- a/openmp/runtime/src/kmp_os.h ++++ b/openmp/runtime/src/kmp_os.h +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + + #define KMP_FTN_PLAIN 1 + #define KMP_FTN_APPEND 2 +@@ -864,15 +865,25 @@ + __sync_lock_test_and_set((volatile kmp_uint64 *)(p), (kmp_uint64)(v)) + + inline kmp_real32 KMP_XCHG_REAL32(volatile kmp_real32 *p, kmp_real32 v) { +- kmp_int32 tmp = +- __sync_lock_test_and_set((volatile kmp_uint32 *)(p), *(kmp_uint32 *)&v); +- return *(kmp_real32 *)&tmp; ++ volatile kmp_uint32 *up; ++ kmp_uint32 uv; ++ memcpy(&up, &p, sizeof(up)); ++ memcpy(&uv, &v, sizeof(uv)); ++ kmp_int32 tmp = __sync_lock_test_and_set(up, uv); ++ kmp_real32 ftmp; ++ memcpy(&ftmp, &tmp, sizeof(tmp)); ++ return ftmp; + } + + inline kmp_real64 KMP_XCHG_REAL64(volatile kmp_real64 *p, kmp_real64 v) { +- kmp_int64 tmp = +- __sync_lock_test_and_set((volatile kmp_uint64 *)(p), *(kmp_uint64 *)&v); +- return *(kmp_real64 *)&tmp; ++ volatile kmp_uint64 *up; ++ kmp_uint64 uv; ++ memcpy(&up, &p, sizeof(up)); ++ memcpy(&uv, &v, sizeof(uv)); ++ kmp_int64 tmp = __sync_lock_test_and_set(up, uv); ++ kmp_real64 dtmp; ++ memcpy(&dtmp, &tmp, sizeof(tmp)); ++ return dtmp; + } + + #else + diff --git a/gcc-workaround.patch b/gcc-workaround.patch new file mode 100644 index 0000000..a7de6ca --- /dev/null +++ b/gcc-workaround.patch @@ -0,0 +1,12 @@ +diff -ruN openmp-14.0.0.src.orig/runtime/src/kmp_lock.cpp openmp-14.0.0.src/runtime/src/kmp_lock.cpp +--- a/openmp-14.0.0.src.orig/runtime/src/kmp_lock.cpp 2022-03-14 10:44:55.000000000 +0100 ++++ b/openmp-14.0.0.src/runtime/src/kmp_lock.cpp 2022-04-22 10:58:26.736078432 +0200 +@@ -2663,7 +2663,7 @@ + } + + // Truncated binary exponential backoff function +-void __kmp_spin_backoff(kmp_backoff_t *boff) { ++void __attribute__((optimize("O1"))) __kmp_spin_backoff(kmp_backoff_t *boff) { + // We could flatten this loop, but making it a nested loop gives better result + kmp_uint32 i; + for (i = boff->step; i > 0; i--) { diff --git a/libomp.spec b/libomp.spec index 28c158c..1831374 100644 --- a/libomp.spec +++ b/libomp.spec @@ -1,6 +1,5 @@ -%define anolis_release .0.1 -%global libomp_version 13.0.1 -#global rc_ver 3 +%global libomp_version 14.0.6 +#global rc_ver 1 %global libomp_srcdir openmp-%{libomp_version}%{?rc_ver:rc%{rc_ver}}.src @@ -10,9 +9,15 @@ %global libomp_arch %{_arch} %endif +%ifarch %{ix86} +%bcond_with testpkg +%else +%bcond_without testpkg +%endif + Name: libomp Version: %{libomp_version}%{?rc_ver:~rc%{rc_ver}} -Release: 1%{anolis_release}%{?dist} +Release: 2%{?dist} Summary: OpenMP runtime for clang License: NCSA @@ -24,8 +29,12 @@ Source3: run-lit-tests Source4: lit.fedora.cfg.py Patch0: 0001-PATCH-openmp-CMake-Make-LIBOMP_HEADERS_INSTALL_PATH-.patch - -Patch1000: 1000-arch-support-loongarch64-platform.patch +# RHEL specific: Workaround for a bug in GCC that breaks compiling +# the kmp_lock.cpp. Without this patch, GCC errors out with +# ../runtime/src/kmp_lock.cpp:2684:1: error: unsupported size for integer register +Patch1: gcc-workaround.patch +# https://github.com/llvm/llvm-project/commit/40d3a0ba4d9e5452c0a68cfdaa8e88eb8ed5c63d +Patch2: fix-strict-aliasing-issue-in-cmpxchg-routine.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -36,11 +45,12 @@ BuildRequires: perl BuildRequires: perl-Data-Dumper BuildRequires: perl-Encode BuildRequires: libffi-devel +# RHEL specific: libomp requires libterminfo BuildRequires: ncurses-devel -# The AMDGCN device RTL requires clang and llvm-link to build -BuildRequires: clang -BuildRequires: llvm +# For gpg source verification +BuildRequires: gnupg2 + # libomptarget needs the llvm cmake files BuildRequires: llvm-devel @@ -60,6 +70,8 @@ Requires: clang-resource-filesystem%{?isa} = %{version} %description devel OpenMP header files. +%if %{with testpkg} + %package test Summary: OpenMP regression tests Requires: %{name}%{?isa} = %{version}-%{release} @@ -73,7 +85,10 @@ Requires: python3-lit %description test OpenMP regression tests +%endif + %prep +%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}' %autosetup -n %{libomp_srcdir} -p2 %build @@ -93,6 +108,7 @@ cd %{_vpath_builddir} %else -DOPENMP_LIBDIR_SUFFIX= \ %endif + -DCMAKE_SKIP_RPATH:BOOL=ON %cmake_build @@ -101,6 +117,7 @@ cd %{_vpath_builddir} cd %{_vpath_builddir} %cmake_install +%if %{with testpkg} # Test package setup %global libomp_srcdir %{_datadir}/libomp/src/ %global libomp_testdir %{libomp_srcdir}/runtime/test/ @@ -125,6 +142,8 @@ echo "lit_config.load_config(config, '%{lit_fedora_cfg}')" >> %{buildroot}%{lit_ install -d %{buildroot}%{_libexecdir}/tests/libomp install -m 0755 %{SOURCE3} %{buildroot}%{_libexecdir}/tests/libomp +%endif + # Remove static libraries with equivalent shared libraries rm -rf %{buildroot}%{_libdir}/libarcher_static.a @@ -135,11 +154,11 @@ cd %{_vpath_builddir} %files %license LICENSE.TXT %{_libdir}/libomp.so -%ifnarch %{arm} loongarch64 +%{_libdir}/libompd.so +%ifnarch %{arm} %{_libdir}/libarcher.so %endif -%ifnarch %{ix86} %{arm} loongarch64 -%{_libdir}/libomptarget-amdgcn*.bc +%ifnarch %{ix86} %{arm} %{_libdir}/libomptarget.rtl.amdgpu.so %{_libdir}/libomptarget.rtl.cuda.so %{_libdir}/libomptarget.rtl.%{libomp_arch}.so @@ -149,7 +168,7 @@ cd %{_vpath_builddir} %files devel %{_libdir}/clang/%{libomp_version}/include/omp.h %{_libdir}/cmake/openmp/FindOpenMPTarget.cmake -%ifnarch %{arm} loongarch64 +%ifnarch %{arm} %{_libdir}/clang/%{libomp_version}/include/omp-tools.h %{_libdir}/clang/%{libomp_version}/include/ompt.h # FIXME: This is probably wrong. Seems like LIBOMP_HEADERS_INSTALL may @@ -157,13 +176,25 @@ cd %{_vpath_builddir} %{_includedir}/ompt-multiplex.h %endif +%if %{with testpkg} %files test %{_datadir}/libomp %{_libexecdir}/tests/libomp/ +%endif %changelog -* Wed Oct 19 2022 Liwei Ge - 13.0.1-1.0.1 -- Support loongarch platform +* Wed Aug 10 2022 Tom Stellard - 14.0.6-2 +- Drop -test sub-package on i686 + +* Tue Jun 28 2022 Tom Stellard - 14.0.6-1 +- 14.0.6 Release + +* Wed May 18 2022 Timm Bäder - 14.00-2 +- Backport 40d3a0ba4d9e5452c0a68cfdaa8e88eb8ed5c63d to + fix a strict aliasing issue. + +* Thu Apr 07 2022 Timm Bäder - 14.0.0-1 +- Update to 14.0.0 * Thu Feb 03 2022 Tom Stellard - 13.0.1-1 - 13.0.1 Release -- Gitee