Skip to content

Commit

Permalink
x86: remove compile-time checks for AVX-512
Browse files Browse the repository at this point in the history
  • Loading branch information
sekrit-twc committed Oct 27, 2024
1 parent 2aed91a commit 017c814
Show file tree
Hide file tree
Showing 22 changed files with 19 additions and 142 deletions.
32 changes: 11 additions & 21 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ libzimg_internal_la_SOURCES += \
src/zimg/resize/arm/resize_impl_arm.cpp \
src/zimg/resize/arm/resize_impl_arm.h


libneon_la_SOURCES = \
src/zimg/colorspace/arm/operation_impl_neon.cpp \
src/zimg/depth/arm/depth_convert_neon.cpp \
Expand All @@ -169,7 +168,8 @@ libzimg_internal_la_LIBADD += libneon.la
endif # ARMSIMD

if X86SIMD
noinst_LTLIBRARIES += libsse.la libsse2.la libavx.la libf16c.la libavx2.la
noinst_LTLIBRARIES += libsse.la libsse2.la libavx.la libf16c.la libavx2.la \
libavx512.la libavx512_vnni.la

libzimg_internal_la_SOURCES += \
src/zimg/colorspace/x86/operation_impl_x86.cpp \
Expand All @@ -193,7 +193,6 @@ libzimg_internal_la_SOURCES += \
src/zimg/unresize/x86/unresize_impl_x86.cpp \
src/zimg/unresize/x86/unresize_impl_x86.h


libsse_la_SOURCES = \
src/zimg/colorspace/x86/operation_impl_sse.cpp \
src/zimg/resize/x86/resize_impl_sse.cpp \
Expand Down Expand Up @@ -235,12 +234,6 @@ libavx2_la_SOURCES = \
libavx2_la_CXXFLAGS = $(AM_CXXFLAGS) -mavx2 -mf16c -mfma $(HSW_CFLAGS)
libavx2_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/src/zimg $(graphengineflags)

libzimg_internal_la_LIBADD += libsse.la libsse2.la libavx.la libf16c.la libavx2.la
endif # X86SIMD

if X86SIMD_AVX512
noinst_LTLIBRARIES += libavx512.la libavx512_vnni.la

libavx512_la_SOURCES = \
src/zimg/colorspace/x86/gamma_constants_avx512.cpp \
src/zimg/colorspace/x86/gamma_constants_avx512.h \
Expand All @@ -257,8 +250,8 @@ libavx512_vnni_la_SOURCES = src/zimg/resize/x86/resize_impl_avx512_vnni.cpp
libavx512_vnni_la_CXXFLAGS = $(AM_CXXFLAGS) -mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512vnni $(CLX_CFLAGS)
libavx512_vnni_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/src/zimg $(graphengineflags)

libzimg_internal_la_LIBADD += libavx512.la libavx512_vnni.la
endif # X86SIMD_AVX512
libzimg_internal_la_LIBADD += libsse.la libsse2.la libavx.la libf16c.la libavx2.la libavx512.la libavx512_vnni.la
endif # X86SIMD


libtestcommon_la_SOURCES = \
Expand Down Expand Up @@ -405,32 +398,28 @@ if X86SIMD
test_unit_test_SOURCES += \
test/colorspace/x86/colorspace_avx_test.cpp \
test/colorspace/x86/colorspace_avx2_test.cpp \
test/colorspace/x86/colorspace_avx512_test.cpp \
test/colorspace/x86/colorspace_sse_test.cpp \
test/colorspace/x86/colorspace_sse2_test.cpp \
test/colorspace/x86/gamma_constants_avx512_test.cpp \
test/depth/x86/depth_convert_avx2_test.cpp \
test/depth/x86/depth_convert_avx512_test.cpp \
test/depth/x86/depth_convert_sse2_test.cpp \
test/depth/x86/dither_avx2_test.cpp \
test/depth/x86/dither_avx512_test.cpp \
test/depth/x86/dither_sse2_test.cpp \
test/depth/x86/error_diffusion_avx2_test.cpp \
test/depth/x86/error_diffusion_sse2_test.cpp \
test/depth/x86/f16c_ivb_test.cpp \
test/depth/x86/f16c_sse2_test.cpp \
test/resize/x86/resize_impl_avx_test.cpp \
test/resize/x86/resize_impl_avx2_test.cpp \
test/resize/x86/resize_impl_avx512_test.cpp \
test/resize/x86/resize_impl_avx512_vnni_test.cpp
test/resize/x86/resize_impl_sse_test.cpp \
test/resize/x86/resize_impl_sse2_test.cpp
endif # X86SIMD

