diff --git a/cmake/mind_expression.cmake b/cmake/mind_expression.cmake index dff0bba9696a0c9ae802877c6e729cc90277a516..e7aa6ac3f4ac8768e1b0116cd904ffb2e0518728 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 733e19045d48149b2ca5f1bf8ba0f7e3a24cfae4..7971d9e3425b568a1553068aac2f35f644c4e82a 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 0fbeff6b4d71cdca30dc8915a271ee05fb26ce46..34766f443dce465681664f95b1a6eb3361811996 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 3201cec92e61f211c6ea7a47d26bc688d23eeaf2..aa1b81d8e4293722f3eb4341d73c898a1cdf9ffc 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 766647d8a3a686a8b93e07e48e6bbc07add3a7ca..8f06878e91d2b89683e3e8ff8f9e8b8251937359 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 b7369039e8f88559a5c65f616a983fa21bdce0c7..3a462d9cb9aa49af62f574678d5a7c156895f91f 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 2a6d46a779d483446412d81e5fb8f3a9799b3544..76e1ad53a5d0f1a1d3e4da99468ae5d378e2f0a3 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(); }