CMakeLists.txt 4.2 KB
Newer Older
P
peizhilin 已提交
1
proto_library(profiler_proto SRCS profiler.proto DEPS framework_proto simple_threadpool)
X
Xin Pan 已提交
2 3 4 5 6 7
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)

W
wopeizl 已提交
8
if (NOT WIN32)
X
Xin Pan 已提交
9
add_custom_command(TARGET profiler_py_proto POST_BUILD
10 11
        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 已提交
12 13
        COMMENT "Copy generated python proto into directory paddle/fluid/proto/profiler."
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
W
wopeizl 已提交
14 15 16 17 18 19 20
else(NOT WIN32)
string(REPLACE "/" "\\" proto_dstpath "${PADDLE_BINARY_DIR}/python/paddle/fluid/proto/profiler/")
add_custom_command(TARGET profiler_py_proto POST_BUILD
        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})
D
dzhwinter 已提交
21
endif(NOT WIN32)
22

Q
Qiao Longfei 已提交
23
if(WITH_GPU)
24
  nv_library(enforce SRCS enforce.cc)
Q
Qiao Longfei 已提交
25 26 27 28 29
else()
  cc_library(enforce SRCS enforce.cc)
endif()
cc_test(enforce_test SRCS enforce_test.cc DEPS stringpiece enforce)

T
tensor-tang 已提交
30 31 32 33 34
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 已提交
35
cc_test(cpu_info_test SRCS cpu_info_test.cc DEPS cpu_info)
L
liaogang 已提交
36

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

T
Tao Luo 已提交
39
cc_library(place SRCS place.cc DEPS enforce boost)
L
liaogang 已提交
40
cc_test(place_test SRCS place_test.cc DEPS place glog gflags)
L
liaogang 已提交
41

L
liaogang 已提交
42
add_subdirectory(dynload)
L
liaogang 已提交
43

T
tensor-tang 已提交
44 45 46
cc_library(cpu_helper SRCS cpu_helper.cc DEPS cblas enforce)
cc_test(cpu_helper_test SRCS cpu_helper_test.cc DEPS cpu_helper)

Q
qijun 已提交
47 48
IF(WITH_GPU)
    set(GPU_CTX_DEPS dynload_cuda dynamic_loader)
49
    set(dgc_deps dgc)
Q
qijun 已提交
50
ELSE()
51
    set(dgc_deps)
Q
qijun 已提交
52 53
ENDIF()

T
tensor-tang 已提交
54 55 56 57 58 59
IF(WITH_MKLDNN)
    set(MKLDNN_CTX_DEPS mkldnn)
ELSE()
    set(MKLDNN_CTX_DEPS)
ENDIF()

60 61
cc_library(temp_allocator SRCS temporary_allocator.cc DEPS  allocator_facade)

S
sneaxiy 已提交
62 63 64 65 66 67 68
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()

69
# memcpy depends on device_context, here add deps individually for
Q
qijun 已提交
70
# avoiding cycle dependencies
S
sneaxiy 已提交
71
cc_library(device_context SRCS device_context.cc init.cc DEPS simple_threadpool malloc ${STREAM_CALLBACK_DEPS}
72 73
    place eigen3 stringpiece cpu_helper cpu_info framework_proto ${GPU_CTX_DEPS} ${MKLDNN_CTX_DEPS}
    temp_allocator ${dgc_deps})
74

P
peizhilin 已提交
75 76 77 78 79 80 81
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 已提交
82
nv_test(device_context_test SRCS device_context_test.cu DEPS device_context gpu_info)
83

84 85
cc_test(init_test SRCS init_test.cc DEPS device_context)

86
nv_test(cudnn_helper_test SRCS cudnn_helper_test.cc DEPS dynload_cuda)
87
nv_test(cudnn_desc_test SRCS cudnn_desc_test.cc DEPS dynload_cuda)
Y
Yi Wang 已提交
88
nv_test(transform_test SRCS transform_test.cu DEPS memory place device_context)
D
dangqingqing 已提交
89

90
cc_library(timer SRCS timer.cc)
91
cc_test(timer_test SRCS timer_test.cc DEPS timer)
92

93
cc_library(device_tracer SRCS device_tracer.cc DEPS boost profiler_proto framework_proto ${GPU_CTX_DEPS})
94
if(WITH_GPU)
95
    nv_library(profiler SRCS profiler.cc profiler.cu DEPS device_tracer gpu_info enforce)
96
else()
97
    cc_library(profiler SRCS profiler.cc DEPS device_tracer enforce)
98
endif()
D
dangqingqing 已提交
99
cc_test(profiler_test SRCS profiler_test.cc DEPS profiler)
100

101 102
nv_test(float16_gpu_test SRCS float16_test.cu DEPS lod_tensor)
cc_test(float16_test SRCS float16_test.cc DEPS lod_tensor)
103 104 105 106

IF(WITH_GPU)
  nv_test(cuda_helper_test SRCS cuda_helper_test.cu)
ENDIF()
Y
Yu Yang 已提交
107
nv_library(cuda_device_guard SRCS cuda_device_guard.cc DEPS gpu_info)
108 109

if(WITH_GPU)
X
Xin Pan 已提交
110
    nv_test(temporal_allocator_test SRCS temporary_allocator_test.cc DEPS temp_allocator tensor operator)
111
else()
X
Xin Pan 已提交
112
    cc_test(temporal_allocator_test SRCS temporary_allocator_test.cc DEPS temp_allocator tensor operator)
113
endif()