[OpenMP] allow openmp build for sparc (#133239)

This commit is contained in:
Petr Sumbera
2025-04-02 01:57:14 +02:00
committed by GitHub
parent d72be15782
commit 1a4dc189ad
7 changed files with 36 additions and 10 deletions

View File

@@ -30,7 +30,7 @@ if(${OPENMP_STANDALONE_BUILD})
# If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake
libomp_get_architecture(LIBOMP_DETECTED_ARCH)
set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING
"The architecture to build for (x86_64/i386/arm/ppc/ppc64/ppc64le/aarch64/aarch64_32/mic/mips/mips64/riscv64/loongarch64/ve/s390x/wasm32).")
"The architecture to build for (x86_64/i386/arm/ppc/ppc64/ppc64le/aarch64/aarch64_32/mic/mips/mips64/riscv64/loongarch64/ve/s390x/sparc/sparcv9/wasm32).")
# Should assertions be enabled? They are on by default.
set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL
"enable assertions?")
@@ -71,6 +71,10 @@ else() # Part of LLVM build
set(LIBOMP_ARCH ve)
elseif(LIBOMP_NATIVE_ARCH MATCHES "s390x")
set(LIBOMP_ARCH s390x)
elseif(LIBOMP_NATIVE_ARCH MATCHES "sparcv9")
set(LIBOMP_ARCH sparcv9)
elseif(LIBOMP_NATIVE_ARCH MATCHES "sparc")
set(LIBOMP_ARCH sparc)
elseif(LIBOMP_NATIVE_ARCH MATCHES "wasm")
set(LIBOMP_ARCH wasm32)
else()
@@ -93,7 +97,7 @@ if(LIBOMP_ARCH STREQUAL "aarch64")
endif()
endif()
libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc ppc64 ppc64le aarch64 aarch64_32 aarch64_a64fx mic mips mips64 riscv64 loongarch64 ve s390x wasm32)
libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc ppc64 ppc64le aarch64 aarch64_32 aarch64_a64fx mic mips mips64 riscv64 loongarch64 ve s390x sparc sparcv9 wasm32)
set(LIBOMP_LIB_TYPE normal CACHE STRING
"Performance,Profiling,Stubs library (normal/profile/stubs)")

View File

@@ -59,6 +59,10 @@ function(libomp_get_architecture return_arch)
#error ARCHITECTURE=s390x
#elif defined(__wasm32__)
#error ARCHITECTURE=wasm32
#elif defined(__sparcv9)
#error ARCHITECTURE=sparcv9
#elif defined(__sparc)
#error ARCHITECTURE=sparc
#else
#error ARCHITECTURE=UnknownArchitecture
#endif

View File

@@ -316,7 +316,9 @@ else()
(LIBOMP_ARCH STREQUAL ppc64) OR
(LIBOMP_ARCH STREQUAL riscv64) OR
(LIBOMP_ARCH STREQUAL loongarch64) OR
(LIBOMP_ARCH STREQUAL s390x))
(LIBOMP_ARCH STREQUAL s390x) OR
(LIBOMP_ARCH STREQUAL sparc) OR
(LIBOMP_ARCH STREQUAL sparcv9))
AND # OS supported?
((WIN32 AND LIBOMP_HAVE_PSAPI) OR APPLE OR
(NOT (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND LIBOMP_HAVE_WEAK_ATTRIBUTE)))

View File

@@ -358,7 +358,7 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ORDERED_END)(void) {
// (IA-32 architecture) or 64-bit signed (Intel(R) 64).
#if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_WASM || \
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC32
#define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
#define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
#define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4

View File

@@ -179,11 +179,11 @@ typedef unsigned long long kmp_uint64;
#endif /* KMP_OS_UNIX */
#if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_WASM || \
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC32
#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_LOONGARCH64 || \
KMP_ARCH_VE || KMP_ARCH_S390X
KMP_ARCH_VE || KMP_ARCH_S390X || KMP_ARCH_SPARC64
#define KMP_SIZE_T_SPEC KMP_UINT64_SPEC
#else
#error "Can't determine size_t printf format specifier."
@@ -1052,7 +1052,8 @@ extern kmp_real64 __kmp_xchg_real64(volatile kmp_real64 *p, kmp_real64 v);
#if KMP_ARCH_PPC64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS || \
KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || \
KMP_ARCH_VE || KMP_ARCH_S390X || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
KMP_ARCH_VE || KMP_ARCH_S390X || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || \
KMP_ARCH_SPARC
#if KMP_OS_WINDOWS
#undef KMP_MB
#define KMP_MB() std::atomic_thread_fence(std::memory_order_seq_cst)

View File

@@ -129,6 +129,7 @@
#define KMP_ARCH_LOONGARCH64 0
#define KMP_ARCH_VE 0
#define KMP_ARCH_S390X 0
#define KMP_ARCH_SPARC 0
#if KMP_OS_WINDOWS
#if defined(_M_AMD64) || defined(__x86_64)
@@ -200,6 +201,9 @@
#elif defined __s390x__
#undef KMP_ARCH_S390X
#define KMP_ARCH_S390X 1
#elif defined __sparc || defined __sparc__
#undef KMP_ARCH_SPARC
#define KMP_ARCH_SPARC 1
#endif
#endif
@@ -246,6 +250,17 @@
#define KMP_ARCH_PPC64 \
(KMP_ARCH_PPC64_ELFv2 || KMP_ARCH_PPC64_ELFv1 || KMP_ARCH_PPC64_XCOFF)
#if defined(KMP_ARCH_SPARC)
#undef KMP_ARCH_SPARC32
#undef KMP_ARCH_SPARC64
#if defined(__sparcv9) || defined(__sparc64__)
#define KMP_ARCH_SPARC64 1
#endif
#if defined(__sparc) && !defined(__sparcv9) && !defined(__sparc64__)
#define KMP_ARCH_SPARC32 1
#endif
#endif
#if defined(__MIC__) || defined(__MIC2__)
#define KMP_MIC 1
#if __MIC2__ || __KNC__
@@ -264,7 +279,7 @@
/* Specify 32 bit architectures here */
#define KMP_32_BIT_ARCH \
(KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_WASM || \
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32)
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC32)
// Platforms which support Intel(R) Many Integrated Core Architecture
#define KMP_MIC_SUPPORTED \
@@ -275,7 +290,7 @@
KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64 + \
KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH64 + KMP_ARCH_VE + \
KMP_ARCH_S390X + KMP_ARCH_WASM + KMP_ARCH_PPC + \
KMP_ARCH_AARCH64_32)
KMP_ARCH_AARCH64_32 + KMP_ARCH_SPARC)
#error Unknown or unsupported architecture
#endif

View File

@@ -8978,7 +8978,7 @@ __kmp_determine_reduction_method(
// KMP_OS_HURD || KMP_OS_SOLARIS || KMP_OS_WASI || KMP_OS_AIX
#elif KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_AARCH || KMP_ARCH_MIPS || \
KMP_ARCH_WASM || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
KMP_ARCH_WASM || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
KMP_OS_OPENBSD || KMP_OS_WINDOWS || KMP_OS_HAIKU || KMP_OS_HURD || \