-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathembree-4.3.0-e2k.patch
158 lines (144 loc) · 4.83 KB
/
embree-4.3.0-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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
From 46cab529d9b854214c058561bc58d62a698ca72a Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <[email protected]>
Date: Fri, 27 Oct 2023 10:53:19 +0700
Subject: [PATCH] embree-4.3.0 e2k support
Use cmake option -DEMBREE_MAX_ISA=DEFAULT
---
common/math/vec2fa.h | 2 +-
common/math/vec3fa.h | 4 ++--
common/sys/intrinsics.h | 6 ++++++
common/sys/platform.h | 2 +-
common/sys/sysinfo.cpp | 7 +++++++
common/sys/sysinfo.h | 1 +
kernels/common/device.cpp | 5 +++++
7 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/common/math/vec2fa.h b/common/math/vec2fa.h
index d57e549..922b252 100644
--- a/common/math/vec2fa.h
+++ b/common/math/vec2fa.h
@@ -252,7 +252,7 @@ namespace embree
/// Euclidean Space Operators
////////////////////////////////////////////////////////////////////////////////
-#if defined(__SSE4_1__)
+#if defined(__SSE4_1__) && !defined(__e2k__)
__forceinline float dot ( const Vec2fa& a, const Vec2fa& b ) {
return _mm_cvtss_f32(_mm_dp_ps(a,b,0x3F));
}
diff --git a/common/math/vec3fa.h b/common/math/vec3fa.h
index 967e75d..fbb0432 100644
--- a/common/math/vec3fa.h
+++ b/common/math/vec3fa.h
@@ -321,7 +321,7 @@ namespace embree
/// Euclidean Space Operators
////////////////////////////////////////////////////////////////////////////////
-#if defined(__SSE4_1__)
+#if defined(__SSE4_1__) && !defined(__e2k__)
__forceinline float dot ( const Vec3fa& a, const Vec3fa& b ) {
return _mm_cvtss_f32(_mm_dp_ps(a.m128,b.m128,0x7F));
}
@@ -691,7 +691,7 @@ namespace embree
/// Euclidean Space Operators
////////////////////////////////////////////////////////////////////////////////
-#if defined(__SSE4_1__)
+#if defined(__SSE4_1__) && !defined(__e2k__)
__forceinline float dot ( const Vec3fx& a, const Vec3fx& b ) {
return _mm_cvtss_f32(_mm_dp_ps(a.m128,b.m128,0x7F));
}
diff --git a/common/sys/intrinsics.h b/common/sys/intrinsics.h
index f5074bb..69b67f3 100644
--- a/common/sys/intrinsics.h
+++ b/common/sys/intrinsics.h
@@ -18,6 +18,10 @@
#endif
#endif
+#ifdef __e2k__
+#include <x86intrin.h>
+#endif
+
#if defined(__BMI__) && defined(__GNUC__) && !defined(__INTEL_COMPILER)
#if !defined(_tzcnt_u32)
#define _tzcnt_u32 __tzcnt_u32
@@ -201,6 +205,8 @@ namespace embree
uint32_t high,low;
asm volatile ("rdtsc" : "=d"(high), "=a"(low));
return (((uint64_t)high) << 32) + (uint64_t)low;
+#elif defined(__e2k__)
+ return __rdtsc();
#else
/* Not supported yet, meaning measuring traversal cost per pixel does not work. */
return 0;
diff --git a/common/sys/platform.h b/common/sys/platform.h
index 6dc0cf3..002e5a2 100644
--- a/common/sys/platform.h
+++ b/common/sys/platform.h
@@ -58,7 +58,7 @@
#endif
/* detect 64 bit platform */
-#if defined(__X86_64__) || defined(__aarch64__)
+#if defined(__X86_64__) || defined(__aarch64__) || defined(__e2k__)
#define __64BIT__
#endif
diff --git a/common/sys/sysinfo.cpp b/common/sys/sysinfo.cpp
index 1e45061..d6bc3dc 100644
--- a/common/sys/sysinfo.cpp
+++ b/common/sys/sysinfo.cpp
@@ -100,6 +100,8 @@ namespace embree
return (char*)name;
#elif defined(__ARM_NEON)
return "ARM";
+#elif defined(__e2k__)
+ return "MCST";
#else
return "Unknown";
#endif
@@ -176,6 +178,8 @@ namespace embree
#elif defined(__ARM_NEON)
return CPU::ARM;
+#elif defined(__e2k__)
+ return CPU::E2K;
#endif
return CPU::UNKNOWN;
@@ -205,6 +209,7 @@ namespace embree
case CPU::CORE2 : return "Core2";
case CPU::CORE1 : return "Core";
case CPU::ARM : return "ARM";
+ case CPU::E2K : return "Elbrus 2000";
case CPU::UNKNOWN : return "Unknown CPU";
}
return "Unknown CPU (error)";
@@ -363,6 +368,8 @@ namespace embree
cpu_features |= CPU_FEATURE_NEON_2X;
return cpu_features;
+#elif defined(__e2k__)
+ return ISA;
#else
/* Unknown CPU. */
return 0;
diff --git a/common/sys/sysinfo.h b/common/sys/sysinfo.h
index cefd39a..ffe82ca 100644
--- a/common/sys/sysinfo.h
+++ b/common/sys/sysinfo.h
@@ -89,6 +89,7 @@ namespace embree
CORE2,
CORE1,
ARM,
+ E2K,
UNKNOWN,
};
diff --git a/kernels/common/device.cpp b/kernels/common/device.cpp
index c2e7c7c..c27a2dd 100644
--- a/kernels/common/device.cpp
+++ b/kernels/common/device.cpp
@@ -78,6 +78,11 @@ namespace embree
case CPU::XEON_PHI_KNIGHTS_MILL : frequency_level = FREQUENCY_SIMD512; break;
case CPU::XEON_PHI_KNIGHTS_LANDING: frequency_level = FREQUENCY_SIMD512; break;
case CPU::ARM: frequency_level = FREQUENCY_SIMD256; break;
+#ifdef __AVX__
+ case CPU::E2K: frequency_level = FREQUENCY_SIMD256; break;
+#else
+ case CPU::E2K: frequency_level = FREQUENCY_SIMD128; break;
+#endif
}
/* initialize global state */
--
2.34.1