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

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

11
set(enforce_deps phi)
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)
30 31 32
cc_test(
  os_info_test
  SRCS os_info_test.cc
33
  DEPS phi)
34 35 36 37

cc_library(
  place
  SRCS place.cc
38
  DEPS enforce phi)
39 40 41
cc_test(
  place_test
  SRCS place_test.cc
42
  DEPS place glog phi)
43 44 45 46 47 48

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

50
add_subdirectory(device)
L
liaogang 已提交
51
add_subdirectory(dynload)
L
liaogang 已提交
52

53 54 55 56 57 58 59 60
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 已提交
61

62
set(dgc_deps "")
63 64 65 66 67
if(WITH_DGC)
  set(dgc_deps dgc)
endif()

if(WITH_GPU OR WITH_ROCM)
L
Leo Chen 已提交
68
  set(GPU_CTX_DEPS dynload_cuda dynamic_loader)
69 70
endif()

71 72 73 74
if(WITH_XPU)
  set(XPU_CTX_DEPS dynload_xpti dynamic_loader)
endif()

75 76 77 78
if(WITH_IPU)
  set(IPU_CTX_DEPS ipu_info)
else()
  set(IPU_CTX_DEPS)
79
endif()
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94

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 已提交
95
  set(STREAM_CALLBACK_DEPS stream_callback_manager)
96
else()
S
sneaxiy 已提交
97
  set(STREAM_CALLBACK_DEPS)
98
endif()
S
sneaxiy 已提交
99

100
if(WITH_GLOO)
101 102 103 104
  cc_library(
    gloo_context
    SRCS gloo_context.cc
    DEPS framework_proto gloo_wrapper enforce)
105 106
endif()

107
# separate init from device_context to avoid cycle dependencies
108 109 110
cc_library(
  init
  SRCS init.cc
111
  DEPS device_context phi memcpy pd_dialect ir)
112

113
# memcpy depends on device_context, here add deps individually for
Q
qijun 已提交
114
# avoiding cycle dependencies
115

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
cc_library(
  device_context
  SRCS device_context.cc
  DEPS simple_threadpool
       malloc
       xxhash
       ${STREAM_CALLBACK_DEPS}
       place
       eigen3
       cpu_helper
       framework_proto
       ${IPU_CTX_DEPS}
       ${GPU_CTX_DEPS}
       ${MKLDNN_CTX_DEPS}
       ${dgc_deps}
       dlpack
132 133
       phi
       ${XPU_CTX_DEPS})
134

135 136 137 138
cc_library(
  collective_helper
  SRCS collective_helper.cc gen_comm_id_helper.cc
  DEPS framework_proto device_context enforce)
139

140
if(WITH_GPU OR WITH_ROCM)
141
  target_link_libraries(device_context gpu_resource_pool)
142
endif()
143 144 145

if(WITH_XPU)
  target_link_libraries(device_context xpu_resource_pool)
146 147
endif()

148 149 150 151
if(WITH_CUSTOM_DEVICE)
  target_link_libraries(device_context custom_device_resource_pool)
endif()

152 153 154 155
cc_test(
  init_test
  SRCS init_test.cc
  DEPS device_context)
156

157 158
# Manage all device event library
set(DEVICE_EVENT_LIBS)
159 160 161 162 163 164 165
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")
166

167
if(WITH_GPU)
168 169 170 171 172 173 174
  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")
175 176 177 178 179 180 181 182 183 184 185
  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()
186 187 188 189 190
  if(WITH_CUSTOM_DEVICE)
    nv_library(
      cuda_graph_with_memory_pool
      SRCS cuda_graph_with_memory_pool.cc
      DEPS ${DEVICE_EVENT_LIBS} device_event_custom_device device_context
191
           allocator phi)
192 193 194 195
  else()
    nv_library(
      cuda_graph_with_memory_pool
      SRCS cuda_graph_with_memory_pool.cc
196
      DEPS ${DEVICE_EVENT_LIBS} device_context allocator phi)
197
  endif()
198 199 200 201
  nv_test(
    device_context_test
    SRCS device_context_test.cu
    DEPS device_context gpu_info)
Y
Yuang Liu 已提交
202 203 204 205
  nv_test(
    device_context_test_cuda_graph
    SRCS device_context_test_cuda_graph.cu
    DEPS device_context gpu_info cuda_graph_with_memory_pool)
206 207 208 209 210
else()
  cc_library(
    cuda_graph_with_memory_pool
    SRCS cuda_graph_with_memory_pool.cc
    DEPS device_context allocator)
211 212 213
endif()

if(WITH_ROCM)
214 215 216 217 218 219 220
  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")
221 222 223 224 225 226 227 228 229 230 231
  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()
232 233 234 235
  hip_test(
    device_context_test
    SRCS device_context_test.cu
    DEPS device_context gpu_info)
236
endif()
D
dangqingqing 已提交
237

238
cc_library(timer SRCS timer.cc)
239 240 241 242 243 244 245 246
cc_test(
  timer_test
  SRCS timer_test.cc
  DEPS timer)

cc_library(
  lodtensor_printer
  SRCS lodtensor_printer.cc
247
  DEPS phi
248 249 250 251 252 253 254 255 256 257
       place
       tensor
       scope
       lod_tensor
       variable_helper
       framework_proto)
cc_test(
  lodtensor_printer_test
  SRCS lodtensor_printer_test.cc
  DEPS lodtensor_printer)
D
dongdaxiang 已提交
258

L
liutiexing 已提交
259 260
add_subdirectory(profiler)

261
if(WITH_GPU)
262 263 264
  nv_library(
    profiler
    SRCS profiler.cc profiler.cu
265
    DEPS phi
266 267 268 269
         gpu_info
         enforce
         dynload_cuda
         new_profiler
270 271
         stats
         op_proto_maker
272
         shape_inference)
273
elseif(WITH_ROCM)
274 275 276
  hip_library(
    profiler
    SRCS profiler.cc profiler.cu
277
    DEPS phi
278 279 280 281 282
         gpu_info
         enforce
         new_profiler
         stats
         op_proto_maker
283
         shape_inference)
284 285 286 287 288 289 290 291 292 293 294
elseif(WITH_XPU)
  cc_library(
    profiler
    SRCS profiler.cc
    DEPS phi
         enforce
         dynload_xpti
         new_profiler
         stats
         op_proto_maker
         shape_inference)
295
else()
296 297 298
  cc_library(
    profiler
    SRCS profiler.cc
299
    DEPS phi enforce new_profiler stats op_proto_maker shape_inference)
300
endif()
301

302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
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)
318

319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
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
335
    DEPS gpu_info phi)
336 337 338 339 340
  nv_library(
    cuda_device_guard
    SRCS cuda_device_guard.cc
    DEPS gpu_info)
endif()
341

342 343 344 345 346 347 348 349
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
350
    DEPS gpu_info phi)
351 352 353 354 355
  hip_library(
    cuda_device_guard
    SRCS cuda_device_guard.cc
    DEPS gpu_info)
endif()
356

357
if(NOT APPLE AND NOT WIN32)
358
  if(WITH_GPU OR WITH_ROCM)
359 360 361
    cc_test(
      device_code_test
      SRCS device_code_test.cc
362
      DEPS phi lod_tensor)
363
  endif()
364
endif()
365 366 367 368 369 370 371 372 373 374

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()
375 376 377 378 379 380 381 382 383

cc_library(
  init_phi
  SRCS init_phi.cc
  DEPS init)

cc_test(
  init_phi_test
  SRCS init_phi_test.cc
384
  DEPS phi init_phi)