-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbenchmark-1.7.1-e2k.patch
59 lines (55 loc) · 2.11 KB
/
benchmark-1.7.1-e2k.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 0a1d917e47dbd5a943049eb8fa0f4fc6c516c318 Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <[email protected]>
Date: Wed, 3 May 2023 15:17:10 +0700
Subject: [PATCH] benchmark-1.7.1 e2k support
---
include/benchmark/benchmark.h | 11 ++++++++++-
src/cycleclock.h | 6 ++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h
index fefe9b2..455c320 100644
--- a/include/benchmark/benchmark.h
+++ b/include/benchmark/benchmark.h
@@ -439,7 +439,16 @@ inline BENCHMARK_ALWAYS_INLINE void ClobberMemory() {
// intended to add little to no overhead.
// See: https://youtu.be/nXaxk27zwlk?t=2441
#ifndef BENCHMARK_HAS_NO_INLINE_ASSEMBLY
-#if !defined(__GNUC__) || defined(__llvm__) || defined(__INTEL_COMPILER)
+#if defined(__e2k__) && defined(__EDG__)
+template <class Tp>
+inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) {
+ asm volatile("" : : "r"(&reinterpret_cast<char const volatile&>(value)) : "memory");
+}
+template <class Tp>
+inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) {
+ asm volatile("" : : "r"(&reinterpret_cast<char volatile&>(value)) : "memory");
+}
+#elif !defined(__GNUC__) || defined(__llvm__) || defined(__INTEL_COMPILER)
template <class Tp>
inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) {
asm volatile("" : : "r,m"(value) : "memory");
diff --git a/src/cycleclock.h b/src/cycleclock.h
index df6ffa5..f64e00e 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>
@@ -122,6 +126,8 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
return virtual_timer_value;
#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.34.1