CMakeLists.txt 1.8 KB
Newer Older
1 2
add_subdirectory(dynload)

3
set(BACKENDS_SRCS all_context.cc cpu/cpu_context.cc)
4
set(BACKENDS_DEPS enforce place flags eigen3 phi_device_context)
5

W
Wilber 已提交
6
if(WITH_GPU OR WITH_ROCM)
7 8 9 10 11 12 13 14 15
  list(APPEND BACKENDS_SRCS gpu/gpu_context.cc gpu/gpu_info.cc
       gpu/gpu_resources.cc)
  if(WITH_GPU)
    list(APPEND BACKENDS_SRCS gpu/cuda/cuda_info.cc)
  endif()
  if(WITH_ROCM)
    list(APPEND BACKENDS_SRCS gpu/rocm/rocm_info.cc)
  endif()
  list(APPEND BACKENDS_DEPS phi_dynload_cuda)
W
Wilber 已提交
16 17
endif()

W
Wilber 已提交
18
if(WITH_XPU)
19
  add_subdirectory(xpu)
20
  list(APPEND BACKENDS_SRCS xpu/xpu_context.cc xpu/xpu_info.cc)
W
Wilber 已提交
21 22
endif()

23
if(WITH_MKLDNN)
24
  list(APPEND BACKENDS_SRCS onednn/onednn_context.cc)
25
  list(APPEND BACKENDS_SRCS onednn/axpy_handler.cc)
26
  list(APPEND BACKENDS_DEPS mkldnn)
27 28
endif()

29 30 31 32 33 34 35 36 37 38 39 40
if(WITH_CUSTOM_DEVICE)
  list(
    APPEND
    BACKENDS_SRCS
    callback_manager.cc
    device_guard.cc
    stream.cc
    event.cc
    device_base.cc
    device_manager.cc
    custom/custom_context.cc
    custom/custom_device.cc)
W
Wilber 已提交
41
endif()
W
Wilber 已提交
42

43 44
add_library(phi_backends "${BACKENDS_SRCS}")
target_link_libraries(phi_backends ${BACKENDS_DEPS})
45
add_dependencies(phi_backends eigen3)
46 47 48 49 50

# 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}")
51 52

if(WITH_CUSTOM_DEVICE)
53 54 55
  cc_test(
    custom_device_test
    SRCS custom/custom_device_test.cc
56
    DEPS phi_backends phi_device_context gradient_accumulator)
57 58 59 60
  cc_test(
    capi_test
    SRCS custom/capi_test.cc
    DEPS phi_capi)
61
endif()
62 63 64 65 66 67 68 69 70 71 72 73

set(COMM_UTILS_DEPS processgroup)
if(WITH_NCCL OR WITH_RCCL)
  set(COMM_UTILS_DEPS ${PROCESS_GROUP_UTILS_DEPS} processgroup_nccl)
endif()
if(WITH_CUSTOM_DEVICE)
  set(COMM_UTILS_DEPS ${PROCESS_GROUP_UTILS_DEPS} processgroup_custom)
endif()
cc_library(
  processgroup_comm_utils
  SRCS processgroup_comm_utils.cc
  DEPS ${COMM_UTILS_DEPS})