CMakeLists.txt 8.0 KB
Newer Older
P
peizhilin 已提交
1
proto_library(profiler_proto SRCS profiler.proto DEPS framework_proto simple_threadpool)
2
if(WITH_GPU)
3
  proto_library(external_error_proto SRCS external_error.proto)
4
endif(WITH_GPU)
5 6 7 8 9 10 11
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
12 13
        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 已提交
14 15
        COMMENT "Copy generated python proto into directory paddle/fluid/proto/profiler."
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
16 17 18
  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 已提交
19 20 21 22
        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})
23 24
  endif(NOT WIN32)
endif()
25

Z
Zeng Jinle 已提交
26
cc_library(flags SRCS flags.cc DEPS gflags boost)
27
cc_library(denormal SRCS denormal.cc DEPS)
28

29 30
cc_test(errors_test SRCS errors_test.cc DEPS errors enforce)

31
set(enforce_deps flags errors boost flags pten_enforce)
32
if(WITH_GPU)
33
  set(enforce_deps ${enforce_deps} external_error_proto)
34
endif()
F
fwenguang 已提交
35

36
cc_library(enforce INTERFACE SRCS enforce.cc DEPS ${enforce_deps})
H
hutuxian 已提交
37
cc_library(monitor SRCS monitor.cc)
Q
Qiao Longfei 已提交
38 39
cc_test(enforce_test SRCS enforce_test.cc DEPS stringpiece enforce)

T
tensor-tang 已提交
40 41 42 43 44
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 已提交
45
cc_test(cpu_info_test SRCS cpu_info_test.cc DEPS cpu_info)
L
liutiexing 已提交
46
cc_library(os_info SRCS os_info.cc DEPS enforce)
L
liutiexing 已提交
47
cc_test(os_info_test SRCS os_info_test.cc DEPS os_info)
L
liaogang 已提交
48

49
IF(WITH_GPU)
50 51 52
    nv_library(cuda_graph_with_memory_pool SRCS cuda_graph_with_memory_pool.cc DEPS device_context allocator_facade cuda_graph)
ELSE()
    cc_library(cuda_graph_with_memory_pool SRCS cuda_graph_with_memory_pool.cc DEPS device_context allocator_facade)
53
ENDIF()
54

55
cc_library(place SRCS place.cc DEPS enforce boost pten_place)
L
liaogang 已提交
56
cc_test(place_test SRCS place_test.cc DEPS place glog gflags)
L
liaogang 已提交
57

58
add_subdirectory(device)
L
liaogang 已提交
59
add_subdirectory(dynload)
60
add_subdirectory(stream)
L
liaogang 已提交
61

T
tensor-tang 已提交
62 63 64
cc_library(cpu_helper SRCS cpu_helper.cc DEPS cblas enforce)
cc_test(cpu_helper_test SRCS cpu_helper_test.cc DEPS cpu_helper)

65
set(dgc_deps "")
G
gongweibao 已提交
66 67 68 69
IF(WITH_DGC)
    set(dgc_deps dgc)
ENDIF()

70
IF(WITH_GPU OR WITH_ROCM)
71
    set(GPU_CTX_DEPS dynload_cuda dynamic_loader cuda_stream)
Q
qijun 已提交
72 73
ENDIF()

J
jianghaicheng 已提交
74 75 76 77 78 79
IF(WITH_IPU)
    set(IPU_CTX_DEPS ipu_backend)
ELSE()
    set(IPU_CTX_DEPS)
ENDIF(WITH_IPU)

80 81 82 83
IF(WITH_ASCEND_CL)
    set(NPU_CTX_DEPS npu_stream npu_info)
ENDIF()

F
fwenguang 已提交
84 85 86 87
IF(WITH_MLU)
    set(MLU_CTX_DEPS mlu_device_context)
ENDIF()

T
tensor-tang 已提交
88 89 90 91 92
IF(WITH_MKLDNN)
    set(MKLDNN_CTX_DEPS mkldnn)
ELSE()
    set(MKLDNN_CTX_DEPS)
ENDIF()
93

F
fwenguang 已提交
94
IF(WITH_ASCEND_CL OR WITH_MLU)
95
cc_library(stream_callback_manager SRCS stream_callback_manager.cc DEPS simple_threadpool enforce)
96 97
ENDIF()

S
sneaxiy 已提交
98
IF(WITH_GPU)
99
    nv_library(stream_callback_manager SRCS stream_callback_manager.cc DEPS simple_threadpool enforce)
100 101 102 103 104 105
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 已提交
106
  set(STREAM_CALLBACK_DEPS stream_callback_manager)
107 108
ELSEIF(WITH_ASCEND_CL)
  set(STREAM_CALLBACK_DEPS stream_callback_manager)
S
sneaxiy 已提交
109 110 111 112
ELSE()
  set(STREAM_CALLBACK_DEPS)
