add x86_64 sse optimize

pull/8155/head
liuzhongkai 4 years ago
parent bbfef6233a
commit e4fa3c5b85

@ -26,7 +26,7 @@ usage()
echo " [-a on|off] [-p on|off] [-i] [-L] [-R] [-D on|off] [-j[n]] [-e gpu|d|cpu] \\" echo " [-a on|off] [-p on|off] [-i] [-L] [-R] [-D on|off] [-j[n]] [-e gpu|d|cpu] \\"
echo " [-P on|off] [-z [on|off]] [-M on|off] [-V 9.2|10.1] [-I arm64|arm32|x86_64] [-K] \\" echo " [-P on|off] [-z [on|off]] [-M on|off] [-V 9.2|10.1] [-I arm64|arm32|x86_64] [-K] \\"
echo " [-B on|off] [-w on|off] [-E] [-l on|off] [-n full|lite|off] [-T on|off] \\" echo " [-B on|off] [-w on|off] [-E] [-l on|off] [-n full|lite|off] [-T on|off] \\"
echo " [-A [cpp|java|object-c] [-C on|off] [-o on|off] [-S on|off] [-k on|off] \\" echo " [-A [cpp|java|object-c] [-C on|off] [-o on|off] [-S on|off] [-k on|off] [-W sse|neon|avx|off] \\"
echo "" echo ""
echo "Options:" echo "Options:"
echo " -d Debug mode" echo " -d Debug mode"
@ -65,6 +65,7 @@ usage()
echo " -o Enable mindspore lite tools compilation, enabled when -I is specified, default on" echo " -o Enable mindspore lite tools compilation, enabled when -I is specified, default on"
echo " -S Enable enable download cmake compile dependency from gitee , default off" echo " -S Enable enable download cmake compile dependency from gitee , default off"
echo " -k Enable make clean, clean up compilation generated cache " echo " -k Enable make clean, clean up compilation generated cache "
echo " -W Enable x86_64 SSE or AVX instruction set, use [sse|avx|neon|off], default off"
} }
# check value of input is 'on' or 'off' # check value of input is 'on' or 'off'
@ -118,9 +119,10 @@ checkopts()
ENABLE_GITEE="off" ENABLE_GITEE="off"
ANDROID_STL="c++_shared" ANDROID_STL="c++_shared"
ENABLE_MAKE_CLEAN="off" ENABLE_MAKE_CLEAN="off"
X86_64_SIMD="off"
# Process the options # Process the options
while getopts 'drvj:c:t:hsb:a:g:p:ie:m:l:I:LRP:D:zM:V:K:swB:En:T:A:C:o:S:k:' opt while getopts 'drvj:c:t:hsb:a:g:p:ie:m:l:I:LRP:D:zM:V:K:swB:En:T:A:C:o:S:k:W:' opt
do do
OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]') OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
case "${opt}" in case "${opt}" in
@ -341,6 +343,16 @@ checkopts()
check_on_off $OPTARG o check_on_off $OPTARG o
ENABLE_TOOLS="$OPTARG" ENABLE_TOOLS="$OPTARG"
;; ;;
W)
if [[ "$OPTARG" != "sse" && "$OPTARG" != "off" && "$OPTARG" != "avx" && "$OPTARG" != "neon" ]]; then
echo "Invalid value ${OPTARG} for option -W, -W parameter must be sse|neon|avx|off"
usage
exit 1
fi
if [[ "$OPTARG" == "sse" || "$OPTARG" == "avx" ]]; then
X86_64_SIMD="$OPTARG"
fi
;;
*) *)
echo "Unknown option ${opt}!" echo "Unknown option ${opt}!"
usage usage
@ -702,7 +714,7 @@ build_lite()
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_GPU=${ENABLE_GPU} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_GPU=${ENABLE_GPU} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp \ -DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp \
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \ -DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
-DENABLE_VERBOSE=${ENABLE_VERBOSE} "${BASEPATH}/mindspore/lite" -DENABLE_VERBOSE=${ENABLE_VERBOSE} -DX86_64_SIMD=${X86_64_SIMD} "${BASEPATH}/mindspore/lite"
fi fi
make -j$THREAD_NUM && make install && make package make -j$THREAD_NUM && make install && make package
COMPILE_RET=$? COMPILE_RET=$?

