Skip to content

Commit 898ca38

Browse files
committed
cmake: AVX512 -> AVX_512F
1 parent 2938860 commit 898ca38

File tree

7 files changed

+34
-33
lines changed

7 files changed

+34
-33
lines changed

cmake/OpenCVCompilerOptimizations.cmake

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SSE / SSE2 (always available on 64-bit CPUs)
33
# SSE3 / SSSE3
44
# SSE4_1 / SSE4_2 / POPCNT
5-
# AVX / AVX2 / AVX512
5+
# AVX / AVX2 / AVX_512F
66
# FMA3
77

88
# CPU_{opt}_SUPPORTED=ON/OFF - compiler support (possibly with additional flag)
@@ -26,7 +26,7 @@
2626
#
2727
# CPU_DISPATCH_FLAGS_${opt} - flags for source files compiled separately (<name>.avx2.cpp)
2828

29-
set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX512")
29+
set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F")
3030
list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16)
3131
list(APPEND CPU_ALL_OPTIMIZATIONS VSX)
3232
list(REMOVE_DUPLICATES CPU_ALL_OPTIMIZATIONS)
@@ -145,7 +145,7 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
145145
endif()
146146

147147
if(X86 OR X86_64)
148-
ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX512")
148+
ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX_512F")
149149

150150
ocv_update(CPU_SSE_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse.cpp")
151151
ocv_update(CPU_SSE2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp")
@@ -157,11 +157,11 @@ if(X86 OR X86_64)
157157
ocv_update(CPU_AVX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx.cpp")
158158
ocv_update(CPU_AVX2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx2.cpp")
159159
ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
160-
ocv_update(CPU_AVX512_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512.cpp")
160+
ocv_update(CPU_AVX_512F_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512.cpp")
161161

162162
if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE)
163-
ocv_update(CPU_AVX512_IMPLIES "AVX2")
164-
ocv_update(CPU_AVX512_FORCE "") # Don't force other optimizations
163+
ocv_update(CPU_AVX_512F_IMPLIES "AVX2")
164+
ocv_update(CPU_AVX_512F_FORCE "") # Don't force other optimizations
165165
ocv_update(CPU_AVX2_IMPLIES "AVX;FMA3;FP16")
166166
ocv_update(CPU_FMA3_IMPLIES "AVX2")
167167
ocv_update(CPU_FMA3_FORCE "") # Don't force other optimizations
@@ -205,7 +205,7 @@ if(X86 OR X86_64)
205205
if(NOT X86_64) # x64 compiler doesn't support /arch:sse
206206
ocv_intel_compiler_optimization_option(SSE "-msse" "/arch:SSE")
207207
endif()
208-
#ocv_intel_compiler_optimization_option(AVX512 "-march=core-avx512")
208+
ocv_intel_compiler_optimization_option(AVX_512F "-march=common-avx512" "/arch:COMMON-AVX512")
209209
elseif(CMAKE_COMPILER_IS_GNUCXX)
210210
ocv_update(CPU_AVX2_FLAGS_ON "-mavx2")
211211
ocv_update(CPU_FP16_FLAGS_ON "-mf16c")
@@ -219,7 +219,8 @@ if(X86 OR X86_64)
219219
ocv_update(CPU_SSE2_FLAGS_ON "-msse2")
220220
ocv_update(CPU_SSE_FLAGS_ON "-msse")
221221
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
222-
ocv_update(CPU_AVX512_FLAGS_ON "-mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi")
222+
# -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi
223+
ocv_update(CPU_AVX_512F_FLAGS_ON "-mavx512f")
223224
endif()
224225
elseif(MSVC)
225226
ocv_update(CPU_AVX2_FLAGS_ON "/arch:AVX2")

modules/core/include/opencv2/core/cv_cpu_dispatch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@
8282
# include <immintrin.h>
8383
# define CV_AVX2 1
8484
#endif
85-
#ifdef CV_CPU_COMPILE_AVX512
85+
#ifdef CV_CPU_COMPILE_AVX_512F
8686
# include <immintrin.h>
87-
# define CV_AVX512 1
87+
# define CV_AVX_512F 1
8888
#endif
8989
#ifdef CV_CPU_COMPILE_FMA3
9090
# define CV_FMA3 1

modules/core/include/opencv2/core/cv_cpu_helper.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,20 @@
165165
#endif
166166
#define __CV_CPU_DISPATCH_CHAIN_FMA3(fn, args, mode, ...) CV_CPU_CALL_FMA3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
167167

168-
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX512
169-
# define CV_TRY_AVX512 1
170-
# define CV_CPU_HAS_SUPPORT_AVX512 1
171-
# define CV_CPU_CALL_AVX512(fn, args) return (opt_AVX512::fn args)
172-
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX512
173-
# define CV_TRY_AVX512 1
174-
# define CV_CPU_HAS_SUPPORT_AVX512 (cv::checkHardwareSupport(CV_CPU_AVX512))
175-
# define CV_CPU_CALL_AVX512(fn, args) if (CV_CPU_HAS_SUPPORT_AVX512) return (opt_AVX512::fn args)
168+
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX_512F
169+
# define CV_TRY_AVX_512F 1
170+
# define CV_CPU_HAS_SUPPORT_AVX_512F 1
171+
# define CV_CPU_CALL_AVX_512F(fn, args) return (opt_AVX_512F::fn args)
172+
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX_512F
173+
# define CV_TRY_AVX_512F 1
174+
# define CV_CPU_HAS_SUPPORT_AVX_512F (cv::checkHardwareSupport(CV_CPU_AVX_512F))
175+
# define CV_CPU_CALL_AVX_512F(fn, args) if (CV_CPU_HAS_SUPPORT_AVX_512F) return (opt_AVX_512F::fn args)
176176
#else
177-
# define CV_TRY_AVX512 0
178-
# define CV_CPU_HAS_SUPPORT_AVX512 0
179-
# define CV_CPU_CALL_AVX512(fn, args)
177+
# define CV_TRY_AVX_512F 0
178+
# define CV_CPU_HAS_SUPPORT_AVX_512F 0
179+
# define CV_CPU_CALL_AVX_512F(fn, args)
180180
#endif
181-
#define __CV_CPU_DISPATCH_CHAIN_AVX512(fn, args, mode, ...) CV_CPU_CALL_AVX512(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
181+
#define __CV_CPU_DISPATCH_CHAIN_AVX_512F(fn, args, mode, ...) CV_CPU_CALL_AVX_512F(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
182182

183183
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON
184184
# define CV_TRY_NEON 1

modules/dnn/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ endif()
1313

1414
set(the_description "Deep neural network module. It allows to load models from different frameworks and to make forward pass")
1515

16-
ocv_add_dispatched_file("layers/layers_common" AVX AVX2 AVX512)
16+
ocv_add_dispatched_file("layers/layers_common" AVX AVX2 AVX_512F)
1717

1818
ocv_add_module(dnn opencv_core opencv_imgproc WRAP python matlab java js)
1919
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo

modules/dnn/src/layers/convolution_layer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class ConvolutionLayerImpl : public BaseConvolutionLayerImpl
384384
p.is1x1_ = kernel == Size(0,0) && pad == Size(0, 0);
385385
p.useAVX = checkHardwareSupport(CPU_AVX);
386386
p.useAVX2 = checkHardwareSupport(CPU_AVX2);
387-
p.useAVX512 = checkHardwareSupport(CPU_AVX_512DQ);
387+
p.useAVX512 = CV_CPU_HAS_SUPPORT_AVX_512F;
388388

389389
int ncn = std::min(inpCn, (int)BLK_SIZE_CN);
390390
p.ofstab_.resize(kernel.width*kernel.height*ncn);
@@ -564,10 +564,10 @@ class ConvolutionLayerImpl : public BaseConvolutionLayerImpl
564564
// now compute dot product of the weights
565565
// and im2row-transformed part of the tensor
566566
int bsz = ofs1 - ofs0;
567-
#if CV_TRY_AVX512
567+
#if CV_TRY_AVX_512F
568568
/* AVX512 convolution requires an alignment of 16, and ROI is only there for larger vector sizes */
569569
if(useAVX512)
570-
opt_AVX512::fastConv(wptr, wstep, biasptr, rowbuf0, data_out0 + ofs0,
570+
opt_AVX_512F::fastConv(wptr, wstep, biasptr, rowbuf0, data_out0 + ofs0,
571571
outShape, bsz, vsz, vsz_a, relu, cn0 == 0);
572572
else
573573
#endif
@@ -1102,7 +1102,7 @@ class DeConvolutionLayerImpl : public BaseConvolutionLayerImpl
11021102
nstripes_ = nstripes;
11031103
useAVX = checkHardwareSupport(CPU_AVX);
11041104
useAVX2 = checkHardwareSupport(CPU_AVX2);
1105-
useAVX512 = checkHardwareSupport(CPU_AVX_512DQ);
1105+
useAVX512 = CV_CPU_HAS_SUPPORT_AVX_512F;
11061106
}
11071107

11081108
void operator()(const Range& range_) const
@@ -1120,9 +1120,9 @@ class DeConvolutionLayerImpl : public BaseConvolutionLayerImpl
11201120
size_t bstep = b_->step1();
11211121
size_t cstep = c_->step1();
11221122

1123-
#if CV_TRY_AVX512
1123+
#if CV_TRY_AVX_512F
11241124
if( useAVX512 )
1125-
opt_AVX512::fastGEMM( aptr, astep, bptr, bstep, cptr, cstep, mmax, kmax, nmax );
1125+
opt_AVX_512F::fastGEMM( aptr, astep, bptr, bstep, cptr, cstep, mmax, kmax, nmax );
11261126
else
11271127
#endif
11281128
#if CV_TRY_AVX2

modules/dnn/src/layers/fully_connected_layer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class FullyConnectedLayerImpl : public InnerProductLayer
161161
p.activ = activ;
162162
p.useAVX = checkHardwareSupport(CPU_AVX);
163163
p.useAVX2 = checkHardwareSupport(CPU_AVX2);
164-
p.useAVX512 = checkHardwareSupport(CPU_AVX_512DQ);
164+
p.useAVX512 = CV_CPU_HAS_SUPPORT_AVX_512F;
165165

166166
parallel_for_(Range(0, nstripes), p, nstripes);
167167
}
@@ -196,9 +196,9 @@ class FullyConnectedLayerImpl : public InnerProductLayer
196196

197197
memcpy(sptr, sptr_, vecsize*sizeof(sptr[0]));
198198

199-
#if CV_TRY_AVX512
199+
#if CV_TRY_AVX_512F
200200
if( useAVX512 )
201-
opt_AVX512::fastGEMM1T( sptr, wptr, wstep, biasptr, dptr, nw, vecsize);
201+
opt_AVX_512F::fastGEMM1T( sptr, wptr, wstep, biasptr, dptr, nw, vecsize);
202202
else
203203
#endif
204204
#if CV_TRY_AVX2

modules/dnn/src/layers/layers_common.simd.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void fastGEMM( const float* aptr, size_t astep, const float* bptr,
301301
{
302302
int n = 0;
303303

304-
#ifdef CV_AVX512
304+
#if CV_AVX_512F
305305
for( ; n <= nb - 32; n += 32 )
306306
{
307307
for( int m = 0; m < ma; m += 4 )

0 commit comments

Comments
 (0)