if X86SIMD_AVX512
test_unit_test_SOURCES += \
test/colorspace/x86/colorspace_avx512_test.cpp \
test/colorspace/x86/gamma_constants_avx512_test.cpp \
test/depth/x86/depth_convert_avx512_test.cpp \
test/depth/x86/dither_avx512_test.cpp \
test/resize/x86/resize_impl_avx512_test.cpp \
test/resize/x86/resize_impl_avx512_vnni_test.cpp
endif # X86SIMD_AVX512

test/extra/googletest/build/lib/libgtest.a: .FAKE
-$(MAKE) -C test/extra/googletest/build gtest

Expand All @@ -442,6 +431,7 @@ test_unit_test_LDADD = \
libzimg_internal.la
endif # UNIT_TEST


clean-local:
-cd test/extra/googletest/build && make clean

Expand Down
8 changes: 4 additions & 4 deletions _msvc/unit_test/unit_test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\zimg;$(ProjectDir)..\..\graphengine\include;$(ProjectDir)..\..\test;$(ProjectDir)..\..\test\extra;$(ProjectDir)..\..\test\extra\googletest\googletest\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;ZIMG_X86_AVX512;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<FloatingPointModel>Strict</FloatingPointModel>
Expand Down Expand Up @@ -300,7 +300,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\zimg;$(ProjectDir)..\..\graphengine\include;$(ProjectDir)..\..\test;$(ProjectDir)..\..\test\extra;$(ProjectDir)..\..\test\extra\googletest\googletest\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;ZIMG_X86_AVX512;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<LanguageStandard>stdcpp17</LanguageStandard>
Expand Down Expand Up @@ -334,7 +334,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\zimg;$(ProjectDir)..\..\graphengine\include;$(ProjectDir)..\..\test;$(ProjectDir)..\..\test\extra;$(ProjectDir)..\..\test\extra\googletest\googletest\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;ZIMG_X86_AVX512;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<FloatingPointModel>Strict</FloatingPointModel>
<LanguageStandard>stdcpp17</LanguageStandard>
Expand Down Expand Up @@ -373,7 +373,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\zimg;$(ProjectDir)..\..\graphengine\include;$(ProjectDir)..\..\test;$(ProjectDir)..\..\test\extra;$(ProjectDir)..\..\test\extra\googletest\googletest\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;ZIMG_X86_AVX512;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand Down
8 changes: 4 additions & 4 deletions _msvc/zimg/zimg.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\zimg;$(ProjectDir)..\..\graphengine\include</AdditionalIncludeDirectories>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<PreprocessorDefinitions>ZIMG_GRAPHENGINE_API;GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;ZIMG_X86_AVX512;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>ZIMG_GRAPHENGINE_API;GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
Expand Down Expand Up @@ -202,7 +202,7 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\zimg;$(ProjectDir)..\..\graphengine\include</AdditionalIncludeDirectories>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<PreprocessorDefinitions>ZIMG_GRAPHENGINE_API;GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;ZIMG_X86_AVX512;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>ZIMG_GRAPHENGINE_API;GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
Expand All @@ -220,7 +220,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\zimg;$(ProjectDir)..\..\graphengine\include</AdditionalIncludeDirectories>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<PreprocessorDefinitions>ZIMG_GRAPHENGINE_API;GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;ZIMG_X86_AVX512;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>ZIMG_GRAPHENGINE_API;GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BufferSecurityCheck>false</BufferSecurityCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<FloatingPointModel>Strict</FloatingPointModel>
Expand Down Expand Up @@ -278,7 +278,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\src\zimg;$(ProjectDir)..\..\graphengine\include</AdditionalIncludeDirectories>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<PreprocessorDefinitions>ZIMG_GRAPHENGINE_API;GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;ZIMG_X86_AVX512;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>ZIMG_GRAPHENGINE_API;GRAPHENGINE_IMPL_NAMESPACE=zimg;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ZIMG_X86;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BufferSecurityCheck>false</BufferSecurityCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
Expand Down
19 changes: 0 additions & 19 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,6 @@ AS_IF([test "x$X86" = "xyes" && test "x$enable_simd" != "xno"],
AX_CHECK_COMPILE_FLAG([-mtune=haswell], AC_SUBST([HSW_CFLAGS], [-mtune=haswell]))
AX_CHECK_COMPILE_FLAG([-mtune=skylake-avx512], AC_SUBST([SKX_CFLAGS], [-mtune=skylake-avx512]))
AX_CHECK_COMPILE_FLAG([-mtune=cascadelake], AC_SUBST([CLX_CFLAGS], [-mtune=cascadelake]))
AX_CHECK_COMPILE_FLAG(
[-mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -mavx512vbmi2 -mavx512bitalg -mavx512vpopcntdq -mavx512vnni],
[
AC_DEFINE([ZIMG_X86_AVX512])
enable_x86_simd_avx512=yes
], [], [],
[AC_LANG_SOURCE([
#include <immintrin.h>
int main()
{
volatile __m512 x = _mm512_setzero_ps();
x = _mm512_add_ps(x, x);
#if defined(__GNUC__) && defined(__x86_64__)
asm volatile ("" : : : "zmm16", "zmm17", "zmm18", "zmm19");
#endif
return 0;
}
])])
])


