From f6d8d28883755d4ded224207b634a08367ee006f Mon Sep 17 00:00:00 2001 From: mtklein Date: Thu, 17 Dec 2015 10:18:04 -0800 Subject: [PATCH] update CMake and Google3 builds for AVX/AVX2 The _avx.cpp code was working in a degraded (SSE2/SSSE3) mode silently. This CL will make the _avx.cpp code start using AVX. There is currently no _avx2.cpp code, but I'm writing some now, and this change will make it work properly from the start. Chrome and Android builds should already be okay. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1535443003 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac10.9-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1535443003 --- BUILD.public | 36 ++++++++++++++++++++++++++++++++++++ cmake/CMakeLists.txt | 6 +++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/BUILD.public b/BUILD.public index d20eb235ee..b184f726f1 100644 --- a/BUILD.public +++ b/BUILD.public @@ -84,6 +84,8 @@ BASE_SRCS_UNIX = glob( # Included in :opts_sse4 library. "src/opts/*SSE4*", "src/opts/*sse4*", + # Included in :opts_avx or :opts_avx2 + "src/opts/*avx*", "src/opts/SkBitmapProcState_opts_none.cpp", "src/opts/SkBlitMask_opts_none.cpp", "src/opts/SkBlitRow_opts_none.cpp", @@ -123,6 +125,7 @@ BASE_SRCS_ANDROID = glob( "src/opts/*ssse3*", "src/opts/*SSE4*", "src/opts/*sse4*", + "src/opts/*avx*", "src/opts/*x86*", "src/opts/SkBitmapProcState_opts_none.cpp", "src/opts/SkBlitMask_opts_none.cpp", @@ -165,6 +168,7 @@ BASE_SRCS_IOS = glob( "src/opts/*ssse3*", "src/opts/*SSE4*", "src/opts/*sse4*", + "src/opts/*avx*", "src/opts/*x86*", "src/opts/SkBitmapProcState_opts_none.cpp", "src/opts/SkBlitMask_opts_none.cpp", @@ -212,6 +216,18 @@ SSE4_SRCS = glob( ], ) +AVX_SRCS = glob( + [ + "src/opts/*_avx.cpp", + ], +) + +AVX2_SRCS = glob( + [ + "src/opts/*_avx2.cpp", + ], +) + BASE_HDRS = glob( [ "include/**/*.h", @@ -229,6 +245,8 @@ BASE_HDRS = glob( # Dependencies. BASE_DEPS_UNIX = [ + ":opts_avx2", + ":opts_avx", ":opts_sse4", ":opts_ssse3", ] @@ -424,6 +442,24 @@ cc_library( deps = EXTERNAL_DEPS_ALL, ) +cc_library( + name = "opts_avx", + srcs = AVX_SRCS, + copts = COPTS + ["-mavx"], + defines = DEFINES, + includes = INCLUDES, + deps = EXTERNAL_DEPS_ALL, +) + +cc_library( + name = "opts_avx2", + srcs = AVX2_SRCS, + copts = COPTS + ["-mavx2"], + defines = DEFINES, + includes = INCLUDES, + deps = EXTERNAL_DEPS_ALL, +) + # If you need Ganesh (GPU) support in Skia, please contact skia-team@google.com # for help. cc_library( diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2de051b3fc..fcbce4ff5c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -114,11 +114,15 @@ endif() remove_srcs(../src/gpu/gl/angle/*) # TODO remove_srcs(../src/codec/* ../src/android/*) # TODO: Requires Chromium's libjpeg-turbo, and incompatible giflib. -# Certain files must be compiled with support for SSSE3 or SSE4.1 intrinsics. +# Certain files must be compiled with support for SSSE3, SSE4.1, AVX, or AVX2 intrinsics. file (GLOB_RECURSE ssse3_srcs ../src/*ssse3*.cpp ../src/*SSSE3*.cpp) file (GLOB_RECURSE sse41_srcs ../src/*sse4*.cpp ../src/*SSE4*.cpp) +file (GLOB_RECURSE avx_srcs ../src/*_avx.cpp) +file (GLOB_RECURSE avx2_srcs ../src/*_avx2.cpp) set_source_files_properties(${ssse3_srcs} PROPERTIES COMPILE_FLAGS -mssse3) set_source_files_properties(${sse41_srcs} PROPERTIES COMPILE_FLAGS -msse4.1) +set_source_files_properties(${avx_srcs} PROPERTIES COMPILE_FLAGS -mavx) +set_source_files_properties(${avx2_srcs} PROPERTIES COMPILE_FLAGS -mavx2) # Detect our optional dependencies. # If we can't find them, don't build the parts of Skia that use them.