CMakeLists.txt 8.7 KB
Newer Older
P
peizhilin 已提交
1
proto_library(profiler_proto SRCS profiler.proto DEPS framework_proto simple_threadpool)
2
proto_library(error_codes_proto SRCS error_codes.proto)
3
if(WITH_GPU)
4
  proto_library(external_error_proto SRCS external_error.proto)
5
endif(WITH_GPU)
X
Xin Pan 已提交
6

7
if(WITH_XPU)
8
  set(XPU_CTX_DEPS xpulib ssl crypto rt z resolv dl)
9 10 11 12
ELSE()
  set(XPU_CTX_DEPS)
endif(WITH_XPU)

13 14 15 16 17 18
if(WITH_ASCEND)
    set(ASCEND_DEPS xpulib)
ELSE()
  set(ASCEND_DEPS)
endif(WITH_ASCEND)

19 20 21 22 23 24 25
if (WITH_PYTHON)
  py_proto_compile(profiler_py_proto SRCS profiler.proto)
  add_custom_target(profiler_py_proto_init ALL COMMAND ${CMAKE_COMMAND} -E touch __init__.py)
  add_dependencies(profiler_py_proto profiler_py_proto_init)

  if (NOT WIN32)
    add_custom_command(TARGET profiler_py_proto POST_BUILD
26 27
        COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_BINARY_DIR}/python/paddle/fluid/proto/profiler
        COMMAND cp *.py ${PADDLE_BINARY_DIR}/python/paddle/fluid/proto/profiler
