summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r--openmp/runtime/src/kmp_csupport.cpp3
-rw-r--r--openmp/runtime/src/kmp_os.h5
-rw-r--r--openmp/runtime/src/kmp_platform.h6
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp3
-rw-r--r--openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h10
-rw-r--r--openmp/runtime/src/z_Linux_asm.S172
-rw-r--r--openmp/runtime/src/z_Linux_util.cpp3
7 files changed, 193 insertions, 9 deletions
diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp
index c778c97022f..ec3252ebbcd 100644
--- a/openmp/runtime/src/kmp_csupport.cpp
+++ b/openmp/runtime/src/kmp_csupport.cpp
@@ -676,7 +676,8 @@ void __kmpc_flush(ident_t *loc) {
#endif // KMP_COMPILER_ICC
}
#endif // KMP_MIC
-#elif (KMP_ARCH_ARM || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS || KMP_ARCH_MIPS64)
+#elif (KMP_ARCH_ARM || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS || KMP_ARCH_MIPS64 || \
+ KMP_ARCH_RISCV64)
// 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 c4c7bcf6cc5..ca3af3a308f 100644
--- a/openmp/runtime/src/kmp_os.h
+++ b/openmp/runtime/src/kmp_os.h
@@ -165,7 +165,8 @@ 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
+#elif KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || \
+ KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64
#define KMP_SIZE_T_SPEC KMP_UINT64_SPEC
#else
#error "Can't determine size_t printf format specifier."
@@ -840,7 +841,7 @@ extern kmp_real64 __kmp_xchg_real64(volatile kmp_real64 *p, kmp_real64 v);
#endif /* KMP_OS_WINDOWS */
#if KMP_ARCH_PPC64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS || \
- KMP_ARCH_MIPS64
+ KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64
#define KMP_MB() __sync_synchronize()
#endif
diff --git a/openmp/runtime/src/kmp_platform.h b/openmp/runtime/src/kmp_platform.h
index e4f2e06b962..3238deafc01 100644
--- a/openmp/runtime/src/kmp_platform.h
+++ b/openmp/runtime/src/kmp_platform.h
@@ -98,6 +98,7 @@
#define KMP_ARCH_PPC64 (KMP_ARCH_PPC64_LE || KMP_ARCH_PPC64_BE)
#define KMP_ARCH_MIPS 0
#define KMP_ARCH_MIPS64 0
+#define KMP_ARCH_RISCV64 0
#if KMP_OS_WINDOWS
#if defined(_M_AMD64) || defined(__x86_64)
@@ -135,6 +136,9 @@
#undef KMP_ARCH_MIPS
#define KMP_ARCH_MIPS 1
#endif
+#elif defined __riscv && __riscv_xlen == 64
+#undef KMP_ARCH_RISCV64
+#define KMP_ARCH_RISCV64 1
#endif
#endif
@@ -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_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64 + KMP_ARCH_RISCV64)
#error Unknown or unsupported architecture
#endif
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 452f2f468d2..684dc50e8b7 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -8023,7 +8023,8 @@ __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
+#if KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || \
+ KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64
#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 cc494cb4db4..f231e70d181 100644
--- a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h
+++ b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_config.h
@@ -161,6 +161,10 @@
# define ITT_ARCH_MIPS64 6
#endif /* ITT_ARCH_MIPS64 */
+#ifndef ITT_ARCH_RISCV64
+# define ITT_ARCH_RISCV64 7
+#endif /* ITT_ARCH_RISCV64 */
+
#ifndef ITT_ARCH
# if defined _M_IX86 || defined __i386__
# define ITT_ARCH ITT_ARCH_IA32
@@ -178,6 +182,8 @@
# define ITT_ARCH ITT_ARCH_MIPS
# elif defined __mips__ && defined __mips64
# define ITT_ARCH ITT_ARCH_MIPS64
+# elif defined __riscv && __riscv_xlen == 64
+# define ITT_ARCH ITT_ARCH_RISCV64
# endif
#endif
@@ -330,7 +336,9 @@ ITT_INLINE long __TBB_machine_fetchadd4(volatile void* ptr, long addend)
: "memory");
return result;
}
-#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
+#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
#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 4cd1508ab43..b491fcf186a 100644
--- a/openmp/runtime/src/z_Linux_asm.S
+++ b/openmp/runtime/src/z_Linux_asm.S
@@ -1563,6 +1563,173 @@ __kmp_invoke_microtask:
#endif /* KMP_ARCH_PPC64 */
+#if KMP_ARCH_RISCV64
+
+//------------------------------------------------------------------------
+//
+// typedef void (*microtask_t)(int *gtid, int *tid, ...);
+//
+// int __kmp_invoke_microtask(microtask_t pkfn, int gtid, int tid, int argc,
+// void *p_argv[]
+// #if OMPT_SUPPORT
+// ,
+// void **exit_frame_ptr
+// #endif
+// ) {
+// #if OMPT_SUPPORT
+// *exit_frame_ptr = OMPT_GET_FRAME_ADDRESS(0);
+// #endif
+//
+// (*pkfn)(&gtid, &tid, argv[0], ...);
+//
+// return 1;
+// }
+//
+// Parameters:
+// a0: pkfn
+// a1: gtid
+// a2: tid
+// a3: argc
+// a4: p_argv
+// a5: exit_frame_ptr
+//
+// Locals:
+// __gtid: gtid param pushed on stack so can pass &gtid to pkfn
+// __tid: tid param pushed on stack so can pass &tid to pkfn
+//
+// Temp. registers:
+//
+// t0: used to calculate the dynamic stack size / used to hold pkfn address
+// t1: used as temporary for stack placement calculation
+// t2: used as temporary for stack arguments
+// t3: used as temporary for number of remaining pkfn parms
+// t4: used to traverse p_argv array
+//
+// return: a0 (always 1/TRUE)
+//
+
+__gtid = -20
+__tid = -24
+
+// -- Begin __kmp_invoke_microtask
+// mark_begin;
+ .text
+ .globl __kmp_invoke_microtask
+ .p2align 1
+ .type __kmp_invoke_microtask,@function
+__kmp_invoke_microtask:
+ .cfi_startproc
+
+ // First, save ra and fp
+ addi sp, sp, -16
+ sd ra, 8(sp)
+ sd fp, 0(sp)
+ addi fp, sp, 16
+ .cfi_def_cfa fp, 0
+ .cfi_offset ra, -8
+ .cfi_offset fp, -16
+
+ // Compute the dynamic stack size:
+ //
+ // - We need 8 bytes for storing 'gtid' and 'tid', so we can pass them by
+ // reference
+ // - We need 8 bytes for each argument that cannot be passed to the 'pkfn'
+ // function by register. Given that we have 8 of such registers (a[0-7])
+ // and two + 'argc' arguments (consider &gtid and &tid), we need to
+ // reserve max(0, argc - 6)*8 extra bytes
+ //
+ // The total number of bytes is then max(0, argc - 6)*8 + 8
+
+ // Compute max(0, argc - 6) using the following bithack:
+ // max(0, x) = x - (x & (x >> 31)), where x := argc - 6
+ // Source: http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax
+ addi t0, a3, -6
+ srai t1, t0, 31
+ and t1, t0, t1
+ sub t0, t0, t1
+
+ addi t0, t0, 1
+
+ slli t0, t0, 3
+ sub sp, sp, t0
+
+ // Align the stack to 16 bytes
+ andi sp, sp, -16
+
+ mv t0, a0
+ mv t3, a3
+ mv t4, a4
+
+#if OMPT_SUPPORT
+ // Save frame pointer into exit_frame
+ sd fp, 0(a5)
+#endif
+
+ // Prepare arguments for the pkfn function (first 8 using a0-a7 registers)
+
+ sw a1, __gtid(fp)
+ sw a2, __tid(fp)
+
+ addi a0, fp, __gtid
+ addi a1, fp, __tid
+
+ beqz t3, .L_kmp_3
+ ld a2, 0(t4)
+
+ addi t3, t3, -1
+ beqz t3, .L_kmp_3
+ ld a3, 8(t4)
+
+ addi t3, t3, -1
+ beqz t3, .L_kmp_3
+ ld a4, 16(t4)
+
+ addi t3, t3, -1
+ beqz t3, .L_kmp_3
+ ld a5, 24(t4)
+
+ addi t3, t3, -1
+ beqz t3, .L_kmp_3
+ ld a6, 32(t4)
+
+ addi t3, t3, -1
+ beqz t3, .L_kmp_3
+ ld a7, 40(t4)
+
+ // Prepare any additional argument passed through the stack
+ addi t4, t4, 48
+ mv t1, sp
+ j .L_kmp_2
+.L_kmp_1:
+ ld t2, 0(t4)
+ sd t2, 0(t1)
+ addi t4, t4, 8
+ addi t1, t1, 8
+.L_kmp_2:
+ addi t3, t3, -1
+ bnez t3, .L_kmp_1
+
+.L_kmp_3:
+ // Call pkfn function
+ jalr t0
+
+ // Restore stack and return
+
+ addi a0, zero, 1
+
+ addi sp, fp, -16
+ ld fp, 0(sp)
+ ld ra, 8(sp)
+ addi sp, sp, 16
+ ret
+.Lfunc_end0:
+ .size __kmp_invoke_microtask, .Lfunc_end0-__kmp_invoke_microtask
+ .cfi_endproc
+
+// -- End __kmp_invoke_microtask
+
+#endif /* KMP_ARCH_RISCV64 */
+
#if KMP_ARCH_ARM || KMP_ARCH_MIPS
.data
.comm .gomp_critical_user_,32,8
@@ -1574,7 +1741,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
+#if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64
.data
.comm .gomp_critical_user_,32,8
.data
@@ -1583,7 +1750,8 @@ __kmp_unnamed_critical_addr:
__kmp_unnamed_critical_addr:
.8byte .gomp_critical_user_
.size __kmp_unnamed_critical_addr,8
-#endif /* KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 */
+#endif /* KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 ||
+ KMP_ARCH_RISCV64 */
#if KMP_OS_LINUX
# if KMP_ARCH_ARM
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 5f80c723a62..a35e1d3fd39 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -2331,7 +2331,8 @@ finish: // Clean up and exit.
#endif // USE_LOAD_BALANCE
#if !(KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_MIC || \
- ((KMP_OS_LINUX || KMP_OS_DARWIN) && KMP_ARCH_AARCH64) || KMP_ARCH_PPC64)
+ ((KMP_OS_LINUX || KMP_OS_DARWIN) && KMP_ARCH_AARCH64) || \
+ KMP_ARCH_PPC64 || KMP_ARCH_RISCV64)
// we really only need the case with 1 argument, because CLANG always build
// a struct of pointers to shared variables referenced in the outlined function
OpenPOWER on IntegriCloud