114 Star 0 Fork 28

src-openEuler/papi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
add-loongarch64-support-for-papi.patch 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
zhangwenlong01 提交于 2024-04-16 02:27 . add loongarch64 support for papi
From 5caa74b57f4f0bbcdef3a0d764b544f5c6061222 Mon Sep 17 00:00:00 2001
From: Wenlong Zhang <zhangwenlong@loongson.cn>
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/papi.git
git@gitee.com:src-openeuler/papi.git
src-openeuler
papi
papi
master

搜索帮助