From 51e9fbf973688b6574e6ac5805bf3f89dfa5a902 Mon Sep 17 00:00:00 2001 From: kswang Date: Wed, 5 Aug 2020 22:07:45 +0800 Subject: [PATCH] format ompi --- cmake/mind_expression.cmake | 7 +++--- cmake/package.cmake | 25 +++++++++++++++---- mindspore/ccsrc/CMakeLists.txt | 2 +- mindspore/ccsrc/runtime/device/CMakeLists.txt | 23 +++++++++-------- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/cmake/mind_expression.cmake b/cmake/mind_expression.cmake index a3a469c2704..d5680e00275 100644 --- a/cmake/mind_expression.cmake +++ b/cmake/mind_expression.cmake @@ -38,11 +38,12 @@ endif() find_package(Python3) include_directories(${Python3_INCLUDE_DIRS}) include_directories(${CMAKE_SOURCE_DIR}/third_party) +if (ENABLE_MPI) + include(${CMAKE_SOURCE_DIR}/cmake/external_libs/ompi.cmake) +endif() + if (ENABLE_CPU) include(${CMAKE_SOURCE_DIR}/cmake/external_libs/mkl_dnn.cmake) - if (ENABLE_MPI) - include(${CMAKE_SOURCE_DIR}/cmake/external_libs/ompi.cmake) - endif() endif() if (ENABLE_GPU) diff --git a/cmake/package.cmake b/cmake/package.cmake index 1b0f349f159..77605204f47 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -132,24 +132,39 @@ if (ENABLE_CPU) endif () if (ENABLE_MPI) - install( - TARGETS _ms_mpi - DESTINATION ${INSTALL_BASE_DIR} - COMPONENT mindspore + if (ENABLE_GPU) + install( + TARGETS _ms_mpi + DESTINATION ${INSTALL_BASE_DIR} + COMPONENT mindspore + ) + endif () + if (ENABLE_CPU) + install( + TARGETS mpi_adapter + DESTINATION ${INSTALL_LIB_DIR} + COMPONENT mindspore + ) + endif () + file(GLOB_RECURSE MPI_LIB_LIST + ${ompi_LIBPATH}/libmpi${CMAKE_SHARED_LIBRARY_SUFFIX}* + ${ompi_LIBPATH}/libopen*${CMAKE_SHARED_LIBRARY_SUFFIX}* ) install( - TARGETS mpi_adapter + FILES ${MPI_LIB_LIST} DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore ) endif () if (ENABLE_GPU) + if (ENABLE_MPI) install( TARGETS gpu_collective DESTINATION ${INSTALL_LIB_DIR} COMPONENT mindspore ) + endif () install( TARGETS gpu_queue DESTINATION ${INSTALL_LIB_DIR} diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index 1339b4b9ea7..d26539f2d84 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -162,7 +162,7 @@ if (ENABLE_DEBUGGER) endif() target_link_libraries(mindspore proto_input) -if (ENABLE_MPI) +if (ENABLE_MPI AND ENABLE_CPU) target_link_libraries(mindspore securec mindspore::flatbuffers mpi_adapter) else () target_link_libraries(mindspore securec mindspore::flatbuffers) diff --git a/mindspore/ccsrc/runtime/device/CMakeLists.txt b/mindspore/ccsrc/runtime/device/CMakeLists.txt index 3de02822ec0..fac738ca69f 100644 --- a/mindspore/ccsrc/runtime/device/CMakeLists.txt +++ b/mindspore/ccsrc/runtime/device/CMakeLists.txt @@ -18,17 +18,20 @@ if (ENABLE_CPU) endif () if (ENABLE_MPI) - # _ms_mpi - file(GLOB_RECURSE MPI_SRC_LIST "cpu/mpi/mpi_adapter.cc") - set_property(SOURCE ${MPI_SRC_LIST} - PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE) - add_library(mpi_adapter SHARED ${MPI_SRC_LIST}) - target_link_libraries(mpi_adapter PRIVATE mindspore::ompi) + if (ENABLE_CPU) + file(GLOB_RECURSE MPI_SRC_LIST "cpu/mpi/mpi_adapter.cc") + set_property(SOURCE ${MPI_SRC_LIST} + PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE) + add_library(mpi_adapter SHARED ${MPI_SRC_LIST}) + target_link_libraries(mpi_adapter PRIVATE mindspore::ompi) + endif () - set_property(SOURCE "gpu/mpi/mpi_initializer.cc" - PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE) - pybind11_add_module(_ms_mpi "gpu/mpi/mpi_initializer.cc") - target_link_libraries(_ms_mpi PRIVATE mindspore::pybind11_module mindspore::ompi) + if (ENABLE_GPU) + set_property(SOURCE "gpu/mpi/mpi_initializer.cc" + PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE) + pybind11_add_module(_ms_mpi "gpu/mpi/mpi_initializer.cc") + target_link_libraries(_ms_mpi PRIVATE mindspore::pybind11_module mindspore::ompi) + endif () endif () # gpu