diff --git a/papi-riscv64.patch b/papi-riscv64.patch new file mode 100644 index 0000000..3851670 --- /dev/null +++ b/papi-riscv64.patch @@ -0,0 +1,67 @@ +From b464420f3a2855b2c800413a4c5767b69e088087 Mon Sep 17 00:00:00 2001 +From: Vince Weaver +Date: Tue, 9 Jan 2024 21:50:26 +0000 +Subject: [PATCH] add initial riscv support + +This adds basic support for the RISC-V architecture + +After this PAPI will compile and the tools will run, however no events will +work because of missing libpfm4 support. + +Tested on a BeagleV-Ahead board +--- + src/linux-context.h | 2 ++ + src/linux-timer.c | 2 +- + src/mb.h | 10 ++++++++++ + 3 files changed, 13 insertions(+), 1 deletion(-) + +diff --git a/src/linux-context.h b/src/linux-context.h +index f46e5577b..394a4804d 100644 +--- a/src/linux-context.h ++++ b/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 +diff --git a/src/linux-timer.c b/src/linux-timer.c +index 0eaa79c66..be489f325 100644 +--- a/src/linux-timer.c ++++ b/src/linux-timer.c +@@ -281,7 +281,7 @@ static inline long long get_cycles() + return retval; + } + +-#elif (defined(__arm__) || defined(__mips__) || defined(__hppa__)) ++#elif (defined(__arm__) || defined(__mips__) || defined(__hppa__)) || defined(__riscv) + static inline long long + get_cycles( void ) + { +diff --git a/src/mb.h b/src/mb.h +index 81797c553..56d980410 100644 +--- a/src/mb.h ++++ b/src/mb.h +@@ -63,6 +63,16 @@ + #define rmb() asm volatile("lfence":::"memory") + #endif + ++ ++#elif defined (__riscv) ++#define RISCV_FENCE(p, s) \ ++ __asm__ __volatile__ ("fence " #p "," #s : : : "memory") ++ ++/* These barriers need to enforce ordering on both devices or memory. */ ++#define mb() RISCV_FENCE(iorw,iorw) ++#define rmb() RISCV_FENCE(ir,ir) ++#define wmb() RISCV_FENCE(ow,ow) ++ + #else + #error Need to define rmb for this architecture! + #error See the kernel source directory: tools/perf/perf.h file +-- +2.49.0 + diff --git a/papi.spec b/papi.spec index 5efb420..3a59882 100644 --- a/papi.spec +++ b/papi.spec @@ -15,7 +15,7 @@ Summary: Performance Application Programming Interface Name: papi Version: 7.1.0 -Release: 6%{?dist} +Release: 6%{?dist}.alma.1 License: BSD-3-Clause Requires: papi-libs = %{version}-%{release} URL: http://icl.cs.utk.edu/papi/ @@ -23,6 +23,9 @@ Source0: http://icl.cs.utk.edu/projects/papi/downloads/%{name}-%{version}.tar.gz Patch1: papi-python3.patch Patch5: papi-nostatic.patch Patch6: papi-libsde.patch + +# AlmaLinux Patch +Patch1001: papi-riscv64.patch BuildRequires: make BuildRequires: autoconf BuildRequires: doxygen @@ -94,6 +97,9 @@ the PAPI user-space libraries and interfaces. %prep %setup -q + +# Applying AlmaLinux Patch +%patch -P 1001 -p1 -b .papi-riscv64 %patch 1 -p1 -b .python3 %patch 5 -p1 %patch 6 -p1 -b .flags @@ -191,6 +197,9 @@ find %{buildroot} -type f -executable ! -iname "*.py" ! -iname "*.sh" | xargs ch %endif %changelog +* Thu Aug 21 2025 Andrew Lukoshko - 7.1.0-6.alma.1 +- Add initial RISC-V support + * Tue Oct 29 2024 Troy Dawson - 7.1.0-6 - Bump release for October 2024 mass rebuild: Resolves: RHEL-64018