X
Xin Pan 已提交
28 29
        COMMENT "Copy generated python proto into directory paddle/fluid/proto/profiler."
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
30 31 32
  else(NOT WIN32)
    string(REPLACE "/" "\\" proto_dstpath "${PADDLE_BINARY_DIR}/python/paddle/fluid/proto/profiler/")
    add_custom_command(TARGET profiler_py_proto POST_BUILD
W
wopeizl 已提交
33 34 35 36
        COMMAND ${CMAKE_COMMAND} -E make_directory ${PADDLE_BINARY_DIR}/python/paddle/fluid/proto/profiler
        COMMAND copy /Y *.py ${proto_dstpath}
        COMMENT "Copy generated python proto into directory paddle/fluid/proto/profiler."
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
37 38
  endif(NOT WIN32)
endif()
39

Z
Zeng Jinle 已提交
40
cc_library(flags SRCS flags.cc DEPS gflags boost)
41
cc_library(denormal SRCS denormal.cc DEPS)
42

43 44 45
cc_library(errors SRCS errors.cc DEPS error_codes_proto)
cc_test(errors_test SRCS errors_test.cc DEPS errors enforce)

Z
Zeng Jinle 已提交
46
set(enforce_deps flags errors boost flags)
47
if(WITH_GPU)
48
  set(enforce_deps ${enforce_deps} external_error_proto)
49 50
endif()
cc_library(enforce INTERFACE SRCS enforce.cc DEPS ${enforce_deps})
H
hutuxian 已提交
51
cc_library(monitor SRCS monitor.cc)
Q
Qiao Longfei 已提交
52 53
cc_test(enforce_test SRCS enforce_test.cc DEPS stringpiece enforce)

T
tensor-tang 已提交
54 55 56 57 58
set(CPU_INFO_DEPS gflags glog enforce)
IF(WITH_XBYAK)
    list(APPEND CPU_INFO_DEPS xbyak)
ENDIF()
cc_library(cpu_info SRCS cpu_info.cc DEPS ${CPU_INFO_DEPS})
L
liaogang 已提交
59
cc_test(cpu_info_test SRCS cpu_info_test.cc DEPS cpu_info)
L
liaogang 已提交
60

61 62
IF(WITH_GPU)
    nv_library(gpu_info SRCS gpu_info.cc DEPS gflags glog enforce monitor dynload_cuda)
63
    nv_library(cuda_profiler SRCS cuda_profiler.cc DEPS enforce)
64 65 66 67
ENDIF()
IF(WITH_ROCM)
    hip_library(gpu_info SRCS gpu_info.cc DEPS gflags glog enforce monitor dynload_cuda)
ENDIF()
68

T
Tao Luo 已提交
69
cc_library(place SRCS place.cc DEPS enforce boost)
L
liaogang 已提交
70
cc_test(place_test SRCS place_test.cc DEPS place glog gflags)
L
liaogang 已提交
71

72
if(WITH_XPU)
Q
QingshuChen 已提交
73
cc_library(xpu_info SRCS xpu/xpu_info.cc DEPS gflags glog enforce xpulib)
74
cc_library(xpu_op_list SRCS xpu/xpu_op_list.cc DEPS gflags glog enforce xpulib device_context)
75 76
endif()

77 78 79 80
if(WITH_ASCEND)
    cc_library(ascend_npu_info SRCS ascend_npu_info.cc DEPS gflags glog enforce atlas_acl)
endif()

81 82 83 84
if(WITH_ASCEND_CL)
    cc_library(npu_info SRCS npu_info.cc DEPS gflags glog enforce monitor ascendcl acl_op_compiler)
endif()

L
liaogang 已提交
85
add_subdirectory(dynload)
86
add_subdirectory(stream)
L
liaogang 已提交
87

T
tensor-tang 已提交
88 89 90
cc_library(cpu_helper SRCS cpu_helper.cc DEPS cblas enforce)
cc_test(cpu_helper_test SRCS cpu_helper_test.cc DEPS cpu_helper)

91
set(dgc_deps "")
G
gongweibao 已提交
92 93 94 95
IF(WITH_DGC)
    set(dgc_deps dgc)
ENDIF()

96
IF(WITH_GPU OR WITH_ROCM)
97
    set(GPU_CTX_DEPS dynload_cuda dynamic_loader cuda_stream)
Q
qijun 已提交
98 99
ENDIF()

100 101 102 103
IF(WITH_ASCEND_CL)
    set(NPU_CTX_DEPS npu_stream npu_info)
ENDIF()

T
tensor-tang 已提交
104 105 106 107 108
IF(WITH_MKLDNN)
    set(MKLDNN_CTX_DEPS mkldnn)
ELSE()
    set(MKLDNN_CTX_DEPS)
ENDIF()
109 110

IF(WITH_ASCEND_CL)
111
cc_library(stream_callback_manager SRCS stream_callback_manager.cc DEPS simple_threadpool enforce)
112 113
ENDIF()

S
sneaxiy 已提交
114
IF(WITH_GPU)
115
    nv_library(stream_callback_manager SRCS stream_callback_manager.cc DEPS simple_threadpool enforce)
116 117 118 119 120 121
ENDIF()
IF(WITH_ROCM)
    hip_library(stream_callback_manager SRCS stream_callback_manager.cc DEPS simple_threadpool enforce)
ENDIF()

IF(WITH_GPU OR WITH_ROCM)
S
sneaxiy 已提交
122
  set(STREAM_CALLBACK_DEPS stream_callback_manager)
123 124
ELSEIF(WITH_ASCEND_CL)
  set(STREAM_CALLBACK_DEPS stream_callback_manager)
S
sneaxiy 已提交
125 126 127 128
ELSE()
  set(STREAM_CALLBACK_DEPS)
ENDIF()

129 130 131 132
if(WITH_GLOO)
    cc_library(gloo_context SRCS gloo_context.cc DEPS framework_proto gloo_wrapper enforce)
endif()

133 134
cc_library(cudnn_workspace_helper SRCS cudnn_workspace_helper.cc DEPS boost)

135
# memcpy depends on device_context, here add deps individually for
Q
qijun 已提交
136
# avoiding cycle dependencies
137
cc_library(device_context SRCS device_context.cc init.cc DEPS simple_threadpool malloc xxhash ${STREAM_CALLBACK_DEPS}
138
    place eigen3 stringpiece cpu_helper cpu_info framework_proto ${GPU_CTX_DEPS} ${NPU_CTX_DEPS} ${MKLDNN_CTX_DEPS}
139
    ${dgc_deps} dlpack cudnn_workspace_helper ${XPU_CTX_DEPS})
140

141
cc_library(collective_helper SRCS collective_helper.cc collective_helper_npu.cc gen_comm_id_helper.cc DEPS framework_proto  device_context enforce)
142

143
if(WITH_GPU OR WITH_ROCM)
144 145 146 147
    cc_library(cuda_resource_pool SRCS cuda_resource_pool.cc DEPS gpu_info)
    target_link_libraries(device_context cuda_resource_pool)
endif()

148 149 150 151 152
if(WITH_ASCEND_CL)
    cc_library(npu_resource_pool SRCS npu_resource_pool.cc DEPS npu_info)
    target_link_libraries(device_context npu_resource_pool)
endif()

153 154
cc_test(init_test SRCS init_test.cc DEPS device_context)

155 156 157 158
# Manage all device event library
set(DEVICE_EVENT_LIBS)
cc_library(device_event_base SRCS device_event_base.cc DEPS place enforce device_context op_registry)
set(DEVICE_EVENT_LIBS  device_event_base CACHE INTERNAL "device event libs")
159 160


161
if(WITH_GPU)
162 163 164 165
  nv_library(device_event_gpu SRCS device_event_gpu.cc DEPS device_event_base)
  set(DEVICE_EVENT_LIBS  device_event_gpu CACHE INTERNAL "device event libs")
  nv_test(device_event_test SRCS device_event_test.cc DEPS device_event_gpu)

166 167 168 169 170 171 172
  nv_test(device_context_test SRCS device_context_test.cu DEPS device_context gpu_info)
  nv_test(cudnn_helper_test SRCS cudnn_helper_test.cc DEPS dynload_cuda)
  nv_test(cudnn_desc_test SRCS cudnn_desc_test.cc DEPS dynload_cuda)
  nv_test(transform_test SRCS transform_test.cu DEPS memory place device_context)
endif()

if(WITH_ROCM)
173 174 175 176
  hip_library(device_event_gpu SRCS device_event_gpu.cc DEPS device_event_base)
  set(DEVICE_EVENT_LIBS  device_event_gpu CACHE INTERNAL "device event libs")
  hip_test(device_event_test SRCS device_event_test.cc DEPS device_event_gpu)

177 178 179 180 181
  hip_test(device_context_test SRCS device_context_test.cu DEPS device_context gpu_info)
  hip_test(miopen_helper_test SRCS miopen_helper_test.cc DEPS dynload_cuda)
  hip_test(cudnn_desc_test SRCS cudnn_desc_test.cc DEPS dynload_cuda tensor)
  hip_test(transform_test SRCS transform_test.cu DEPS memory place device_context)
endif()
D
dangqingqing 已提交
182

183
cc_library(timer SRCS timer.cc)
184
cc_test(timer_test SRCS timer_test.cc DEPS timer)
185

D
dongdaxiang 已提交
186
cc_library(lodtensor_printer SRCS lodtensor_printer.cc DEPS ddim place tensor scope lod_tensor variable_helper framework_proto)
D
dongdaxiang 已提交
187
cc_test(lodtensor_printer_test SRCS lodtensor_printer_test.cc DEPS lodtensor_printer)
D
dongdaxiang 已提交
188

189
cc_library(device_tracer SRCS device_tracer.cc DEPS boost profiler_proto framework_proto ${GPU_CTX_DEPS})
190
if(WITH_GPU)
191
  nv_library(profiler SRCS profiler.cc profiler.cu DEPS device_tracer gpu_info enforce dynload_cuda)
192 193
  nv_test(cuda_helper_test SRCS cuda_helper_test.cu)
  nv_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info gpu_info place)