Expand Down
4 changes: 0 additions & 4 deletions src/zimg/colorspace/x86/gamma_constants_avx512.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef ZIMG_X86_AVX512

#include <algorithm>
#include <cfloat>
#include <cmath>
Expand Down Expand Up @@ -317,5 +315,3 @@ float st_2084_inverse_eotf(float x)

} // namespace avx512constants
} // namespace zimg::colorspace

#endif // ZIMG_X86_AVX512
4 changes: 0 additions & 4 deletions src/zimg/colorspace/x86/gamma_constants_avx512.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#ifdef ZIMG_X86_AVX512

#ifndef ZIMG_COLORSPACE_X86_GAMMA_CONSTANTS_H_
#define ZIMG_COLORSPACE_X86_GAMMA_CONSTANTS_H_

Expand Down Expand Up @@ -76,5 +74,3 @@ float st_2084_inverse_eotf(float x);
} // namespace zimg::colorspace

#endif // ZIMG_COLORSPACE_X86_GAMMA_CONSTANTS_H_

#endif // ZIMG_X86_AVX512
4 changes: 0 additions & 4 deletions src/zimg/colorspace/x86/operation_impl_avx512.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef ZIMG_X86_AVX512

#include <cfloat>
#include <immintrin.h>
#include "common/align.h"
Expand Down Expand Up @@ -351,5 +349,3 @@ std::unique_ptr<Operation> create_inverse_gamma_operation_avx512(const TransferF
}

} // namespace zimg::colorspace

