From d02b70b9cd9c407a9894d5b6d9ea2f992036d4ee Mon Sep 17 00:00:00 2001 From: psong Date: Mon, 8 Jul 2024 22:59:54 +0800 Subject: [PATCH] update risv-c support --- 1000-add-riscv-support.patch | 18 ---------- 1001-update-risv-support.patch | 62 ++++++++++++++++++++++++++++++++++ mvapich2.spec | 7 ++-- 3 files changed, 67 insertions(+), 20 deletions(-) delete mode 100644 1000-add-riscv-support.patch create mode 100644 1001-update-risv-support.patch diff --git a/1000-add-riscv-support.patch b/1000-add-riscv-support.patch deleted file mode 100644 index 707880f..0000000 --- a/1000-add-riscv-support.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/src/mpid/ch3/channels/common/include/mv2_clock.h 2018-07-24 22:30:00.000000000 +0800 -+++ b/src/mpid/ch3/channels/common/include/mv2_clock.h 2022-03-03 14:19:52.430980863 +0800 -@@ -92,7 +92,14 @@ - - return ret; - } -- -+#elif defined(__riscv) -+typedef unsigned long cycles_t; -+static inline cycles_t get_cycles() -+{ -+ unsigned long clk; -+ asm volatile("rdcycle %0" : "=r" (clk)); -+ return clk; -+} - #else - #warning get_cycles not implemented for this architecture: attempt asm/timex.h - #include diff --git a/1001-update-risv-support.patch b/1001-update-risv-support.patch new file mode 100644 index 0000000..cd438c9 --- /dev/null +++ b/1001-update-risv-support.patch @@ -0,0 +1,62 @@ +diff --git a/src/mpid/ch3/channels/common/include/mv2_clock.h b/src/mpid/ch3/channels/common/include/mv2_clock.h +index 77552c4..b7e41a3 100644 +--- a/src/mpid/ch3/channels/common/include/mv2_clock.h ++++ b/src/mpid/ch3/channels/common/include/mv2_clock.h +@@ -93,6 +93,14 @@ static inline cycles_t get_cycles() + return ret; + } + ++#elif defined(__riscv) ++// this function don't call ++typedef unsigned long cycles_t; ++static inline cycles_t get_cycles() ++{ ++ return 0; ++} ++ + #else + #warning get_cycles not implemented for this architecture: attempt asm/timex.h + #include +diff --git a/src/mpid/ch3/channels/common/src/util/mv2_clock.c b/src/mpid/ch3/channels/common/src/util/mv2_clock.c +index 4d9eb0a..74d5686 100644 +--- a/src/mpid/ch3/channels/common/src/util/mv2_clock.c ++++ b/src/mpid/ch3/channels/common/src/util/mv2_clock.c +@@ -52,7 +52,7 @@ + /* For gettimeofday */ + #define _BSD_SOURCE + #include +- ++#include + #include + #include + #include +@@ -218,6 +218,21 @@ double get_cpu_mhz() + + #ifndef DISABLE_LOW_LEVEL_TIMERS + ++#if defined(__riscv) ++void mv2_init_timers() ++{ ++} ++double mv2_get_time_us() ++{ ++ struct timespec ts; ++ if (clock_gettime(CLOCK_REALTIME,&ts) == -1){ ++ PRINT_ERROR("Error in clock_gettime."); ++ exit(-1); ++ } ++ long long time_us = (long long )ts.tv_sec * 1000000 + ts.tv_nsec / 1000; ++ return (double)time_us; ++} ++#else + void mv2_init_timers() + { + global_mhz = get_cpu_mhz(); +@@ -231,6 +246,7 @@ double mv2_get_time_us() + { + return (get_cycles()/global_mhz); + } ++#endif + + #else + diff --git a/mvapich2.spec b/mvapich2.spec index d6ae6b8..7b92241 100644 --- a/mvapich2.spec +++ b/mvapich2.spec @@ -2,7 +2,7 @@ Name: mvapich2 Version: 2.3.6 -Release: 4 +Release: 5 Summary: OSU MVAPICH2 MPI package License: BSD and MIT URL: http://mvapich.cse.ohio-state.edu @@ -12,7 +12,7 @@ Source2: mvapich2.macros.in Patch0001: 0001-mvapich23-unbundle-contrib-hwloc.patch Patch0002: 0002-mvapich23-unbundle-osu_benchmarks.patch %ifarch riscv64 -Patch1000: 1000-add-riscv-support.patch +Patch1000: 1001-update-risv-support.patch %endif Patch1001: 0001-mvapich2-2.3.6-add-support-for-loongarch64.patch BuildRequires: gcc-gfortran python3-devel gcc-c++ @@ -262,6 +262,9 @@ cd .. %changelog +* Mon Jul 8 2024 pSomng - 2.3.6-5 +- update risc-v support + * Thu Apr 25 2024 Pengda Dou - 2.3.6-4 - add support for loongarch64 -- Gitee