Skip to content

Commit

Permalink
Update SKCMS (#4021)
Browse files Browse the repository at this point in the history
It's structure has been changed - avx2 / avx512 specializations have been factored out

(cherry picked from commit d830431275a706d618f7f6d24d5c305f653f9a3e)
  • Loading branch information
eustas committed Dec 27, 2024
1 parent 06f3516 commit c814917
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fsanitize=fuzzer-no-link" CXX_FUZZERS_SUPPORTED)
check_cxx_compiler_flag("-fmacro-prefix-map=OLD=NEW" CXX_MACRO_PREFIX_MAP)
check_cxx_compiler_flag("-fno-rtti" CXX_NO_RTTI_SUPPORTED)
check_cxx_compiler_flag("-mavx2" CXX_MAVX2_SUPPORTED)
check_cxx_compiler_flag("-mf16c" CXX_MF16C_SUPPORTED)
check_cxx_compiler_flag("-mavx512f" CXX_MAVX512F_SUPPORTED)
check_cxx_compiler_flag("-mavx512dq" CXX_MAVX512DQ_SUPPORTED)
check_cxx_compiler_flag("-mavx512cd" CXX_MAVX512CD_SUPPORTED)
check_cxx_compiler_flag("-mavx512bw" CXX_MAVX512BW_SUPPORTED)
check_cxx_compiler_flag("-mavx512vl" CXX_MAVX512VL_SUPPORTED)

# Add "DebugOpt" CMake build type. Unlike builtin DEBUG it is optimized.
string(REGEX REPLACE "-DNDEBUG " "" CMAKE_CXX_FLAGS_DEBUGOPT "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDEBUG" )
Expand Down
2 changes: 1 addition & 1 deletion deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MYDIR=$(dirname "${SELF}")
TESTDATA="873045a9c42ed60721756e26e2a6b32e17415205"
THIRD_PARTY_GOOGLETEST="58d77fa8070e8cec2dc1ed015d66b454c8d78850"
THIRD_PARTY_HIGHWAY="457c891775a7397bdb0376bb1031e6e027af1c48" # v1.2.0
THIRD_PARTY_SKCMS="42030a771244ba67f86b1c1c76a6493f873c5f91"
THIRD_PARTY_SKCMS="b2e692629c1fb19342517d7fb61f1cf83d075492"
THIRD_PARTY_SJPEG="e5ab13008bb214deb66d5f3e17ca2f8dbff150bf"
THIRD_PARTY_ZLIB="51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf" # v1.3.1
THIRD_PARTY_LIBPNG="f135775ad4e5d4408d2e12ffcc71bb36e6b48551" # v1.6.40
Expand Down
2 changes: 1 addition & 1 deletion third_party/skcms
Submodule skcms updated from 42030a to b2e692
37 changes: 35 additions & 2 deletions third_party/skcms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,46 @@
# limitations under the License.

function(target_link_skcms TARGET_NAME)
target_sources(${TARGET_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/third_party/skcms/skcms.cc")
set(_sources_dir "${PROJECT_SOURCE_DIR}/third_party/skcms")
set(_sources
"${_sources_dir}/skcms.cc"
"${_sources_dir}/src/skcms_TransformBaseline.cc"
)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(_use_avx2 ${CXX_MAVX2_SUPPORTED} AND ${CXX_MF16C_SUPPORTED})
set(_use_avx512 ${CXX_MAVX512F_SUPPORTED} AND ${CXX_MAVX512DQ_SUPPORTED} AND ${CXX_MAVX512CD_SUPPORTED} AND ${CXX_MAVX512BW_SUPPORTED} AND ${CXX_MAVX512VL_SUPPORTED})
else()
set(_use_avx2 0)
set(_use_avx512 0)
endif()

if(${_use_avx2})
list(APPEND _sources "${_sources_dir}/src/skcms_TransformHsw.cc")
set_source_files_properties("${_sources_dir}/src/skcms_TransformHsw.cc"
PROPERTIES COMPILE_OPTIONS "-march=x86-64;-mavx2;-mf16c"
TARGET_DIRECTORY ${TARGET_NAME}
)
else()
target_compile_definitions(${TARGET_NAME} PRIVATE -DSKCMS_DISABLE_HSW)
endif()
if(${_use_avx512})
list(APPEND _sources "${_sources_dir}/src/skcms_TransformSkx.cc")
set_source_files_properties("${_sources_dir}/src/skcms_TransformSkx.cc"
PROPERTIES COMPILE_OPTIONS "-march=x86-64;-mavx512f;-mavx512dq;-mavx512cd;-mavx512bw;-mavx512vl"
TARGET_DIRECTORY ${TARGET_NAME}
)
else()
target_compile_definitions(${TARGET_NAME} PRIVATE -DSKCMS_DISABLE_SKX)
endif()

target_sources(${TARGET_NAME} PRIVATE "${_sources}")
target_include_directories(${TARGET_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/third_party/skcms/")

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wno-psabi" CXX_WPSABI_SUPPORTED)
if(CXX_WPSABI_SUPPORTED)
set_source_files_properties("${PROJECT_SOURCE_DIR}/third_party/skcms/skcms.cc"
set_source_files_properties("${_sources}"
PROPERTIES COMPILE_OPTIONS "-Wno-psabi"
TARGET_DIRECTORY ${TARGET_NAME})
endif()
Expand Down

0 comments on commit c814917

Please sign in to comment.