CMakeLists.txt 5.3 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
proto_library(cuda_error_proto SRCS cuda_error.proto)
X
Xin Pan 已提交
4

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

26 27
cc_library(flags SRCS flags.cc DEPS gflags) 

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

31
cc_library(enforce INTERFACE SRCS enforce.cc DEPS flags errors cuda_error_proto)
Q
Qiao Longfei 已提交
32 33
cc_test(enforce_test SRCS enforce_test.cc DEPS stringpiece enforce)

T
tensor-tang 已提交
34 35 36 37 38
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 已提交
39
cc_test(cpu_info_test SRCS cpu_info_test.cc DEPS cpu_info)
L
liaogang 已提交
40

Q
Qiao Longfei 已提交
41
nv_library(gpu_info SRCS gpu_info.cc DEPS gflags glog enforce)
42

T
Tao Luo 已提交
43
cc_library(place SRCS place.cc DEPS enforce boost)
L
liaogang 已提交
44
cc_test(place_test SRCS place_test.cc DEPS place glog gflags)
L
liaogang 已提交
45

L
liaogang 已提交
46
add_subdirectory(dynload)
47
add_subdirectory(stream)
L
liaogang 已提交
48

T
tensor-tang 已提交
49 50 51
cc_library(cpu_helper SRCS cpu_helper.cc DEPS cblas enforce)
cc_test(cpu_helper_test SRCS cpu_helper_test.cc DEPS cpu_helper)

52
set(dgc_deps "")
G
gongweibao 已提交
53 54 55 56
IF(WITH_DGC)
    set(dgc_deps dgc)
ENDIF()

Q
qijun 已提交
57
IF(WITH_GPU)
58
    set(GPU_CTX_DEPS dynload_cuda dynamic_loader cuda_stream)
Q
qijun 已提交
59 60
ENDIF()

T
tensor-tang 已提交
61 62 63 64 65 66
IF(WITH_MKLDNN)
    set(MKLDNN_CTX_DEPS mkldnn)
ELSE()
    set(MKLDNN_CTX_DEPS)
ENDIF()

S
sneaxiy 已提交
67 68 69 70 71 72 73
nv_library(stream_callback_manager SRCS stream_callback_manager.cc DEPS simple_threadpool enforce) 
IF(WITH_GPU)
  set(STREAM_CALLBACK_DEPS stream_callback_manager)
ELSE()
  set(STREAM_CALLBACK_DEPS)
ENDIF()

74 75 76 77
if(WITH_GLOO)
    cc_library(gloo_context SRCS gloo_context.cc DEPS framework_proto gloo_wrapper enforce)
endif()

78 79
cc_library(cudnn_workspace_helper SRCS cudnn_workspace_helper.cc DEPS boost)

80
# memcpy depends on device_context, here add deps individually for
Q
qijun 已提交
81
# avoiding cycle dependencies
82
cc_library(device_context SRCS device_context.cc init.cc DEPS simple_threadpool malloc xxhash ${STREAM_CALLBACK_DEPS}
83
    place eigen3 stringpiece cpu_helper cpu_info framework_proto ${GPU_CTX_DEPS} ${MKLDNN_CTX_DEPS}
84
    ${dgc_deps} dlpack cudnn_workspace_helper)
85

86
cc_library(collective_helper SRCS collective_helper.cc DEPS framework_proto  device_context enforce)
87

88 89 90 91 92
if(WITH_GPU)
    cc_library(cuda_resource_pool SRCS cuda_resource_pool.cc DEPS gpu_info)
    target_link_libraries(device_context cuda_resource_pool)
endif()

P
peizhilin 已提交
93 94 95 96 97 98 99
if(WIN32)
    if(WITH_GPU AND NOT WITH_DSO)
        get_property(cuda_modules GLOBAL PROPERTY CUDA_MODULES)
        target_link_libraries(device_context ${cuda_modules})
    endif(WITH_GPU AND NOT WITH_DSO)
endif(WIN32)

D
dzhwinter 已提交
100
nv_test(device_context_test SRCS device_context_test.cu DEPS device_context gpu_info)
101

102 103
cc_test(init_test SRCS init_test.cc DEPS device_context)

104
nv_test(cudnn_helper_test SRCS cudnn_helper_test.cc DEPS dynload_cuda)
105
nv_test(cudnn_desc_test SRCS cudnn_desc_test.cc DEPS dynload_cuda)
Y
Yi Wang 已提交
106
nv_test(transform_test SRCS transform_test.cu DEPS memory place device_context)
D
dangqingqing 已提交
107

108
cc_library(timer SRCS timer.cc)
109
cc_test(timer_test SRCS timer_test.cc DEPS timer)
110

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

114
cc_library(device_tracer SRCS device_tracer.cc DEPS boost profiler_proto framework_proto ${GPU_CTX_DEPS})
115
if(WITH_GPU)
116
  nv_library(profiler SRCS profiler.cc profiler.cu DEPS device_tracer gpu_info enforce)
117 118
  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)
119
else()
120 121
  cc_library(profiler SRCS profiler.cc DEPS device_tracer enforce)
  cc_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info place)
122
endif()
D
dangqingqing 已提交
123
cc_test(profiler_test SRCS profiler_test.cc DEPS profiler)
124

125 126
nv_test(float16_gpu_test SRCS float16_test.cu DEPS lod_tensor)
cc_test(float16_test SRCS float16_test.cc DEPS lod_tensor)
127

128 129
nv_test(test_limit_gpu_memory SRCS test_limit_gpu_memory.cu DEPS gpu_info flags)

Y
Yu Yang 已提交
130
nv_library(cuda_device_guard SRCS cuda_device_guard.cc DEPS gpu_info)
131

132 133 134 135 136
if(NOT APPLE AND NOT WIN32)
  cc_library(device_code SRCS device_code.cc DEPS device_context)
  if(WITH_GPU)
    cc_test(device_code_test SRCS device_code_test.cc DEPS device_code lod_tensor)
  endif()
137
endif()