#endif // ZIMG_X86_AVX512
12 changes: 0 additions & 12 deletions src/zimg/colorspace/x86/operation_impl_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ std::unique_ptr<Operation> create_matrix_operation_x86(const Matrix3x3 &m, CPUCl
std::unique_ptr<Operation> ret;

if (cpu_is_autodetect(cpu)) {
#ifdef ZIMG_X86_AVX512
if (!ret && cpu == CPUClass::AUTO_64B && caps.avx512f)
ret = create_matrix_operation_avx512(m);
#endif
if (!ret && caps.avx && !cpu_has_slow_avx(caps))
ret = create_matrix_operation_avx(m);
if (!ret && caps.sse)
ret = create_matrix_operation_sse(m);
} else {
#ifdef ZIMG_X86_AVX512
if (!ret && cpu >= CPUClass::X86_AVX512)
ret = create_matrix_operation_avx512(m);
#endif
if (!ret && cpu >= CPUClass::X86_AVX)
ret = create_matrix_operation_avx(m);
if (!ret && cpu >= CPUClass::X86_SSE)
Expand All @@ -42,19 +38,15 @@ std::unique_ptr<Operation> create_gamma_operation_x86(const TransferFunction &tr
std::unique_ptr<Operation> ret;

if (cpu_is_autodetect(cpu)) {
#ifdef ZIMG_X86_AVX512
if (!ret && cpu == CPUClass::AUTO_64B && caps.avx512f && caps.avx512bw && caps.avx512dq)
ret = create_gamma_operation_avx512(transfer, params);
#endif
if (!ret && caps.avx2 && !cpu_has_slow_gather(caps))
ret = create_gamma_operation_avx2(transfer, params);
if (!ret && caps.sse2)
ret = create_gamma_operation_sse2(transfer, params);
} else {
#ifdef ZIMG_X86_AVX512
if (!ret && cpu >= CPUClass::X86_AVX512)
ret = create_gamma_operation_avx512(transfer, params);
#endif
if (!ret && cpu >= CPUClass::X86_AVX2)
ret = create_gamma_operation_avx2(transfer, params);
if (!ret && cpu >= CPUClass::X86_SSE2)
Expand All @@ -70,19 +62,15 @@ std::unique_ptr<Operation> create_inverse_gamma_operation_x86(const TransferFunc
std::unique_ptr<Operation> ret;

if (cpu_is_autodetect(cpu)) {
#ifdef ZIMG_X86_AVX512
if (!ret && cpu == CPUClass::AUTO_64B && caps.avx512f && caps.avx512bw && caps.avx512dq)
ret = create_inverse_gamma_operation_avx512(transfer, params);
#endif
if (!ret && caps.avx2 && !cpu_has_slow_gather(caps))
ret = create_inverse_gamma_operation_avx2(transfer, params);
if (!ret && caps.sse2)
ret = create_inverse_gamma_operation_sse2(transfer, params);
} else {
#ifdef ZIMG_X86_AVX512
if (!ret && cpu >= CPUClass::X86_AVX512)
ret = create_inverse_gamma_operation_avx512(transfer, params);
#endif
if (!ret && cpu >= CPUClass::X86_AVX2)
ret = create_inverse_gamma_operation_avx2(transfer, params);
if (!ret && cpu >= CPUClass::X86_SSE2)
Expand Down
4 changes: 0 additions & 4 deletions src/zimg/common/x86/avx512_util.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#ifdef ZIMG_X86_AVX512

#ifndef ZIMG_X86_AVX512_UTIL_H_
#define ZIMG_X86_AVX512_UTIL_H_

Expand Down Expand Up @@ -178,5 +176,3 @@ static inline FORCE_INLINE void mm512_transpose32_epi16(
} // namespace zimg

#endif // ZIMG_X86_AVX512_UTIL_H_

#endif // ZIMG_X86_AVX512
4 changes: 0 additions & 4 deletions src/zimg/depth/x86/depth_convert_avx512.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef ZIMG_X86_AVX512

#include <cstdint>
#include <immintrin.h>
#include "common/align.h"
Expand Down Expand Up @@ -188,5 +186,3 @@ void depth_convert_w2f_avx512(const void *src, void *dst, float scale, float off
}

} // namespace zimg::depth

#endif // ZIMG_X86_AVX512
12 changes: 0 additions & 12 deletions src/zimg/depth/x86/depth_convert_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ left_shift_func select_left_shift_func_avx2(PixelType pixel_in, PixelType pixel_
return nullptr;
}

#ifdef ZIMG_X86_AVX512
left_shift_func select_left_shift_func_avx512(PixelType pixel_in, PixelType pixel_out)
{
if (pixel_in == PixelType::BYTE && pixel_out == PixelType::BYTE)
Expand All @@ -52,7 +51,6 @@ left_shift_func select_left_shift_func_avx512(PixelType pixel_in, PixelType pixe
else
return nullptr;
}
#endif

depth_convert_func select_depth_convert_func_sse2(PixelType pixel_in, PixelType pixel_out)
{
Expand Down Expand Up @@ -81,7 +79,6 @@ depth_convert_func select_depth_convert_func_avx2(PixelType pixel_in, PixelType
return nullptr;
}

#ifdef ZIMG_X86_AVX512
depth_convert_func select_depth_convert_func_avx512(PixelType pixel_in, PixelType pixel_out)
{
if (pixel_in == PixelType::BYTE && pixel_out == PixelType::HALF)
Expand All @@ -95,7 +92,6 @@ depth_convert_func select_depth_convert_func_avx512(PixelType pixel_in, PixelTyp
else
return nullptr;
}
#endif // ZIMG_X86_AVX512

} // namespace

Expand All @@ -106,19 +102,15 @@ left_shift_func select_left_shift_func_x86(PixelType pixel_in, PixelType pixel_o
left_shift_func func = nullptr;

if (cpu_is_autodetect(cpu)) {
#ifdef ZIMG_X86_AVX512
if (!func && cpu == CPUClass::AUTO_64B && caps.avx512f && caps.avx512bw && caps.avx512vl)
func = select_left_shift_func_avx512(pixel_in, pixel_out);
#endif
if (!func && caps.avx2)
func = select_left_shift_func_avx2(pixel_in, pixel_out);
if (!func && caps.sse2)
func = select_left_shift_func_sse2(pixel_in, pixel_out);
} else {
#ifdef ZIMG_X86_AVX512
if (!func && cpu >= CPUClass::X86_AVX512)
func = select_left_shift_func_avx512(pixel_in, pixel_out);
#endif
if (!func && cpu >= CPUClass::X86_AVX2)
func = select_left_shift_func_avx2(pixel_in, pixel_out);
if (!func && cpu >= CPUClass::X86_SSE2)
Expand All @@ -134,19 +126,15 @@ depth_convert_func select_depth_convert_func_x86(const PixelFormat &pixel_in, co
depth_convert_func func = nullptr;

if (cpu_is_autodetect(cpu)) {
#ifdef ZIMG_X86_AVX512
if (!func && cpu == CPUClass::AUTO_64B && caps.avx512f && caps.avx512bw && caps.avx512vl)
func = select_depth_convert_func_avx512(pixel_in.type, pixel_out.type);
#endif
if (!func && caps.avx2 && caps.fma)
func = select_depth_convert_func_avx2(pixel_in.type, pixel_out.type);
if (!func && caps.sse2)
func = select_depth_convert_func_sse2(pixel_in.type, pixel_out.type);
} else {
#ifdef ZIMG_X86_AVX512
if (!func && cpu >= CPUClass::X86_AVX512)
func = select_depth_convert_func_avx512(pixel_in.type, pixel_out.type);
#endif
if (!func && cpu >= CPUClass::X86_AVX2)
func = select_depth_convert_func_avx2(pixel_in.type, pixel_out.type);
if (!func && cpu >= CPUClass::X86_SSE2)
Expand Down
Loading

0 comments on commit 017c814

Please sign in to comment.