You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 3.1 kB

6 years ago
6 years ago
6 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. file(GLOB_RECURSE DEVICE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "common/*.cc"
  2. "kernel_info.cc" "executor/dynamic_kernel.cc" "kernel_runtime.cc" "memory_manager.cc" "kernel_runtime_manager.cc" "convert_tensor_utils.cc"
  3. )
  4. if (ENABLE_GPU)
  5. list(APPEND DEVICE_SRC_LIST "gpu/distribution/collective_init.cc")
  6. else ()
  7. list(APPEND DEVICE_SRC_LIST "gpu/distribution/collective_fake_init.cc")
  8. endif ()
  9. if (ENABLE_D)
  10. file(GLOB_RECURSE D_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "ascend/*.cc" "kernel_adjust.cc")
  11. endif ()
  12. if (ENABLE_CPU)
  13. file(GLOB_RECURSE CPU_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "cpu/*.cc")
  14. list(REMOVE_ITEM CPU_SRC_LIST "cpu/mpi/mpi_adapter.cc" "cpu/mpi/mpi_export.cc")
  15. endif ()
  16. if (ENABLE_MPI)
  17. if (ENABLE_CPU)
  18. file(GLOB_RECURSE MPI_SRC_LIST "cpu/mpi/mpi_adapter.cc" "cpu/mpi/mpi_export.cc")
  19. set_property(SOURCE ${MPI_SRC_LIST}
  20. PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE)
  21. add_library(mpi_adapter SHARED ${MPI_SRC_LIST})
  22. target_link_libraries(mpi_adapter PRIVATE mindspore::ompi)
  23. endif ()
  24. if (ENABLE_GPU)
  25. set_property(SOURCE "gpu/mpi/mpi_initializer.cc"
  26. PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE)
  27. pybind11_add_module(_ms_mpi "gpu/mpi/mpi_initializer.cc")
  28. target_link_libraries(_ms_mpi PRIVATE mindspore::pybind11_module mindspore::ompi)
  29. endif ()
  30. endif ()
  31. # gpu
  32. if (ENABLE_GPU)
  33. file(GLOB_RECURSE CUDA_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "gpu/*.cc" "gpu/*.cu")
  34. set(GPU_QUEUE_SRCS "gpu/blocking_queue.cc" "gpu/gpu_buffer_mgr.cc")
  35. set(GPU_COLLECTIVE_SRCS "gpu/distribution/collective_wrapper.cc"
  36. "gpu/distribution/mpi_wrapper.cc"
  37. "gpu/distribution/nccl_wrapper.cc")
  38. # gpu_queue
  39. list(REMOVE_ITEM CUDA_SRC_LIST ${GPU_QUEUE_SRCS})
  40. set_property(SOURCE ${GPU_QUEUE_SRCS} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE)
  41. add_library(gpu_queue SHARED ${GPU_QUEUE_SRCS})
  42. target_link_libraries(gpu_queue ${CMAKE_THREAD_LIBS_INIT} ${CUDA_PATH}/lib64/libcudart.so)
  43. list(REMOVE_ITEM CUDA_SRC_LIST "gpu/mpi/mpi_initializer.cc" ${GPU_COLLECTIVE_SRCS})
  44. if (ENABLE_MPI)
  45. include(ExternalProject)
  46. # gpu_collective
  47. set_property(SOURCE ${GPU_COLLECTIVE_SRCS}
  48. PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE)
  49. add_library(gpu_collective SHARED ${GPU_COLLECTIVE_SRCS})
  50. target_link_libraries(gpu_collective PRIVATE mindspore::ompi mindspore::nccl)
  51. target_link_libraries(_ms_mpi PRIVATE gpu_collective)
  52. endif ()
  53. # add_library(_mindspore_device_cuda_obj OBJECT ${CUDA_SRC_LIST})
  54. endif ()
  55. set_property(SOURCE ${DEVICE_SRC_LIST} ${D_SRC_LIST} ${CPU_SRC_LIST}
  56. PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_DEVICE)
  57. add_library(_mindspore_runtime_device_obj OBJECT ${DEVICE_SRC_LIST} ${D_SRC_LIST} ${CPU_SRC_LIST})