Skip to content

Commit 1a4dc18

Browse files
authored
[OpenMP] allow openmp build for sparc (llvm#133239)
1 parent d72be15 commit 1a4dc18

File tree

7 files changed

+36
-10
lines changed

7 files changed

+36
-10
lines changed

openmp/runtime/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if(${OPENMP_STANDALONE_BUILD})
3030
# If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake
3131
libomp_get_architecture(LIBOMP_DETECTED_ARCH)
3232
set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING
33-
"The architecture to build for (x86_64/i386/arm/ppc/ppc64/ppc64le/aarch64/aarch64_32/mic/mips/mips64/riscv64/loongarch64/ve/s390x/wasm32).")
33+
"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).")
3434
# Should assertions be enabled? They are on by default.
3535
set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL
3636
"enable assertions?")
@@ -71,6 +71,10 @@ else() # Part of LLVM build
7171
set(LIBOMP_ARCH ve)
7272
elseif(LIBOMP_NATIVE_ARCH MATCHES "s390x")
7373
set(LIBOMP_ARCH s390x)
74+
elseif(LIBOMP_NATIVE_ARCH MATCHES "sparcv9")
75+
set(LIBOMP_ARCH sparcv9)
76+
elseif(LIBOMP_NATIVE_ARCH MATCHES "sparc")
77+
set(LIBOMP_ARCH sparc)
7478
elseif(LIBOMP_NATIVE_ARCH MATCHES "wasm")
7579
set(LIBOMP_ARCH wasm32)
7680
else()
@@ -93,7 +97,7 @@ if(LIBOMP_ARCH STREQUAL "aarch64")
9397
endif()
9498
endif()
9599

96-
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)
100+
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)
97101

98102
set(LIBOMP_LIB_TYPE normal CACHE STRING
99103
"Performance,Profiling,Stubs library (normal/profile/stubs)")

openmp/runtime/cmake/LibompGetArchitecture.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ function(libomp_get_architecture return_arch)
5959
#error ARCHITECTURE=s390x
6060
#elif defined(__wasm32__)
6161
#error ARCHITECTURE=wasm32
62+
#elif defined(__sparcv9)
63+
#error ARCHITECTURE=sparcv9
64+
#elif defined(__sparc)
65+
#error ARCHITECTURE=sparc
6266
#else
6367
#error ARCHITECTURE=UnknownArchitecture
6468
#endif

openmp/runtime/cmake/config-ix.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ else()
316316
(LIBOMP_ARCH STREQUAL ppc64) OR
317317
(LIBOMP_ARCH STREQUAL riscv64) OR
318318
(LIBOMP_ARCH STREQUAL loongarch64) OR
319-
(LIBOMP_ARCH STREQUAL s390x))
319+
(LIBOMP_ARCH STREQUAL s390x) OR
320+
(LIBOMP_ARCH STREQUAL sparc) OR
321+
(LIBOMP_ARCH STREQUAL sparcv9))
320322
AND # OS supported?
321323
((WIN32 AND LIBOMP_HAVE_PSAPI) OR APPLE OR
322324
(NOT (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND LIBOMP_HAVE_WEAK_ATTRIBUTE)))

