-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathopencv-4.7.0-e2k.patch
183 lines (171 loc) · 6.99 KB
/
opencv-4.7.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
From 7b680a555e1d93faf4eb50f04f0e7499f7579ffe Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <[email protected]>
Date: Tue, 20 Jun 2023 14:13:05 +0700
Subject: [PATCH] opencv-4.7.0 e2k support
---
3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp | 7 ++++-
cmake/OpenCVCompilerOptimizations.cmake | 28 +++++++++++++++++++
cmake/OpenCVCompilerOptions.cmake | 6 +++-
cmake/OpenCVDetectCXXCompiler.cmake | 3 ++
modules/core/include/opencv2/core/cvdef.h | 1 +
modules/core/src/system.cpp | 12 ++++++++
modules/ts/include/opencv2/ts/ts_gtest.h | 8 ++++++
7 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp b/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp
index fe1d8a2..809bf90 100644
--- a/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp
+++ b/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp
@@ -39,7 +39,7 @@
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
namespace {
-#if defined(IMF_HAVE_SSE2) && defined(__GNUC__) && !defined(__ANDROID__)
+#if defined(IMF_HAVE_SSE2) && defined(__GNUC__) && !defined(__ANDROID__) && !defined(__e2k__)
// Helper functions for gcc + SSE enabled
void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
@@ -132,6 +132,11 @@ CpuId::CpuId():
ssse3 = true;
sse4_1 = true;
#endif
+#elif defined(__e2k__)
+ sse2 = true;
+ sse3 = true;
+ ssse3 = true;
+ sse4_1 = true;
#endif
}
diff --git a/cmake/OpenCVCompilerOptimizations.cmake b/cmake/OpenCVCompilerOptimizations.cmake
index 28929c3..d74e2a5 100644
--- a/cmake/OpenCVCompilerOptimizations.cmake
+++ b/cmake/OpenCVCompilerOptimizations.cmake
@@ -328,6 +328,34 @@ if(X86 OR X86_64)
endif()
endif()
+elseif(E2K)
+ ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT")
+
+ ocv_update(CPU_SSE_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse.cpp")
+ ocv_update(CPU_SSE2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp")
+ ocv_update(CPU_SSE3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse3.cpp")
+ ocv_update(CPU_SSSE3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_ssse3.cpp")
+ ocv_update(CPU_SSE4_1_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse41.cpp")
+ ocv_update(CPU_POPCNT_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_popcnt.cpp")
+
+ if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE)
+ ocv_update(CPU_POPCNT_IMPLIES "SSE4_1")
+ ocv_update(CPU_POPCNT_FORCE "") # Don't force other optimizations
+ ocv_update(CPU_SSE4_1_IMPLIES "SSE3;SSSE3")
+ ocv_update(CPU_SSSE3_IMPLIES "SSE3")
+ ocv_update(CPU_SSE3_IMPLIES "SSE2")
+ ocv_update(CPU_SSE2_IMPLIES "SSE")
+ endif()
+
+ ocv_update(CPU_POPCNT_FLAGS_ON "-mpopcnt")
+ ocv_update(CPU_SSE4_1_FLAGS_ON "-msse4.1 -mno-avx")
+ ocv_update(CPU_SSE3_FLAGS_ON "-msse3")
+ ocv_update(CPU_SSSE3_FLAGS_ON "-mssse3")
+ ocv_update(CPU_SSE2_FLAGS_ON "-msse2")
+ ocv_update(CPU_SSE_FLAGS_ON "-msse")
+
+ set(CPU_BASELINE "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT" CACHE STRING "${HELP_CPU_BASELINE}")
+
elseif(ARM OR AARCH64)
ocv_update(CPU_NEON_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_neon.cpp")
ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake
index 3f3358a..a86c13d 100644
--- a/cmake/OpenCVCompilerOptions.cmake
+++ b/cmake/OpenCVCompilerOptions.cmake
@@ -131,7 +131,11 @@ if(CV_GCC OR CV_CLANG)
add_extra_compiler_option(-Wundef)
add_extra_compiler_option(-Winit-self)
add_extra_compiler_option(-Wpointer-arith)
- if(NOT (CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0"))
+ if(E2K)
+ add_extra_compiler_option(-Wno-unused-parameter)
+ add_extra_compiler_option(-Wno-unused-function)
+ endif()
+ if(NOT (CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") AND NOT E2K)
add_extra_compiler_option(-Wshadow) # old GCC emits warnings for variables + methods combination
endif()
add_extra_compiler_option(-Wsign-promo)
diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake
index 8fe89b3..4eae03b 100644
--- a/cmake/OpenCVDetectCXXCompiler.cmake
+++ b/cmake/OpenCVDetectCXXCompiler.cmake
@@ -11,6 +11,7 @@
# - AARCH64 - ARMv8+ (64-bit)
# - PPC64 / PPC64LE - PowerPC
# - MIPS
+# - E2K - Elbrus 2000
#
# OS:
# - WIN32 - Windows | MINGW
@@ -100,6 +101,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(mips.*|MIPS.*)")
set(MIPS 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv.*|RISCV.*)")
set(RISCV 1)
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "e2k.*")
+ set(E2K 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(loongarch64.*|LOONGARCH64.*)")
set(LOONGARCH64 1)
else()
diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h
index 957e7bc..5932a53 100644
--- a/modules/core/include/opencv2/core/cvdef.h
+++ b/modules/core/include/opencv2/core/cvdef.h
@@ -725,6 +725,7 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType)
# elif __cplusplus >= 201703L
// available when compiler is C++17 compliant
# define CV_NODISCARD_STD [[nodiscard]]
+# elif defined(__EDG__)
# elif defined(__INTEL_COMPILER)
// see above, available when C++17 is enabled
# elif defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L
diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp
index 027072a..ecaabea 100644
--- a/modules/core/src/system.cpp
+++ b/modules/core/src/system.cpp
@@ -627,6 +627,18 @@ struct HWFeatures
close(cpufile);
}
+ #elif defined __e2k__
+ have[CV_CPU_MMX] = true;
+ have[CV_CPU_SSE] = true;
+ have[CV_CPU_SSE2] = true;
+ have[CV_CPU_SSE3] = true;
+ have[CV_CPU_SSSE3] = true;
+ have[CV_CPU_SSE4_1] = true;
+ have[CV_CPU_POPCNT] = true;
+ #ifdef __AVX2__
+ have[CV_CPU_AVX] = true;
+ have[CV_CPU_AVX2] = true;
+ #endif
#endif
#elif (defined __APPLE__)
#if (defined __ARM_NEON__ || (defined __ARM_NEON && defined __aarch64__))
diff --git a/modules/ts/include/opencv2/ts/ts_gtest.h b/modules/ts/include/opencv2/ts/ts_gtest.h
index b1c6c12..a6c3c96 100644
--- a/modules/ts/include/opencv2/ts/ts_gtest.h
+++ b/modules/ts/include/opencv2/ts/ts_gtest.h
@@ -11915,7 +11915,11 @@ typename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() {
}
} // namespace internal:: // fixes MacOS X issue with "friend class internal/*::anon*/::ParameterizedTestFactory;"
+#ifdef __EDG__
+namespace internal {
+#else
namespace { // wrap into anynomous namespace to avoid build warnings like GCC's -Wsubobject-linkage
+#endif
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
@@ -21710,7 +21714,11 @@ class WithParamInterface {
}
// TestClass must be a subclass of WithParamInterface<T> and Test.
+#ifdef __EDG__
+ template <class TestClass> friend class internal::ParameterizedTestFactory;
+#else
template <class TestClass> friend class /*internal::*/ParameterizedTestFactory;
+#endif
};
// Most value-parameterized classes can ignore the existence of
--
2.34.1