CMakeLists.txt 2.2 KB
Newer Older
1
add_subdirectory(dynload)
2
add_subdirectory(gpu)
3

4
set(BACKENDS_SRCS all_context.cc cpu/cpu_context.cc cpu/cpu_info.cc)
5
set(BACKENDS_DEPS enforce place flags eigen3 phi_device_context)
6 7 8
if(WITH_XBYAK)
  list(APPEND BACKENDS_DEPS xbyak)
endif()
9

W
Wilber 已提交
10
if(WITH_GPU OR WITH_ROCM)
11 12 13
  list(APPEND BACKENDS_SRCS gpu/gpu_context.cc gpu/gpu_info.cc
       gpu/gpu_resources.cc)
  if(WITH_GPU)
14
    list(APPEND BACKENDS_SRCS gpu/cuda/cuda_info.cc gpu/cuda/cuda_graph.cc)
MarDino's avatar
MarDino 已提交
15 16 17 18 19
    set_source_files_properties(
      gpu/gpu_resources.cc
      PROPERTIES COMPILE_FLAGS
                 "-DCUDA_REAL_ARCHS=\"${NVCC_FLAGS_EXTRA_real_archs}\"")

20 21 22 23 24
  endif()
  if(WITH_ROCM)
    list(APPEND BACKENDS_SRCS gpu/rocm/rocm_info.cc)
  endif()
  list(APPEND BACKENDS_DEPS phi_dynload_cuda)
W
Wilber 已提交
25 26
endif()

W
Wilber 已提交
27
if(WITH_XPU)
28
  list(APPEND BACKENDS_SRCS xpu/xpu_context.cc xpu/xpu_info.cc)
29 30
  list(APPEND BACKENDS_SRCS xpu/xpu_op_list.cc xpu/xpu1_op_list.cc
       xpu/xpu2_op_list.cc)
W
Wilber 已提交
31 32
endif()

33
if(WITH_MKLDNN)
34
  list(APPEND BACKENDS_SRCS onednn/onednn_context.cc)
35
  list(APPEND BACKENDS_SRCS onednn/axpy_handler.cc)
36
  list(APPEND BACKENDS_DEPS mkldnn)
37 38
endif()

39 40 41 42 43 44 45 46 47 48
list(
  APPEND
  BACKENDS_SRCS
  callback_manager.cc
  device_guard.cc
  stream.cc
  event.cc
  device_base.cc
  device_manager.cc)

49
if(WITH_CUSTOM_DEVICE)
50
  list(APPEND BACKENDS_SRCS custom/custom_context.cc custom/custom_device.cc)
W
Wilber 已提交
51
endif()
W
Wilber 已提交
52

53 54
add_library(phi_backends "${BACKENDS_SRCS}")
target_link_libraries(phi_backends ${BACKENDS_DEPS})
55
add_dependencies(phi_backends eigen3)
56 57 58 59 60

# for inference library
get_property(phi_modules GLOBAL PROPERTY PHI_MODULES)
set(phi_modules ${phi_modules} phi_backends)
set_property(GLOBAL PROPERTY PHI_MODULES "${phi_modules}")
61 62

if(WITH_CUSTOM_DEVICE)
63 64 65
  cc_test(
    custom_device_test
    SRCS custom/custom_device_test.cc
66
    DEPS phi_backends phi_device_context gradient_accumulator)
67 68 69 70
  cc_test(
    capi_test
    SRCS custom/capi_test.cc
    DEPS phi_capi)
71
endif()
72

W
Wen Sun 已提交
73
set(COMM_UTILS_DEPS process_group)
74
if(WITH_NCCL OR WITH_RCCL)
W
Wen Sun 已提交
75
  set(COMM_UTILS_DEPS ${PROCESS_GROUP_UTILS_DEPS} process_group_nccl)
76 77
endif()
if(WITH_CUSTOM_DEVICE)
W
Wen Sun 已提交
78
  set(COMM_UTILS_DEPS ${PROCESS_GROUP_UTILS_DEPS} process_group_custom)
79 80 81 82 83
endif()
cc_library(
  processgroup_comm_utils
  SRCS processgroup_comm_utils.cc
  DEPS ${COMM_UTILS_DEPS})