From 8ff1a9ab47b1068de7f51a872ecbc14c34623680 Mon Sep 17 00:00:00 2001 From: ZPaC Date: Tue, 21 Jul 2020 16:37:24 +0800 Subject: [PATCH] Use white list to control pslite compilation --- cmake/mind_expression.cmake | 2 +- cmake/options.cmake | 8 ++++---- mindspore/ccsrc/CMakeLists.txt | 2 +- mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt | 2 +- mindspore/ccsrc/backend/session/ascend_session.cc | 4 ++-- mindspore/ccsrc/backend/session/cpu_session.cc | 6 +++--- mindspore/ccsrc/backend/session/gpu_session.cc | 4 +++- mindspore/ccsrc/backend/session/session_basic.cc | 4 ++-- mindspore/ccsrc/frontend/parallel/CMakeLists.txt | 2 +- mindspore/ccsrc/minddata/dataset/CMakeLists.txt | 2 +- mindspore/ccsrc/pipeline/jit/action.cc | 8 ++++---- mindspore/ccsrc/pipeline/jit/pipeline.cc | 4 ++-- 12 files changed, 25 insertions(+), 23 deletions(-) diff --git a/cmake/mind_expression.cmake b/cmake/mind_expression.cmake index dff0bba969..e7aa6ac3f4 100644 --- a/cmake/mind_expression.cmake +++ b/cmake/mind_expression.cmake @@ -30,7 +30,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/external_libs/flatbuffers.cmake) if(USE_GLOG) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/glog.cmake) endif() -if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT ENABLE_GE) +if (ENABLE_CPU AND (ENABLE_D OR ENABLE_GPU)) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/zeromq.cmake) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/pslite.cmake) endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index 733e19045d..7971d9e342 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -70,6 +70,10 @@ if (ENABLE_GPU) add_compile_definitions(ENABLE_GPU_COLLECTIVE) endif() +if (ENABLE_CPU) + add_compile_definitions(ENABLE_CPU) +endif() + if (ENABLE_GE) add_compile_definitions(ENABLE_GE) add_compile_definitions(CUSTOM_OP) @@ -119,7 +123,3 @@ endif() if(ENABLE_DEBUGGER) add_compile_definitions(ENABLE_DEBUGGER) endif() - -if(ENABLE_TESTCASES) - add_compile_definitions(ENABLE_TESTCASES) -endif() \ No newline at end of file diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index 1ad152d71a..c1bc641d27 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -252,7 +252,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows") target_link_libraries(mindspore mindspore_gvar) target_link_libraries(_c_expression PRIVATE -Wl,--whole-archive mindspore -Wl,--no-whole-archive) else () - if (NOT ENABLE_GE) + if (ENABLE_CPU AND (ENABLE_D OR ENABLE_GPU)) target_link_libraries(mindspore mindspore::pslite mindspore::protobuf ${zeromq_DIRPATH}/zmq_install/lib/libzmq.a) if (${ENABLE_IBVERBS} STREQUAL "ON") target_link_libraries(mindspore ibverbs rdmacm) diff --git a/mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt b/mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt index 3201cec92e..aa1b81d8e4 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt +++ b/mindspore/ccsrc/backend/kernel_compiler/CMakeLists.txt @@ -33,7 +33,7 @@ if (ENABLE_CPU) endif () endif () -if (${CMAKE_SYSTEM_NAME} MATCHES "Windows" OR ENABLE_GE) +if (NOT (ENABLE_CPU AND (ENABLE_D OR ENABLE_GPU))) list(REMOVE_ITEM CPU_SRC_LIST "cpu/ps/apply_momentum_ps_kernel.cc") list(REMOVE_ITEM CPU_SRC_LIST "cpu/ps/embedding_look_up_proxy_kernel.cc") list(REMOVE_ITEM CPU_SRC_LIST "cpu/ps/embedding_look_up_ps_kernel.cc") diff --git a/mindspore/ccsrc/backend/session/ascend_session.cc b/mindspore/ccsrc/backend/session/ascend_session.cc index 766647d8a3..8f06878e91 100644 --- a/mindspore/ccsrc/backend/session/ascend_session.cc +++ b/mindspore/ccsrc/backend/session/ascend_session.cc @@ -353,7 +353,7 @@ GraphId AscendSession::CompileGraph(NotNull func_graph) { RootGraphExecutorValidate(NOT_NULL(root_graph)); // adjust kernel AdjustKernel(root_graph); -#if (!_WIN32 && !ENABLE_GE && !ENABLE_TESTCASES) +#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU)) // Assign parameter keys. AssignParamKey(root_graph); #endif @@ -515,7 +515,7 @@ void AscendSession::RunGraph(const GraphId &graph_id, const std::vector &inputs, VectorRef *outputs) { auto &kernel_graph = graphs_[graph_id]; MS_EXCEPTION_IF_NULL(kernel_graph); -#if (!_WIN32 && !ENABLE_GE && !ENABLE_TESTCASES) +#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU)) // Initialize parameter server if (!ps_init_) { InitPSParamAndOptim(kernel_graph, inputs); diff --git a/mindspore/ccsrc/backend/session/gpu_session.cc b/mindspore/ccsrc/backend/session/gpu_session.cc index b7369039e8..3a462d9cb9 100644 --- a/mindspore/ccsrc/backend/session/gpu_session.cc +++ b/mindspore/ccsrc/backend/session/gpu_session.cc @@ -182,7 +182,7 @@ GraphId GPUSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrList Optimize(graph); // Select kernel build info SelectKernel(graph); -#if (!_WIN32 && !ENABLE_GE && !ENABLE_TESTCASES) +#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU)) // Assign parameter keys. AssignParamKey(graph); #endif @@ -231,10 +231,12 @@ void GPUSession::RunGraph(const GraphId &graph_id, const std::vector::GetInstance().Run(); return true; @@ -505,7 +505,7 @@ std::vector VmPipeline() { actions.emplace_back(std::make_pair("py_opt", OptActionPyStub)); actions.emplace_back(std::make_pair("validate", ValidateAction)); -#if (!_WIN32 && !ENABLE_GE && !ENABLE_TESTCASES) +#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU)) if (parallel::ps::Util::IsRoleOfWorker()) { actions.emplace_back(std::make_pair("worker", StartPSWorkerAction)); } @@ -519,7 +519,7 @@ std::vector VmPipeline() { return actions; } -#if (!_WIN32 && !ENABLE_GE && !ENABLE_TESTCASES) +#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU)) std::vector PServerPipeline() { auto actions = CommonPipeline(); actions.emplace_back(std::make_pair("optimize", VmOptimizeAction)); diff --git a/mindspore/ccsrc/pipeline/jit/pipeline.cc b/mindspore/ccsrc/pipeline/jit/pipeline.cc index 2a6d46a779..76e1ad53a5 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline.cc @@ -42,7 +42,7 @@ #include "frontend/optimizer/py_pass_manager.h" #include "pybind_api/pybind_patch.h" -#if (!_WIN32 && !ENABLE_GE && !ENABLE_TESTCASES) +#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU)) #include "frontend/parallel/ps/common.h" #include "frontend/parallel/ps/util.h" #endif @@ -403,7 +403,7 @@ std::vector GetPipline(const ResourcePtr &resource, const std::strin std::string backend = MsContext::GetInstance()->backend_policy(); -#if (!_WIN32 && !ENABLE_GE && !ENABLE_TESTCASES) +#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU)) if (mindspore::parallel::ps::Util::IsParamServerMode()) { mindspore::parallel::ps::Util::SetInternalEnvVar(); }