diff --git a/add-loongarch64-support-for-papi.patch b/add-loongarch64-support-for-papi.patch new file mode 100644 index 0000000000000000000000000000000000000000..f629a0976be62a48b9daa7d72009eae5f0438876 --- /dev/null +++ b/add-loongarch64-support-for-papi.patch @@ -0,0 +1,67 @@ +From 5caa74b57f4f0bbcdef3a0d764b544f5c6061222 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Tue, 16 Apr 2024 02:24:07 +0000 +Subject: [PATCH] add loongarch64 support for papi + +--- + src/linux-context.h | 2 ++ + src/linux-timer.c | 15 +++++++++++++++ + src/mb.h | 3 +++ + 3 files changed, 20 insertions(+) + +diff --git a/src/linux-context.h b/src/linux-context.h +index 394a480..00ebf73 100644 +--- a/src/linux-context.h ++++ b/src/linux-context.h +@@ -41,6 +41,8 @@ typedef ucontext_t hwd_ucontext_t; + #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] ++#elif defined(__loongarch__) ++#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 46bfe75..666801f 100644 +--- a/src/linux-timer.c ++++ b/src/linux-timer.c +@@ -322,6 +322,21 @@ get_cycles( void ) + * Timers and Counters + */ + ++/****************************/ ++/* loongarch64 get_cycles() */ ++/****************************/ ++#elif defined(__loongarch__) ++static inline long long ++get_cycles(void) ++{ ++ register unsigned long ret = 0; ++ int rID = 0; ++ __asm__ __volatile__ ("ibar 0" ::: "memory"); ++ __asm__ __volatile__ ("rdtime.d %0, %1" :"=r"(ret),"=r"(rID)); ++ return ret; ++} ++ ++ + #elif !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_CLOCK_GETTIME) + #error "No get_cycles support for this architecture. " + #endif +diff --git a/src/mb.h b/src/mb.h +index 347436b..03e910b 100644 +--- a/src/mb.h ++++ b/src/mb.h +@@ -42,6 +42,9 @@ + #elif defined(__riscv) + #define rmb() asm volatile("fence ir, ir" ::: "memory") + ++#elif defined(__loongarch__) ++#define rmb() asm volatile("dbar 0" ::: "memory") ++ + #elif defined(__mips__) + #define rmb() asm volatile( \ + ".set mips2\n\t" \ +-- +2.43.0 + diff --git a/papi.spec b/papi.spec index 112b1552b83cd4da9c0fac311e54e9bd44d15751..dc0e863b8906c86cb861879408f131f0753f7b15 100644 --- a/papi.spec +++ b/papi.spec @@ -1,6 +1,6 @@ Name: papi Version: 7.1.0 -Release: 1 +Release: 2 Summary: Performance Application Programming Interface License: BSD-3-clause URL: http://icl.cs.utk.edu/papi/ @@ -13,6 +13,7 @@ Provides: papi-libs = %{version}-%{release} Obsoletes: papi-libs < %{version}-%{release} Patch0001: papi-add-support-riscv64.patch +Patch0002: add-loongarch64-support-for-papi.patch %description PAPI provides a programmer interface to monitor the performance of @@ -89,6 +90,9 @@ done %{_mandir}/man3/* %changelog +* Tue Apr 16 2024 Wenlong Zhang - 7.1.0-2 +- add loongarch64 support for papi + * Tue Jan 2 2024 liyanan - 7.1.0-1 - Upgrade to version 7.1.0