File riscv.patch of Package papi
Index: papi-7.0.0/src/linux-context.h
===================================================================
--- papi-7.0.0.orig/src/linux-context.h
+++ papi-7.0.0/src/linux-context.h
@@ -39,6 +39,8 @@ typedef ucontext_t hwd_ucontext_t;
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.pc
#elif defined(__hppa__)
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.sc_iaoq[0]
+#elif defined(__riscv)
+#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.__gregs[REG_PC]
#else
#error "OVERFLOW_ADDRESS() undefined!"
#endif
Index: papi-7.0.0/src/linux-timer.c
===================================================================
--- papi-7.0.0.orig/src/linux-timer.c
+++ papi-7.0.0/src/linux-timer.c
@@ -301,6 +301,21 @@ get_cycles( void )
}
+/************************/
+/* riscv64 get_cycles() */
+/************************/
+
+#elif defined(__riscv)
+static inline long long
+get_cycles( void )
+{
+ register unsigned long ret;
+
+ __asm__ __volatile__ ("rdtime %0" : "=r" (ret));
+
+ return ret;
+}
+
#elif !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_CLOCK_GETTIME)
#error "No get_cycles support for this architecture. "
Index: papi-7.0.0/src/mb.h
===================================================================
--- papi-7.0.0.orig/src/mb.h
+++ papi-7.0.0/src/mb.h
@@ -63,6 +63,9 @@
#define rmb() asm volatile("lfence":::"memory")
#endif
+#elif defined(__riscv)
+#define rmb() asm volatile("fence ir,ir" ::: "memory")
+
#else
#error Need to define rmb for this architecture!
#error See the kernel source directory: tools/perf/perf.h file