openmp/runtime/src/kmp_gsupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_ORDERED_END)(void) {
358358
// (IA-32 architecture) or 64-bit signed (Intel(R) 64).
359359

360360
#if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_WASM || \
361-
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
361+
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC32
362362
#define KMP_DISPATCH_INIT __kmp_aux_dispatch_init_4
363363
#define KMP_DISPATCH_FINI_CHUNK __kmp_aux_dispatch_fini_chunk_4
364364
#define KMP_DISPATCH_NEXT __kmpc_dispatch_next_4

openmp/runtime/src/kmp_os.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ typedef unsigned long long kmp_uint64;
179179
#endif /* KMP_OS_UNIX */
180180

181181
#if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_WASM || \
182-
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
182+
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC32
183183
#define KMP_SIZE_T_SPEC KMP_UINT32_SPEC
184184
#elif KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || \
185185
KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || \
186-
KMP_ARCH_VE || KMP_ARCH_S390X
186+
KMP_ARCH_VE || KMP_ARCH_S390X || KMP_ARCH_SPARC64
187187
#define KMP_SIZE_T_SPEC KMP_UINT64_SPEC
188188
#else
189189
#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);
10521052

10531053
#if KMP_ARCH_PPC64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS || \
10541054
KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || \
1055-
KMP_ARCH_VE || KMP_ARCH_S390X || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
1055+
KMP_ARCH_VE || KMP_ARCH_S390X || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || \
1056+
KMP_ARCH_SPARC
10561057
#if KMP_OS_WINDOWS
10571058
#undef KMP_MB
10581059
#define KMP_MB() std::atomic_thread_fence(std::memory_order_seq_cst)

openmp/runtime/src/kmp_platform.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
#define KMP_ARCH_LOONGARCH64 0
130130
#define KMP_ARCH_VE 0
131131
#define KMP_ARCH_S390X 0
132+
#define KMP_ARCH_SPARC 0
132133

133134
#if KMP_OS_WINDOWS
134135
#if defined(_M_AMD64) || defined(__x86_64)
@@ -200,6 +201,9 @@
200201
#elif defined __s390x__
201202
#undef KMP_ARCH_S390X
202203
#define KMP_ARCH_S390X 1
204+
#elif defined __sparc || defined __sparc__
205+
#undef KMP_ARCH_SPARC
206+
#define KMP_ARCH_SPARC 1
203207
#endif
204208
#endif
205209

@@ -246,6 +250,17 @@
246250
#define KMP_ARCH_PPC64 \
247251
(KMP_ARCH_PPC64_ELFv2 || KMP_ARCH_PPC64_ELFv1 || KMP_ARCH_PPC64_XCOFF)
248252

253+
#if defined(KMP_ARCH_SPARC)
254+
#undef KMP_ARCH_SPARC32
255+
#undef KMP_ARCH_SPARC64
256+
#if defined(__sparcv9) || defined(__sparc64__)
257+
#define KMP_ARCH_SPARC64 1
258+
#endif
259+
#if defined(__sparc) && !defined(__sparcv9) && !defined(__sparc64__)
260+
#define KMP_ARCH_SPARC32 1
261+
#endif
262+
#endif
263+
249264
#if defined(__MIC__) || defined(__MIC2__)
250265
#define KMP_MIC 1
251266
#if __MIC2__ || __KNC__
@@ -264,7 +279,7 @@
264279
/* Specify 32 bit architectures here */
265280
#define KMP_32_BIT_ARCH \
266281
(KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_WASM || \
267-
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32)
282+
KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC32)
268283

269284
// Platforms which support Intel(R) Many Integrated Core Architecture
270285
#define KMP_MIC_SUPPORTED \
@@ -275,7 +290,7 @@
275290
KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64 + \
276291
KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH64 + KMP_ARCH_VE + \
277292
KMP_ARCH_S390X + KMP_ARCH_WASM + KMP_ARCH_PPC + \
278-
KMP_ARCH_AARCH64_32)
293+
KMP_ARCH_AARCH64_32 + KMP_ARCH_SPARC)
279294
#error Unknown or unsupported architecture
280295
#endif
281296

openmp/runtime/src/kmp_runtime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8978,7 +8978,7 @@ __kmp_determine_reduction_method(
89788978
// KMP_OS_HURD || KMP_OS_SOLARIS || KMP_OS_WASI || KMP_OS_AIX
89798979

89808980
#elif KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_AARCH || KMP_ARCH_MIPS || \
8981-
KMP_ARCH_WASM || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32
8981+
KMP_ARCH_WASM || KMP_ARCH_PPC || KMP_ARCH_AARCH64_32 || KMP_ARCH_SPARC
89828982

89838983
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \
89848984
KMP_OS_OPENBSD || KMP_OS_WINDOWS || KMP_OS_HAIKU || KMP_OS_HURD || \

0 commit comments

Comments
 (0)