CMakeLists.txt 8.2 KB
Newer Older
1 2 3 4
cc_library(
  denormal
  SRCS denormal.cc
  DEPS)
5

6 7 8 9
cc_test(
  errors_test
  SRCS errors_test.cc
  DEPS errors enforce)
10

R
Ruibiao Chen 已提交
11
set(enforce_deps flags errors flags phi_enforce)
12
if(WITH_GPU)
13
  set(enforce_deps ${enforce_deps} external_error_proto)
14
endif()
F
fwenguang 已提交
15

16 17 18 19
cc_library(
  enforce INTERFACE
  SRCS enforce.cc
  DEPS ${enforce_deps})
H
hutuxian 已提交
20
cc_library(monitor SRCS monitor.cc)
21 22 23
cc_test(
  enforce_test
  SRCS enforce_test.cc
L
Leo Chen 已提交
24
  DEPS enforce)
Q
Qiao Longfei 已提交
25

26 27 28
cc_test(
  cpu_info_test
  SRCS cpu_info_test.cc
29
  DEPS phi_backends)
30 31 32
cc_test(
  os_info_test
  SRCS os_info_test.cc
33
  DEPS phi_os_info)
34 35 36 37 38

if(WITH_GPU)
  nv_library(
    cuda_graph_with_memory_pool
    SRCS cuda_graph_with_memory_pool.cc
39
    DEPS device_context allocator phi_backends)
40 41 42 43
else()
  cc_library(
    cuda_graph_with_memory_pool
    SRCS cuda_graph_with_memory_pool.cc
L
Leo Chen 已提交
44
    DEPS device_context allocator)
45 46 47 48 49
endif()

cc_library(
  place
  SRCS place.cc
R
Ruibiao Chen 已提交
50
  DEPS enforce phi_place)
51 52 53 54 55 56 57 58 59 60
cc_test(
  place_test
  SRCS place_test.cc
  DEPS place glog gflags)

if(WITH_MKLDNN)
  set(MKLDNN_CTX_DEPS mkldnn)
else()
  set(MKLDNN_CTX_DEPS)
endif()
61

62
add_subdirectory(device)
L
liaogang 已提交
63
add_subdirectory(dynload)
L
liaogang 已提交
64

65 66 67 68 69 70 71 72
cc_library(
  cpu_helper
  SRCS cpu_helper.cc
  DEPS cblas enforce)
cc_test(
  cpu_helper_test
  SRCS cpu_helper_test.cc
  DEPS cpu_helper)
T
tensor-tang 已提交
73

74
set(dgc_deps "")
75 76 77 78 79
if(WITH_DGC)
  set(dgc_deps dgc)
endif()

if(WITH_GPU OR WITH_ROCM)
L
Leo Chen 已提交
80
  set(GPU_CTX_DEPS dynload_cuda dynamic_loader)
81 82 83 84 85 86
endif()

if(WITH_IPU)
  set(IPU_CTX_DEPS ipu_info)
else()
  set(IPU_CTX_DEPS)
87
endif()
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

if(WITH_ASCEND_CL)
  set(NPU_CTX_DEPS npu_stream npu_info)
endif()

if(WITH_MLU)
  set(MLU_CTX_DEPS mlu_device_context)
endif()

if(WITH_ASCEND_CL OR WITH_MLU)
  cc_library(
    stream_callback_manager
    SRCS stream_callback_manager.cc
    DEPS simple_threadpool enforce)
endif()

if(WITH_GPU)
  nv_library(
    stream_callback_manager
    SRCS stream_callback_manager.cc
    DEPS simple_threadpool enforce)
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 已提交
118
  set(STREAM_CALLBACK_DEPS stream_callback_manager)
119
elseif(WITH_ASCEND_CL)
120
  set(STREAM_CALLBACK_DEPS stream_callback_manager)
121
else()
S
sneaxiy 已提交
122
  set(STREAM_CALLBACK_DEPS)
123
endif()
S
sneaxiy 已提交
124

125
if(WITH_GLOO)
126 127 128 129
  cc_library(
    gloo_context
    SRCS gloo_context.cc
    DEPS framework_proto gloo_wrapper enforce)
130 131
endif()

132
# separate init from device_context to avoid cycle dependencies
133 134 135
cc_library(
  init
  SRCS init.cc
136
  DEPS device_context custom_kernel context_pool memcpy)
137

138
# memcpy depends on device_context, here add deps individually for
Q
qijun 已提交
139
# avoiding cycle dependencies
140

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
cc_library(
  device_context
  SRCS device_context.cc
  DEPS simple_threadpool
       malloc
       xxhash
       ${STREAM_CALLBACK_DEPS}
       place
       phi_place
       eigen3
       cpu_helper
       framework_proto
       ${IPU_CTX_DEPS}
       ${GPU_CTX_DEPS}
       ${NPU_CTX_DEPS}
       ${MKLDNN_CTX_DEPS}
       ${dgc_deps}
       dlpack
       cudnn_workspace_helper
       ${XPU_CTX_DEPS}
       ${MLU_CTX_DEPS}
162 163
       phi_backends
       phi_device_context
164
       generator)
165

166 167 168 169
cc_library(
  collective_helper
  SRCS collective_helper.cc gen_comm_id_helper.cc
  DEPS framework_proto device_context enforce)
170
if(WITH_ASCEND_CL)
171
  target_link_libraries(collective_helper npu_collective_helper)
172
endif()
173

174
if(WITH_CNCL)
175
  target_link_libraries(collective_helper mlu_collective_helper)
176 177
endif()

