1
+ include (CMakeParseArguments )
1
2
INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIR} )
2
3
INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR} /src/basics )
3
4
INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR} /src/convert )
@@ -13,36 +14,37 @@ SET (TEST_LINK_LIBS ${BLAS_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${Boost_LIBRARIES
13
14
SET (CUDA_TEST_DEVICE "0" CACHE STRING "Which CUDA device should the tests be run on, if multiple devices are present." )
14
15
add_definitions (-DCUDA_TEST_DEVICE=${CUDA_TEST_DEVICE} )
15
16
16
- ADD_EXECUTABLE ( test_tensor tensor.cpp )
17
- TARGET_LINK_LIBRARIES ( test_tensor ${TEST_LINK_LIBS} )
18
-
19
- ADD_EXECUTABLE ( test_alloc alloc.cpp )
20
- TARGET_LINK_LIBRARIES ( test_alloc ${TEST_LINK_LIBS} )
21
-
22
- ADD_EXECUTABLE ( test_tensor_serialization tensor_serialization.cpp )
23
- TARGET_LINK_LIBRARIES ( test_tensor_serialization ${TEST_LINK_LIBS} )
24
-
25
- ADD_EXECUTABLE ( test_basic basic.cpp )
26
- TARGET_LINK_LIBRARIES ( test_basic ${TEST_LINK_LIBS} )
27
-
28
- ADD_EXECUTABLE ( test_convert convert.cpp )
29
- TARGET_LINK_LIBRARIES ( test_convert ${TEST_LINK_LIBS} )
30
-
31
- ADD_EXECUTABLE ( test_tensor_op tensor_op.cpp )
32
- TARGET_LINK_LIBRARIES ( test_tensor_op ${TEST_LINK_LIBS} )
33
-
34
- ADD_EXECUTABLE ( test_theano_ops lib_theano_ops.cpp )
35
- TARGET_LINK_LIBRARIES ( test_theano_ops ${TEST_LINK_LIBS} )
36
-
37
- ADD_EXECUTABLE ( test_tensor_op_speed tensor_op_speed.cpp )
38
- TARGET_LINK_LIBRARIES ( test_tensor_op_speed ${TEST_LINK_LIBS} )
39
-
40
- ADD_EXECUTABLE ( test_optimize optimize.cpp )
41
- TARGET_LINK_LIBRARIES ( test_optimize ${TEST_LINK_LIBS} )
42
-
43
- ADD_EXECUTABLE ( test_mat_op matrix_op.cpp )
44
- #TARGET_LINK_LIBRARIES( test_mat_op cuv_basics cuv_tools cuv_convert cuv_tensor_ops cuv_matrix_ops cuv_random ${CUDA_CUBLAS_LIBRARIES} )
45
- TARGET_LINK_LIBRARIES ( test_mat_op ${TEST_LINK_LIBS} )
17
+ SET (CUV_TESTS "" )
18
+ SET (CUV_SPEED_TESTS "" )
19
+ FUNCTION (cuv_add_test )
20
+ set (options SPEEDTEST )
21
+ set (oneValueArgs NAME )
22
+ set (multiValueArgs SOURCES )
23
+ cmake_parse_arguments (CT "${options} " "${oneValueArgs} " "${multiValueArgs} " ${ARGN} )
24
+ #MESSAGE(STATUS "cuv_add_test: ${CT_NAME} <-- ${CT_SOURCES} (${TEST_LINK_LIBS})")
25
+
26
+ ADD_EXECUTABLE (${CT_NAME} ${CT_SOURCES} )
27
+ TARGET_LINK_LIBRARIES ( ${CT_NAME} ${TEST_LINK_LIBS} )
28
+ IF (CT_SPEEDTEST )
29
+ # Speed tests tend to run forever, so they should not be included in
30
+ # ctest runs.
31
+ SET (CUV_SPEED_TESTS ${CUV_SPEED_TESTS} ${CT_NAME} PARENT_SCOPE )
32
+ ELSE ()
33
+ SET (CUV_TESTS ${CUV_TESTS} ${CT_NAME} PARENT_SCOPE )
34
+ ADD_TEST (${CT_NAME} "${CMAKE_CURRENT_BINARY_DIR} /${CT_NAME} " )
35
+ ENDIF ()
36
+ ENDFUNCTION (cuv_add_test )
37
+
38
+ cuv_add_test ( NAME tensor SOURCES tensor.cpp )
39
+ cuv_add_test ( NAME alloc SOURCES alloc.cpp )
40
+ cuv_add_test ( NAME tensor_serialization SOURCES tensor_serialization.cpp )
41
+ cuv_add_test ( NAME basic SOURCES basic.cpp )
42
+ cuv_add_test ( NAME convert SOURCES convert.cpp )
43
+ cuv_add_test ( NAME tensor_op SOURCES tensor_op.cpp )
44
+ cuv_add_test ( NAME theano_ops SOURCES lib_theano_ops.cpp )
45
+ cuv_add_test ( NAME tensor_op_speed SOURCES tensor_op_speed.cpp SPEEDTEST )
46
+ cuv_add_test ( NAME optimize SOURCES optimize.cpp )
47
+ cuv_add_test ( NAME mat_op SOURCES matrix_op.cpp )
46
48
47
49
#ADD_EXECUTABLE( test_dia_mat dia_mat.cpp )
48
50
#TARGET_LINK_LIBRARIES( test_dia_mat ${TEST_LINK_LIBS})
@@ -59,84 +61,32 @@ TARGET_LINK_LIBRARIES( test_mat_op ${TEST_LINK_LIBS})
59
61
#ADD_EXECUTABLE( test_densedense_to_dia_speed densedense_to_dia_speed.cpp )
60
62
#TARGET_LINK_LIBRARIES( test_densedense_to_dia_speed ${TEST_LINK_LIBS})
61
63
62
- ADD_EXECUTABLE ( test_mat_op_speed matrix_op_speed.cpp )
63
- TARGET_LINK_LIBRARIES ( test_mat_op_speed ${TEST_LINK_LIBS} )
64
-
65
- ADD_EXECUTABLE ( test_conv_op conv_op.cpp )
66
- TARGET_LINK_LIBRARIES ( test_conv_op ${TEST_LINK_LIBS} )
67
-
68
- ADD_EXECUTABLE ( test_conv_op_speed conv_op_speed.cpp )
69
- TARGET_LINK_LIBRARIES ( test_conv_op_speed ${TEST_LINK_LIBS} )
70
-
71
- ADD_EXECUTABLE ( test_random random.cpp )
72
- TARGET_LINK_LIBRARIES ( test_random ${TEST_LINK_LIBS} )
73
-
74
- ADD_EXECUTABLE ( test_random_speed random_speed.cpp )
75
- TARGET_LINK_LIBRARIES ( test_random_speed ${TEST_LINK_LIBS} )
76
-
77
- ADD_EXECUTABLE ( test_memory memory.cpp )
78
- TARGET_LINK_LIBRARIES ( test_memory ${TEST_LINK_LIBS} )
79
-
80
- ADD_EXECUTABLE ( test_lib_rbm lib_rbm.cpp )
81
- TARGET_LINK_LIBRARIES ( test_lib_rbm ${TEST_LINK_LIBS} )
82
-
83
- ADD_EXECUTABLE ( test_lib_kmeans lib_kmeans.cpp )
84
- #TARGET_LINK_LIBRARIES( test_lib_kmeans cuv_basics cuv_tools cuv_convert cuv_tensor_ops cuv_matrix_ops cuv_kmeans ${CUDA_CUBLAS_LIBRARIES} )
85
- TARGET_LINK_LIBRARIES ( test_lib_kmeans ${TEST_LINK_LIBS} )
64
+ cuv_add_test ( NAME mat_op_speed SOURCES matrix_op_speed.cpp SPEEDTEST )
65
+ cuv_add_test ( NAME conv_op SOURCES conv_op.cpp )
66
+ cuv_add_test ( NAME conv_op_speed SOURCES conv_op_speed.cpp SPEEDTEST )
67
+ cuv_add_test ( NAME random SOURCES random.cpp )
68
+ cuv_add_test ( NAME random_speed SOURCES random_speed.cpp SPEEDTEST )
69
+ cuv_add_test ( NAME memory SOURCES memory.cpp )
70
+ cuv_add_test ( NAME lib_rbm SOURCES lib_rbm.cpp )
71
+ cuv_add_test ( NAME lib_kmeans SOURCES lib_kmeans.cpp )
86
72
87
73
IF (CUV_CIMG_BINDINGS )
88
74
FIND_PACKAGE ( PNG REQUIRED )
89
- ADD_EXECUTABLE ( test_lib_cimg cimg.cpp )
90
75
SET (TEST_LINK_LIBS ${TEST_LINK_LIBS} X11 pthread ${PNG_LIBRARIES} )
91
- TARGET_LINK_LIBRARIES ( test_lib_cimg ${TEST_LINK_LIBS} )
92
-
93
- ADD_EXECUTABLE ( test_lib_sep_conv lib_sep_conv.cpp )
94
- TARGET_LINK_LIBRARIES ( test_lib_sep_conv ${TEST_LINK_LIBS} )
95
-
96
- ADD_EXECUTABLE ( test_lib_intimg lib_intimg.cpp )
97
- TARGET_LINK_LIBRARIES ( test_lib_intimg ${TEST_LINK_LIBS} )
98
-
99
- ADD_EXECUTABLE ( test_nlmeans lib_nlmean.cpp )
100
- TARGET_LINK_LIBRARIES ( test_nlmeans ${TEST_LINK_LIBS} )
101
-
102
- ADD_EXECUTABLE ( test_hog lib_hog.cpp )
103
- TARGET_LINK_LIBRARIES ( test_hog ${TEST_LINK_LIBS} )
104
-
105
- FILE (COPY ${CMAKE_CURRENT_SOURCE_DIR} /data DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
106
76
77
+ cuv_add_test ( NAME lib_cimg SOURCES cimg.cpp )
78
+ cuv_add_test ( NAME lib_sep_conv SOURCES lib_sep_conv.cpp )
79
+ cuv_add_test ( NAME lib_intimg SOURCES lib_intimg.cpp )
80
+ cuv_add_test ( NAME nlmeans SOURCES lib_nlmean.cpp )
81
+ cuv_add_test ( NAME hog SOURCES lib_hog.cpp )
82
+ FILE (COPY ${CMAKE_CURRENT_SOURCE_DIR} /data DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
107
83
ENDIF (CUV_CIMG_BINDINGS )
108
84
109
85
110
86
if (PYTHONLIBS_FOUND )
111
- TARGET_LINK_LIBRARIES (test_theano_ops ${CUV_LIBRARIES} )
87
+ TARGET_LINK_LIBRARIES (test_theano_ops ${CUV_LIBRARIES} ${PYTHON_LIBS } )
112
88
endif (PYTHONLIBS_FOUND )
113
89
114
- ADD_TEST ( tensor_serialization "${CMAKE_BINARY_DIR} /src/tests/test_tensor_serialization" )
115
- ADD_TEST ( basics "${CMAKE_BINARY_DIR} /src/tests/test_basic" )
116
- ADD_TEST ( convert "${CMAKE_BINARY_DIR} /src/tests/test_convert" )
117
- ADD_TEST ( tensor_op "${CMAKE_BINARY_DIR} /src/tests/test_tensor_op" )
118
- ADD_TEST ( optimize "${CMAKE_BINARY_DIR} /src/tests/test_optimize" )
119
- ADD_TEST ( matrix_op "${CMAKE_BINARY_DIR} /src/tests/test_mat_op" )
120
- #ADD_TEST( dia_mat "${CMAKE_BINARY_DIR}/src/tests/test_dia_mat" )
121
- #ADD_TEST( spmv "${CMAKE_BINARY_DIR}/src/tests/test_spmv" )
122
- #ADD_TEST( densedense_to_dia "${CMAKE_BINARY_DIR}/src/tests/test_densedense_to_dia" )
123
- ADD_TEST ( random "${CMAKE_BINARY_DIR} /src/tests/test_random" )
124
- ADD_TEST ( lib_rbm "${CMAKE_BINARY_DIR} /src/tests/test_lib_rbm" )
125
- ADD_TEST ( lib_kmeans "${CMAKE_BINARY_DIR} /src/tests/test_lib_kmeans" )
126
- ADD_TEST ( conv_op "${CMAKE_BINARY_DIR} /src/tests/test_conv_op" )
127
- ADD_TEST ( theano_ops "${CMAKE_BINARY_DIR} /src/tests/test_theano_ops" )
128
-
129
- # test for memory leak. takes to long and bug was fixed
130
- #ADD_TEST( memory "${CMAKE_BINARY_DIR}/src/tests/test_memory" )
131
-
132
- # speed tests just take too long.
133
- #ADD_TEST( tensor_op_speed "${CMAKE_BINARY_DIR}/tests/test_tensor_op_speed" )
134
- #ADD_TEST( mat_op_speed "${CMAKE_BINARY_DIR}/tests/test_mat_op_speed" )
135
- #ADD_TEST( spmv_speed "${CMAKE_BINARY_DIR}/tests/test_spmv_speed" )
136
- #ADD_TEST( densedense_to_dia_speed "${CMAKE_BINARY_DIR}/tests/test_densedense_to_dia_speed" )
137
- #ADD_TEST( conv_ops_speed "${CMAKE_BINARY_DIR}/tests/test_conv_op_speed" )
138
- #ADD_TEST( random_speed "${CMAKE_BINARY_DIR}/tests/test_random_speed" )
139
-
140
90
IF (CUV_PYTHON_BINDINGS )
141
91
SET (ENV{PYTHONPATH} ${CMAKE_BINARY_DIR} /python_bindings )
142
92
ADD_TEST ( load_py sh -c "PYTHONPATH=${CMAKE_BINARY_DIR} /src python -c 'import cuv_python as cp'" )
@@ -149,4 +99,11 @@ IF(CUV_PYTHON_BINDINGS)
149
99
ENDIF (NOSETEST_EXECUTABLE )
150
100
ENDIF (CUV_PYTHON_BINDINGS )
151
101
102
+ ADD_CUSTOM_TARGET (buildtests DEPENDS ${CUV_TESTS} )
103
+ ADD_CUSTOM_TARGET (buildspeedtests DEPENDS ${CUV_SPEED_TESTS} )
104
+ ADD_CUSTOM_TARGET (runtests
105
+ DEPENDS buildtests
106
+ POST_BUILD_COMMAND ctest ARGS --output-on-failure
107
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
108
+ )
152
109
0 commit comments