fix x86_linux run time

This commit is contained in:
gongdaguo 2021-07-08 14:54:06 +08:00
parent ccc7293780
commit b9434c3255
4 changed files with 30 additions and 9 deletions

View File

@ -26,6 +26,13 @@ if(PLATFORM_ARM32 OR PLATFORM_ARM64)
-fdata-sections -ffast-math -fno-rtti -fno-exceptions -Wno-shorten-64-to-32 \
-fno-aligned-allocation -DTARGET_OS_OSX")
endif()
else()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -fstrict-aliasing -ffunction-sections \
-fdata-sections -ffast-math -fno-rtti -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -fstrict-aliasing -ffunction-sections \
-fdata-sections -ffast-math -fno-rtti -fno-exceptions")
endif()
endif()
if(TARGET_HIMIX200)

View File

@ -7,6 +7,7 @@ file(GLOB KERNEL_SRC
${CMAKE_CURRENT_SOURCE_DIR}/string/*.cc
)
list(REMOVE_ITEM KERNEL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/int8/opt_op_handler.cc)
list(REMOVE_ITEM KERNEL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/base/random_standard_normal.cc)
if(SUPPORT_TRAIN)
file(GLOB TRAIN_KERNEL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/fp16_grad/*.cc)
@ -16,7 +17,6 @@ endif()
add_library(cpu_kernel_mid OBJECT ${KERNEL_SRC})
add_dependencies(cpu_kernel_mid fbs_src)
if(PLATFORM_ARM)
if(ENABLE_FP16)
file(GLOB FP16_KERNEL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/fp16/*.cc)
@ -31,3 +31,11 @@ if(PLATFORM_ARM)
add_library(cpu_opt_kernel_mid OBJECT ${OPT_KERNEL_SRC})
add_dependencies(cpu_kernel_mid fbs_src)
endif()
add_library(cpu_kernel_random_standard_normal OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/base/random_standard_normal.cc)
add_dependencies(cpu_kernel_random_standard_normal fbs_src)
target_link_libraries(cpu_kernel_mid cpu_kernel_random_standard_normal)
if((NOT PLATFORM_ARM AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release") OR TARGET_HIMIX200)
target_compile_options(cpu_kernel_random_standard_normal PRIVATE -Wno-error=maybe-uninitialized)
endif()

View File

@ -30,6 +30,14 @@ file(GLOB KERNEL_OP_SRC
${LITE_DIR}/src/runtime/kernel/arm/int8/*.cc
${LITE_DIR}/src/runtime/kernel/arm/string/*.cc
)
list(REMOVE_ITEM KERNEL_OP_SRC ${LITE_DIR}/src/runtime/kernel/arm/base/random_standard_normal.cc)
if(NOT PLATFORM_ARM AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -fstrict-aliasing -ffunction-sections \
-fdata-sections -ffast-math")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -fstrict-aliasing -ffunction-sections \
-fdata-sections -ffast-math")
endif()
file(GLOB KERNEL_OP_TRAIN_SRC
${LITE_DIR}/src/runtime/kernel/arm/fp32_grad/*.cc
@ -372,7 +380,12 @@ if(SUPPORT_TRAIN)
add_dependencies(lite-test fbs_inner_src)
endif()
target_link_libraries(lite-test nnacl_mid dl mindspore::gtest)
target_link_libraries(lite-test
nnacl_mid
dl
mindspore::gtest
cpu_kernel_random_standard_normal
)
if(PLATFORM_ARM AND ENABLE_FP16)
target_link_libraries(lite-test nnacl_fp16_mid)

View File

@ -4,13 +4,6 @@ set(COMMON_SRC
${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/file_utils.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../src/common/utils.cc
)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
string(REPLACE "-O3" "-Ofast" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-O3" "-Ofast" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-O2" "-Ofast" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-O2" "-Ofast" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_BUILD_TYPE Default)
endif()
if(NOT TARGET_HIMIX200)
add_executable(benchmark
${CMAKE_CURRENT_SOURCE_DIR}/main.cc