Skip to content

Commit

Permalink
perf(*): change multiversioning target clones to x86-64-v3 and x86-64-v4
Browse files Browse the repository at this point in the history
Signed-off-by: k4yt3x <[email protected]>
  • Loading branch information
k4yt3x committed Dec 30, 2024
1 parent 7665cd2 commit a72c094
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(video2x VERSION 6.3.1 LANGUAGES CXX)

# The FindBoost module is removed in CMake 3.30
Expand Down Expand Up @@ -346,10 +346,10 @@ target_include_directories(libvideo2x PRIVATE
)

# Set the compile options for the shared library
if(MSVC)
target_compile_options(libvideo2x PRIVATE $<$<CONFIG:Debug>:/Zi /DDEBUG>)
else()
target_compile_options(libvideo2x PRIVATE -fPIC $<$<CONFIG:Debug>:-g -DDEBUG>)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(libvideo2x PRIVATE $<$<CONFIG:Debug>:/Zi /Od /MDd>)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(libvideo2x PRIVATE -fPIC $<$<CONFIG:Debug>:-g -O0>)
endif()

# Define the paths to the shared libraries
Expand Down
2 changes: 1 addition & 1 deletion src/avutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ AVPixelFormat get_encoder_default_pix_fmt(const AVCodec *encoder, AVPixelFormat
return best_pix_fmt;
}

[[gnu::target_clones("default", "avx2", "avx512f")]]
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
float get_frame_diff(AVFrame *frame1, AVFrame *frame2) {
if (!frame1 || !frame2) {
logger()->error("Invalid frame(s) provided for comparison");
Expand Down
6 changes: 3 additions & 3 deletions src/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace video2x {
namespace conversions {

// Convert AVFrame format
[[gnu::target_clones("default", "avx2", "avx512f")]]
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
AVFrame *convert_avframe_pix_fmt(AVFrame *src_frame, AVPixelFormat pix_fmt) {
AVFrame *dst_frame = av_frame_alloc();
if (dst_frame == nullptr) {
Expand Down Expand Up @@ -68,7 +68,7 @@ AVFrame *convert_avframe_pix_fmt(AVFrame *src_frame, AVPixelFormat pix_fmt) {
}

// Convert AVFrame to ncnn::Mat by copying the data
[[gnu::target_clones("default", "avx2", "avx512f")]]
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
ncnn::Mat avframe_to_ncnn_mat(AVFrame *frame) {
AVFrame *converted_frame = nullptr;

Expand Down Expand Up @@ -108,7 +108,7 @@ ncnn::Mat avframe_to_ncnn_mat(AVFrame *frame) {
}

// Convert ncnn::Mat to AVFrame with a specified pixel format (this part is unchanged)
[[gnu::target_clones("default", "avx2", "avx512f")]]
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
AVFrame *ncnn_mat_to_avframe(const ncnn::Mat &mat, AVPixelFormat pix_fmt) {
int ret;

Expand Down
4 changes: 2 additions & 2 deletions src/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ int Encoder::init(
return 0;
}

[[gnu::target_clones("default", "avx2", "avx512f")]]
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) {
AVFrame *converted_frame = nullptr;
int ret;
Expand Down Expand Up @@ -326,7 +326,7 @@ int Encoder::write_frame(AVFrame *frame, int64_t frame_idx) {
return 0;
}

[[gnu::target_clones("default", "avx2", "avx512f")]]
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
int Encoder::flush() {
int ret;
AVPacket *enc_pkt = av_packet_alloc();
Expand Down
2 changes: 1 addition & 1 deletion src/libvideo2x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ VideoProcessor::VideoProcessor(
hw_device_type_(hw_device_type),
benchmark_(benchmark) {}

[[gnu::target_clones("default", "avx2", "avx512f")]]
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
int VideoProcessor::process(
const std::filesystem::path in_fname,
const std::filesystem::path out_fname
Expand Down

0 comments on commit a72c094

Please sign in to comment.