2020-03-27 14:49:12 +08:00
|
|
|
option(ENABLE_D "Enable d" OFF)
|
|
|
|
option(ENABLE_GPU "Enable gpu" OFF)
|
|
|
|
option(ENABLE_CPU "Enable cpu" OFF)
|
|
|
|
option(ENABLE_MINDDATA "Enable minddata compile" OFF)
|
|
|
|
option(ENABLE_TESTCASES "Run testcases switch, default off" OFF)
|
2020-12-30 09:40:31 +08:00
|
|
|
option(ENABLE_CPP_ST "Run cpp st testcases switch, default off" OFF)
|
2020-03-27 14:49:12 +08:00
|
|
|
option(DEBUG_MODE "Debug mode, default off" OFF)
|
|
|
|
option(ENABLE_ASAN "Enable Google Sanitizer to find memory bugs")
|
|
|
|
option(ENABLE_LOAD_ANF_IR "Enable load ANF-IR as input of 'infer' stage of pipeline" OFF)
|
|
|
|
option(ENABLE_COVERAGE "Enable code coverage report" OFF)
|
|
|
|
option(USE_GLOG "Use glog to output log" OFF)
|
2021-07-20 16:20:00 +08:00
|
|
|
option(ENABLE_SECURITY "Enable security, maintenance function will be disabled, default off" OFF)
|
2020-03-27 14:49:12 +08:00
|
|
|
option(ENABLE_PROFILE "Enable pipeline profile, default off" OFF)
|
|
|
|
option(ENABLE_TIMELINE "Enable time line record" OFF)
|
|
|
|
option(ENABLE_DUMP_PROTO "Enable dump anf graph to file in ProtoBuffer format, default on" ON)
|
2021-01-23 20:20:31 +08:00
|
|
|
option(ENABLE_DUMP_IR "Enable dump function graph ir, default on" ON)
|
2020-03-27 14:49:12 +08:00
|
|
|
option(ENABLE_MPI "enable mpi" OFF)
|
|
|
|
option(ENABLE_AKG "enable akg" OFF)
|
2020-06-11 22:42:57 +08:00
|
|
|
option(ENABLE_DEBUGGER "enable debugger" OFF)
|
2023-01-29 11:06:14 +08:00
|
|
|
option(ENABLE_RDMA "enable RDMA for RPC" OFF)
|
2020-07-11 04:26:00 +08:00
|
|
|
option(ENABLE_PYTHON "Enable python" ON)
|
2020-09-18 14:09:16 +08:00
|
|
|
option(ENABLE_ACL "enable acl" OFF)
|
2021-03-20 19:56:45 +08:00
|
|
|
option(ENABLE_GLIBCXX "enable_glibcxx" OFF)
|
2021-05-26 11:31:02 +08:00
|
|
|
option(MODE_ASCEND_ALL "supports all ascend platform" OFF)
|
|
|
|
option(MODE_ASCEND_ACL "supports ascend acl mode only" OFF)
|
2021-08-22 16:26:45 +08:00
|
|
|
option(ENABLE_SYM_FILE "enable sym file" OFF)
|
2021-11-06 16:56:44 +08:00
|
|
|
option(BUILD_DEV_MODE "MindSpore build nightly dev mode" OFF)
|
2021-11-24 08:51:27 +08:00
|
|
|
option(ENABLE_FAST_HASH_TABLE "Enable use fast hash table instead of std ones" ON)
|
2021-12-03 17:04:54 +08:00
|
|
|
option(USE_LLVM "use llvm" OFF)
|
2021-12-28 11:46:48 +08:00
|
|
|
option(USE_MS_THREADPOOL_FOR_DNNL "use ms threadpool for onednn ops" ON)
|
2022-12-16 15:21:05 +08:00
|
|
|
option(ONLY_BUILD_DEVICE_PLUGINS "only build device plugins" OFF)
|
|
|
|
|
|
|
|
if(ONLY_BUILD_DEVICE_PLUGINS)
|
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
set(ONLY_BUILD_DEVICE_PLUGINS OFF)
|
|
|
|
message(WARNING "-f is supported on only linux.")
|
|
|
|
endif()
|
|
|
|
if(ENABLE_CPU)
|
|
|
|
set(ENABLE_CPU OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
set(ENABLE_MPI OFF)
|
|
|
|
endif()
|
2021-12-28 11:46:48 +08:00
|
|
|
|
2022-01-13 15:26:32 +08:00
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
2021-12-28 11:46:48 +08:00
|
|
|
set(USE_MS_THREADPOOL_FOR_DNNL OFF)
|
|
|
|
endif()
|
2021-03-20 19:56:45 +08:00
|
|
|
|
2022-11-09 11:41:35 +08:00
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
2021-03-20 19:56:45 +08:00
|
|
|
set(ENABLE_GLIBCXX ON)
|
|
|
|
endif()
|
2020-03-27 14:49:12 +08:00
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
if(WIN32)
|
2020-04-15 17:36:48 +08:00
|
|
|
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all")
|
|
|
|
else()
|
|
|
|
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")
|
|
|
|
endif()
|
2020-03-27 14:49:12 +08:00
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
2020-03-27 14:49:12 +08:00
|
|
|
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -Wsign-compare")
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_COVERAGE)
|
2020-03-27 14:49:12 +08:00
|
|
|
set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -ftest-coverage")
|
|
|
|
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_ASAN)
|
2021-03-17 20:15:02 +08:00
|
|
|
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer")
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(OPTION_CXX_FLAGS "${OPTION_CXX_FLAGS} -static-libsan")
|
2020-03-27 14:49:12 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(DEBUG_MODE)
|
2020-03-27 14:49:12 +08:00
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
2021-06-18 09:41:55 +08:00
|
|
|
add_compile_definitions(MEM_REUSE_DEBUG)
|
2020-04-17 16:45:50 +08:00
|
|
|
else()
|
2020-03-27 14:49:12 +08:00
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if((CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") OR (CMAKE_BUILD_TYPE STREQUAL Release))
|
2020-03-27 14:49:12 +08:00
|
|
|
set(PYBIND11_LTO_CXX_FLAGS FALSE)
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(NOT BUILD_PATH)
|
2020-03-27 14:49:12 +08:00
|
|
|
set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build")
|
|
|
|
endif()
|
|
|
|
|
2022-01-06 15:29:15 +08:00
|
|
|
if(ENABLE_D)
|
2020-03-27 14:49:12 +08:00
|
|
|
set(ENABLE_TDTQUE ON)
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_GPU)
|
2020-04-15 22:18:50 +08:00
|
|
|
add_compile_definitions(ENABLE_GPU_COLLECTIVE)
|
2020-03-27 14:49:12 +08:00
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_CPU)
|
2020-07-21 16:37:24 +08:00
|
|
|
add_compile_definitions(ENABLE_CPU)
|
|
|
|
endif()
|
|
|
|
|
2022-01-06 15:29:15 +08:00
|
|
|
if(ENABLE_D)
|
|
|
|
add_compile_definitions(ENABLE_D)
|
2020-03-27 14:49:12 +08:00
|
|
|
add_compile_definitions(CUSTOM_OP)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_GLOG)
|
|
|
|
add_compile_definitions(USE_GLOG)
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_PROFILE)
|
2020-03-27 14:49:12 +08:00
|
|
|
add_compile_definitions(ENABLE_PROFILE)
|
|
|
|
endif()
|
|
|
|
|
2021-07-20 16:20:00 +08:00
|
|
|
if(ENABLE_SECURITY)
|
|
|
|
add_compile_definitions(ENABLE_SECURITY)
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_TIMELINE)
|
2020-03-27 14:49:12 +08:00
|
|
|
add_compile_definitions(ENABLE_TIMELINE)
|
|
|
|
endif()
|
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_LOAD_ANF_IR)
|
2020-03-27 14:49:12 +08:00
|
|
|
add_compile_definitions(ENABLE_LOAD_ANF_IR)
|
|
|
|
endif()
|
|
|
|
|
2022-01-25 15:32:17 +08:00
|
|
|
if(ENABLE_TESTCASES)
|
|
|
|
add_compile_definitions(ENABLE_TEST)
|
|
|
|
endif()
|
|
|
|
|
2022-01-06 15:29:15 +08:00
|
|
|
if(ENABLE_TESTCASES OR (NOT ENABLE_D))
|
2020-03-27 14:49:12 +08:00
|
|
|
add_compile_definitions(NO_DLIB=1)
|
|
|
|
endif()
|
|
|
|
|
2022-09-21 16:39:30 +08:00
|
|
|
if(NOT (ENABLE_TESTCASES OR ENABLE_TEST) AND (ENABLE_D OR ENABLE_GPU OR ENABLE_CPU))
|
2022-05-23 08:37:13 +08:00
|
|
|
add_compile_definitions(WITH_BACKEND)
|
|
|
|
endif()
|
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
if(ENABLE_DUMP_IR)
|
|
|
|
add_compile_definitions(ENABLE_DUMP_IR)
|
2021-01-23 20:20:31 +08:00
|
|
|
endif()
|
2020-03-27 14:49:12 +08:00
|
|
|
|
|
|
|
if(ENABLE_MINDDATA)
|
|
|
|
add_compile_definitions(ENABLE_MINDDATA)
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_TDTQUE)
|
2020-03-27 14:49:12 +08:00
|
|
|
add_compile_definitions(ENABLE_TDTQUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-06-11 22:42:57 +08:00
|
|
|
if(ENABLE_DEBUGGER)
|
|
|
|
add_compile_definitions(ENABLE_DEBUGGER)
|
|
|
|
endif()
|
2020-09-11 15:07:17 +08:00
|
|
|
|
2021-01-23 20:20:31 +08:00
|
|
|
if(ENABLE_DEBUGGER OR ENABLE_TESTCASES)
|
2020-09-11 15:07:17 +08:00
|
|
|
set(MS_BUILD_GRPC ON)
|
|
|
|
endif()
|
2021-11-25 10:38:43 +08:00
|
|
|
if(ENABLE_MINDDATA AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
2020-09-11 15:07:17 +08:00
|
|
|
set(MS_BUILD_GRPC ON)
|
|
|
|
endif()
|
2021-05-26 11:31:02 +08:00
|
|
|
|
|
|
|
if(ENABLE_D AND ENABLE_ACL)
|
|
|
|
set(MODE_ASCEND_ALL ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_ACL AND NOT ENABLE_D)
|
|
|
|
set(MODE_ASCEND_ACL ON)
|
|
|
|
endif()
|
|
|
|
|
2021-11-25 10:38:43 +08:00
|
|
|
if(ENABLE_CPU AND NOT WIN32)
|
2021-07-14 15:12:27 +08:00
|
|
|
add_compile_definitions(ENABLE_ARMOUR)
|
|
|
|
endif()
|
2021-09-23 16:27:06 +08:00
|
|
|
|
|
|
|
if(ENABLE_AKG AND CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
add_compile_definitions(ENABLE_AKG)
|
|
|
|
endif()
|
2021-12-03 17:04:54 +08:00
|
|
|
|
|
|
|
if(USE_LLVM)
|
|
|
|
add_compile_definitions(USE_LLVM)
|
2022-01-06 15:29:15 +08:00
|
|
|
endif()
|
2021-12-28 11:46:48 +08:00
|
|
|
|
|
|
|
if(USE_MS_THREADPOOL_FOR_DNNL)
|
|
|
|
add_compile_definitions(USE_MS_THREADPOOL_FOR_DNNL)
|
|
|
|
endif()
|