178
if(WITH_GPU OR WITH_ROCM)
179
  target_link_libraries(device_context gpu_resource_pool)
180
endif()
181

182
if(WITH_ASCEND_CL)
183
  target_link_libraries(device_context npu_resource_pool)
184 185
endif()

186 187
if(WITH_XPU)
  target_link_libraries(device_context xpu_resource_pool)
188 189
endif()

190 191
if(WITH_MLU)
  target_link_libraries(device_context mlu_resource_pool)
192 193
endif()

194 195 196 197
if(WITH_CUSTOM_DEVICE)
  target_link_libraries(device_context custom_device_resource_pool)
endif()

198 199 200 201
cc_test(
  init_test
  SRCS init_test.cc
  DEPS device_context)
202

203 204
# Manage all device event library
set(DEVICE_EVENT_LIBS)
205 206 207 208 209 210 211
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")
212

213 214 215 216 217 218 219 220 221 222
if(WITH_ASCEND_CL)
  cc_library(
    device_event_npu
    SRCS device_event_npu.cc
    DEPS device_event_base npu_resource_pool)
  set(DEVICE_EVENT_LIBS
      device_event_npu
      CACHE INTERNAL "device event libs")
endif()

223
if(WITH_GPU)
224 225 226 227 228 229 230
  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")
231 232 233 234 235 236 237 238 239 240 241
  if(WITH_CUSTOM_DEVICE)
    nv_test(
      device_event_test
      SRCS device_event_test.cc
      DEPS device_event_gpu device_event_custom_device)
  else()
    nv_test(
      device_event_test
      SRCS device_event_test.cc
      DEPS device_event_gpu)
  endif()
242 243 244 245
  nv_test(
    device_context_test
    SRCS device_context_test.cu
    DEPS device_context gpu_info)
Y
Yuang Liu 已提交
246 247 248 249
  nv_test(
    device_context_test_cuda_graph
    SRCS device_context_test_cuda_graph.cu
    DEPS device_context gpu_info cuda_graph_with_memory_pool)
250 251 252
endif()

if(WITH_ROCM)
253 254 255 256 257 258 259
  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")
260 261 262 263 264 265 266 267 268 269 270
  if(WITH_CUSTOM_DEVICE)
    hip_test(
      device_event_test
      SRCS device_event_test.cc
      DEPS device_event_gpu device_event_custom_device)
  else()
    hip_test(
      device_event_test
      SRCS device_event_test.cc
      DEPS device_event_gpu)
  endif()
271 272 273 274
  hip_test(
    device_context_test
    SRCS device_context_test.cu
    DEPS device_context gpu_info)
275
endif()
D
dangqingqing 已提交
276

277
cc_library(timer SRCS timer.cc)
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
cc_test(
  timer_test
  SRCS timer_test.cc
  DEPS timer)

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

L
liutiexing 已提交
298 299
add_subdirectory(profiler)

300
if(WITH_GPU)
301 302 303
  nv_library(
    profiler
    SRCS profiler.cc profiler.cu
304 305
    DEPS phi_os_info
         phi_device_tracer
306 307 308 309
         gpu_info
         enforce
         dynload_cuda
         new_profiler
310 311
         stats
         op_proto_maker
312 313
         shape_inference
         phi_profiler)
314
elseif(WITH_ROCM)
315 316 317
  hip_library(
    profiler
    SRCS profiler.cc profiler.cu
318 319
    DEPS phi_os_info
         phi_device_tracer
320 321 322 323 324
         gpu_info
         enforce
         new_profiler
         stats
         op_proto_maker
325 326
         shape_inference
         phi_profiler)
327
else()
328 329 330
  cc_library(
    profiler
    SRCS profiler.cc
331 332
    DEPS phi_os_info
         phi_device_tracer
333 334 335 336
         enforce
         new_profiler
         stats
         op_proto_maker
337 338
         shape_inference
         phi_profiler)
339
endif()
340

341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
cc_test(
  profiler_test
  SRCS profiler_test.cc
  DEPS profiler)
cc_test(
  float16_test
  SRCS float16_test.cc
  DEPS lod_tensor)
cc_test(
  bfloat16_test
  SRCS bfloat16_test.cc
  DEPS lod_tensor)
cc_test(
  complex_test
  SRCS complex_test.cc
  DEPS lod_tensor)
357

358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
if(WITH_GPU)
  nv_test(
    float16_gpu_test
    SRCS float16_test.cu
    DEPS lod_tensor)
  nv_test(
    bfloat16_gpu_test
    SRCS bfloat16_test.cu
    DEPS lod_tensor)
  nv_test(
    complex_gpu_test
    SRCS complex_test.cu
    DEPS lod_tensor)
  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()
380

381 382 383 384 385 386 387 388 389 390 391 392 393 394
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()
395

396
if(NOT APPLE AND NOT WIN32)
397 398 399 400
  cc_library(
    device_code
    SRCS device_code.cc
    DEPS device_context)
401
  if(WITH_GPU OR WITH_ROCM)
402 403 404 405
    cc_test(
      device_code_test
      SRCS device_code_test.cc
      DEPS device_code lod_tensor)
406
  endif()
407
endif()
408 409 410 411 412 413 414 415 416 417

if(WITH_CUSTOM_DEVICE)
  cc_library(
    device_event_custom_device
    SRCS device_event_custom_device.cc
    DEPS device_event_base custom_device_resource_pool)
  set(DEVICE_EVENT_LIBS
      ${DEVICE_EVENT_LIBS} device_event_custom_device
      CACHE INTERNAL "device event libs")
endif()