ENDIF()

113 114 115 116
if(WITH_GLOO)
    cc_library(gloo_context SRCS gloo_context.cc DEPS framework_proto gloo_wrapper enforce)
endif()

117 118
cc_library(cudnn_workspace_helper SRCS cudnn_workspace_helper.cc DEPS boost)

119
# memcpy depends on device_context, here add deps individually for
Q
qijun 已提交
120
# avoiding cycle dependencies
121
cc_library(device_context SRCS device_context.cc init.cc DEPS simple_threadpool malloc xxhash ${STREAM_CALLBACK_DEPS}
122
    place pten_place eigen3 stringpiece cpu_helper cpu_info framework_proto ${IPU_CTX_DEPS} ${GPU_CTX_DEPS} ${NPU_CTX_DEPS} ${MKLDNN_CTX_DEPS}
W
Wilber 已提交
123
    ${dgc_deps} dlpack cudnn_workspace_helper ${XPU_CTX_DEPS} ${MLU_CTX_DEPS} cpu_context)
124

125 126 127 128
cc_library(collective_helper SRCS collective_helper.cc gen_comm_id_helper.cc DEPS framework_proto device_context enforce)
if(WITH_ASCEND_CL)
    target_link_libraries(collective_helper npu_collective_helper)
endif()
129

130
if(WITH_GPU OR WITH_ROCM)
131
    target_link_libraries(device_context gpu_resource_pool)
132 133
endif()

134 135 136 137
if(WITH_ASCEND_CL)
    target_link_libraries(device_context npu_resource_pool)
endif()

138 139
cc_test(init_test SRCS init_test.cc DEPS device_context)

140 141 142 143
# 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")
144 145


146
if(WITH_GPU)
147 148 149 150
  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)

151 152 153 154 155
  nv_test(device_context_test SRCS device_context_test.cu DEPS device_context gpu_info)
  nv_test(transform_test SRCS transform_test.cu DEPS memory place device_context)
endif()

if(WITH_ROCM)
156 157 158 159
  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)

160 161 162
  hip_test(device_context_test SRCS device_context_test.cu DEPS device_context gpu_info)
  hip_test(transform_test SRCS transform_test.cu DEPS memory place device_context)
endif()
D
dangqingqing 已提交
163

164
cc_library(timer SRCS timer.cc)
165
cc_test(timer_test SRCS timer_test.cc DEPS timer)
166

D
dongdaxiang 已提交
167
cc_library(lodtensor_printer SRCS lodtensor_printer.cc DEPS ddim place tensor scope lod_tensor variable_helper framework_proto)
D
dongdaxiang 已提交
168
cc_test(lodtensor_printer_test SRCS lodtensor_printer_test.cc DEPS lodtensor_printer)
D
dongdaxiang 已提交
169

L
liutiexing 已提交
170 171
add_subdirectory(profiler)

172
cc_library(device_tracer SRCS device_tracer.cc DEPS boost profiler_proto framework_proto ${GPU_CTX_DEPS})
173
if(WITH_GPU)
L
liutiexing 已提交
174
  nv_library(profiler SRCS profiler.cc profiler.cu DEPS host_event_recorder os_info device_tracer gpu_info enforce dynload_cuda)
175
  nv_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info gpu_info place)
176
elseif(WITH_ROCM)
L
liutiexing 已提交
177
  hip_library(profiler SRCS profiler.cc profiler.cu DEPS host_event_recorder os_info device_tracer gpu_info enforce)
178
  hip_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info gpu_info place)
179
else()
L
liutiexing 已提交
180
  cc_library(profiler SRCS profiler.cc DEPS host_event_recorder os_info device_tracer enforce)
181
  cc_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info place)
182
endif()
183

T
Tao Luo 已提交
184
cc_test(profiler_test SRCS profiler_test.cc DEPS profiler)
185
cc_test(float16_test SRCS float16_test.cc DEPS lod_tensor)
186
cc_test(bfloat16_test SRCS bfloat16_test.cc DEPS lod_tensor)
187
cc_test(complex_test SRCS complex_test.cc DEPS lod_tensor)
188

189 190
IF(WITH_GPU)
  nv_test(float16_gpu_test SRCS float16_test.cu DEPS lod_tensor)
191
  nv_test(bfloat16_gpu_test SRCS bfloat16_test.cu DEPS lod_tensor)
192
  nv_test(complex_gpu_test SRCS complex_test.cu DEPS lod_tensor)
193 194 195
  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()
196

197 198 199 200 201
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()
202

203 204
if(NOT APPLE AND NOT WIN32)
  cc_library(device_code SRCS device_code.cc DEPS device_context)
205
  if(WITH_GPU OR WITH_ROCM)
206 207
    cc_test(device_code_test SRCS device_code_test.cc DEPS device_code lod_tensor)
  endif()
208
endif()