Group :: Development/C++
RPM: libbenchmark
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: libbenchmark-e2k.patch
Download
Download
From 2cab7229fc3bdfb13035a5aa795af17c29436f13 Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <jpegqs@gmail.com>
Date: Thu, 10 Jun 2021 14:15:07 +0700
Subject: [PATCH] benchmark-1.5.2 e2k support
---
include/benchmark/benchmark.h | 7 +++++++
src/cycleclock.h | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h
index 01f1262..ac344f4 100644
--- a/include/benchmark/benchmark.h
+++ b/include/benchmark/benchmark.h
@@ -310,6 +310,12 @@ BENCHMARK_UNUSED static int stream_init_anchor = InitializeStreams();
// intended to add little to no overhead.
// See: https://youtu.be/nXaxk27zwlk?t=2441
#ifndef BENCHMARK_HAS_NO_INLINE_ASSEMBLY
+#ifdef __e2k__
+template <class Tp>
+inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) {
+ asm volatile("" : : "r"(&reinterpret_cast<char const volatile&>(value)) : "memory");
+}
+#else
template <class Tp>
inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) {
asm volatile("" : : "r,m"(value) : "memory");
@@ -323,6 +329,7 @@ inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) {
asm volatile("" : "+m,r"(value) : : "memory");
#endif
}
+#endif
// Force the compiler to flush pending writes to global memory. Acts as an
// effective read/write barrier
diff --git a/src/cycleclock.h b/src/cycleclock.h
index 179c67c..14c212b 100644
--- a/src/cycleclock.h
+++ b/src/cycleclock.h
@@ -41,6 +41,10 @@ extern "C" uint64_t __rdtsc();
#pragma intrinsic(__rdtsc)
#endif
+#ifdef __e2k__
+#include <x86intrin.h>
+#endif
+
#if !defined(BENCHMARK_OS_WINDOWS) || defined(BENCHMARK_OS_MINGW)
#include <sys/time.h>
#include <time.h>
@@ -116,6 +120,8 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
_asm rdtsc
#elif defined(COMPILER_MSVC)
return __rdtsc();
+#elif defined(__e2k__)
+ return __rdtsc();
#elif defined(BENCHMARK_OS_NACL)
// Native Client validator on x86/x86-64 allows RDTSC instructions,
// and this case is handled above. Native Client validator on ARM
--
2.17.1