@ -20,6 +20,7 @@ option(SUPPORT_GPU "if support gpu" off)
option(OFFLINE_COMPILE "if offline compile OpenCL kernel" off) option(OFFLINE_COMPILE "if offline compile OpenCL kernel" off)
option(BUILD_MINDDATA_EXAMPLE "" on) option(BUILD_MINDDATA_EXAMPLE "" on)
option(ENABLE_VERBOSE "" off) option(ENABLE_VERBOSE "" off)
option(ENABLE_X86_64_SSE "if x86_64 support SSE instruction set" off)
set(DIR_PREFIX mindspore-lite) set(DIR_PREFIX mindspore-lite)
set(MS_VERSION ${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION}) set(MS_VERSION ${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION})
@ -174,6 +175,12 @@ if (PLATFORM_ARM32 OR PLATFORM_ARM64)
endif() endif()
endif() endif()
if (NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64)
if ("${X86_64_SIMD}" STREQUAL "sse")
add_compile_definitions(ENABLE_X86_64_SSE)
endif ()
endif ()
if (BUILD_MINDDATA STREQUAL "lite" OR BUILD_MINDDATA STREQUAL "full") if (BUILD_MINDDATA STREQUAL "lite" OR BUILD_MINDDATA STREQUAL "full")
# add sentencepiece dependency # add sentencepiece dependency
# include(${TOP_DIR}/cmake/external_libs/sentencepiece.cmake) # include(${TOP_DIR}/cmake/external_libs/sentencepiece.cmake)

@ -32,6 +32,11 @@ if (PLATFORM_ARM32)
set_property(SOURCE ${ASSEMBLY_SRC} PROPERTY LANGUAGE C) set_property(SOURCE ${ASSEMBLY_SRC} PROPERTY LANGUAGE C)
endif() endif()
if ("${X86_64_SIMD}" STREQUAL "sse")
file(GLOB ASSEMBLY_SRC ${NNACL_DIR}/x86_64_sse/*.c)
set_property(SOURCE ${ASSEMBLY_SRC} PROPERTY LANGUAGE C)
endif()
########################### build nnacl static library ######################## ########################### build nnacl static library ########################
string(REPLACE "-fvisibility=hidden" "-fvisibility=default" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REPLACE "-fvisibility=hidden" "-fvisibility=default" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
add_library(nnacl STATIC ${KERNEL_SRC} ${TRAIN_SRC} ${ASSEMBLY_SRC}) add_library(nnacl STATIC ${KERNEL_SRC} ${TRAIN_SRC} ${ASSEMBLY_SRC})

@ -121,7 +121,7 @@ int B(const float *poly_array, float *matrix_b, int in_unit) {
return NNACL_OK; return NNACL_OK;
} }
#ifndef ENABLE_ARM #if !defined(ENABLE_ARM) && !defined(ENABLE_X86_64_SSE)
void MatrixMultiplyWinograd(const float *matix_a, const float *matrix_b, float *matrix_c, int m, int k, int n, void MatrixMultiplyWinograd(const float *matix_a, const float *matrix_b, float *matrix_c, int m, int k, int n,
int in_channel, int c4_channel) { int in_channel, int c4_channel) {
int cnt = 0; int cnt = 0;

File diff suppressed because it is too large Load Diff

@ -76,6 +76,16 @@ if (ENABLE_FP16)
${KERNEL_OP_FP16_SRC} ${KERNEL_OP_FP16_SRC}
) )
endif () endif ()
if ("${X86_64_SIMD}" STREQUAL "sse")
file(GLOB TEST_ASSEMBLY_SRC ${LITE_DIR}/nnacl/x86_64_sse/*.c)
set_property(SOURCE ${TEST_ASSEMBLY_SRC} PROPERTY LANGUAGE C)
set(KERNEL_OP_SRC
${KERNEL_OP_SRC}
${TEST_ASSEMBLY_SRC}
)
endif()
### gpu kernel ### gpu kernel
if (SUPPORT_GPU) if (SUPPORT_GPU)
file(GLOB GPU_KERNEL_OP_SRC file(GLOB GPU_KERNEL_OP_SRC

Loading…
Cancel
Save