194 195 196 197
elseif(WITH_ROCM)
  hip_library(profiler SRCS profiler.cc profiler.cu DEPS device_tracer gpu_info enforce)
  hip_test(cuda_helper_test SRCS cuda_helper_test.cu)
  hip_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info gpu_info place)
198
else()
199 200
  cc_library(profiler SRCS profiler.cc DEPS device_tracer enforce)
  cc_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info place)
201
endif()
202

T
Tao Luo 已提交
203
cc_test(profiler_test SRCS profiler_test.cc DEPS profiler)
204
cc_test(float16_test SRCS float16_test.cc DEPS lod_tensor)
205
cc_test(bfloat16_test SRCS bfloat16_test.cc DEPS lod_tensor)
206
cc_test(complex_test SRCS complex_test.cc DEPS lod_tensor)
207

208 209
IF(WITH_GPU)
  nv_test(float16_gpu_test SRCS float16_test.cu DEPS lod_tensor)
210
  nv_test(bfloat16_gpu_test SRCS bfloat16_test.cu DEPS lod_tensor)
211
  nv_test(complex_gpu_test SRCS complex_test.cu DEPS lod_tensor)
212 213 214
  nv_test(test_limit_gpu_memory SRCS test_limit_gpu_memory.cu DEPS gpu_info flags)
  nv_library(cuda_device_guard SRCS cuda_device_guard.cc DEPS gpu_info)
ENDIF()
215

216 217 218 219 220
IF(WITH_ROCM)
  hip_test(float16_gpu_test SRCS float16_test.cu DEPS lod_tensor)
  hip_test(test_limit_gpu_memory SRCS test_limit_gpu_memory.cu DEPS gpu_info flags)
  hip_library(cuda_device_guard SRCS cuda_device_guard.cc DEPS gpu_info)
ENDIF()
221

222 223
if(NOT APPLE AND NOT WIN32)
  cc_library(device_code SRCS device_code.cc DEPS device_context)
224
  if(WITH_GPU OR WITH_ROCM)
225 226
    cc_test(device_code_test SRCS device_code_test.cc DEPS device_code lod_tensor)
  endif()
227
endif()