diff --git a/0001-add-loongarch64-support-for-papi.patch b/0001-add-loongarch64-support-for-papi.patch new file mode 100644 index 0000000000000000000000000000000000000000..1907961e92a0b94a3d91ac4b4ff906b3b10f7f57 --- /dev/null +++ b/0001-add-loongarch64-support-for-papi.patch @@ -0,0 +1,86 @@ +From 8232dfebd1ee4c61da900c5b791042113483b368 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Thu, 28 Sep 2023 15:47:54 +0800 +Subject: [PATCH] add loongarch64 support for papi + +--- + src/libpfm4/config.mk | 4 ++++ + src/linux-context.h | 2 ++ + src/linux-timer.c | 18 ++++++++++++++++++ + src/mb.h | 3 +++ + 4 files changed, 27 insertions(+) + +diff --git a/src/libpfm4/config.mk b/src/libpfm4/config.mk +index 2b26947..bfeb927 100644 +--- a/src/libpfm4/config.mk ++++ b/src/libpfm4/config.mk +@@ -177,6 +177,10 @@ ifeq ($(ARCH),cell) + CONFIG_PFMLIB_CELL=y + endif + ++ifeq ($(ARCH),loongarch64) ++CONFIG_PFMLIB_ARCH_LOONGARCH64=y ++endif ++ + + # + # you shouldn't have to touch anything beyond this point +diff --git a/src/linux-context.h b/src/linux-context.h +index f46e557..4c0795e 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(__loongarch64) ++#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.__pc + #else + #error "OVERFLOW_ADDRESS() undefined!" + #endif +diff --git a/src/linux-timer.c b/src/linux-timer.c +index 0eaa79c..8a633c7 100644 +--- a/src/linux-timer.c ++++ b/src/linux-timer.c +@@ -245,6 +245,24 @@ get_cycles( void ) + return ret; + } + ++/************************/ ++/* loongarch64 get_cycles() */ ++/************************/ ++ ++#elif defined(__loongarch64) ++static inline long long ++get_cycles( void ) ++{ ++ register unsigned long ret; ++ ++ int rID = 0; ++ __asm__ __volatile__ ("ibar 0" ::: "memory"); ++ __asm__ __volatile__ ("rdtime.d %0, %1" :"=r"(ret),"=r"(rID)); ++ ++ return ret; ++} ++ ++ + /************************/ + /* POWER get_cycles() */ + /************************/ +diff --git a/src/mb.h b/src/mb.h +index 81797c5..359458f 100644 +--- a/src/mb.h ++++ b/src/mb.h +@@ -39,6 +39,9 @@ + #elif defined(__aarch64__) + #define rmb() asm volatile("dmb ld" ::: "memory") + ++#elif defined(__loongarch64) ++#define rmb() asm volatile("dbar 0" ::: "memory") ++ + #elif defined(__mips__) + #define rmb() asm volatile( \ + ".set mips2\n\t" \ +-- +2.40.1 + diff --git a/papi.spec b/papi.spec index 28d36702c25db0055dbcc3306cbd785760644ef8..081ad2a0c7a4185c15c674f2294933ecf8d0838d 100644 --- a/papi.spec +++ b/papi.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 # Default to no static libraries %{!?with_static: %global with_static 0} @@ -16,6 +16,7 @@ Source0: http://icl.cs.utk.edu/projects/papi/downloads/%{name}-%{version}.tar.g Patch1: papi-python3.patch Patch2: papi-nostatic.patch +Patch3: 0001-add-loongarch64-support-for-papi.patch Requires: papi-libs = %{version}-%{release} BuildRequires: make @@ -93,6 +94,7 @@ The %{name}-doc package contains documentation files for %{name}. %setup -q %patch1 -p1 -b .python3 %patch2 -p1 +%patch3 -p1 %build @@ -169,6 +171,10 @@ find %{buildroot} -type f -executable ! -iname "*.py" ! -iname "*.sh" | xargs ch %{abidir}/papi_multiplex_cost-option.list %{abidir}/papi_version-option.list %{abidir}/papi_xml_event_info-option.list +%{abidir}/papi_cost-option.list +%{abidir}/papi_decode-option.list +%{abidir}/papi_event_chooser-option.list +%{abidir}/papi_native_avail-option.list %files libs %{_libdir}/*.so.* @@ -204,5 +210,8 @@ find %{buildroot} -type f -executable ! -iname "*.py" ! -iname "*.sh" | xargs ch %doc INSTALL.txt README.md RELEASENOTES.txt %changelog +* Thu Sep 28 2023 Wenlong Zhang - 7.0.1-2 +- Add loongarch support for papi + * Mon Mar 27 2023 Yuanhong Peng - 7.0.1-1 - Init from upstream