forked from ashwin/coursera-heterogeneous
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
138 lines (117 loc) · 3.71 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
set(CUDA_VERBOSE_BUILD ON)
find_package(CUDA QUIET REQUIRED)
# The cuda_include_directories adds paths to only cuda compilation.
CUDA_INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
)
set(BUILD_SHARED_LIBS ON)
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "-lm -F/Library/Frameworks -framework CUDA")
set(CUDA_HOST_COMPILER "/usr/bin/gcc")
endif(APPLE)
INCLUDE_DIRECTORIES(./include)
CUDA_ADD_EXECUTABLE(mp0
src/mp0.cc)
CUDA_ADD_EXECUTABLE(mp1
src/mp1.cu)
CUDA_ADD_EXECUTABLE(mp2
src/mp2.cu)
CUDA_ADD_EXECUTABLE(mp3
src/mp3.cu)
CUDA_ADD_EXECUTABLE(mp4
src/mp4.cu)
CUDA_ADD_EXECUTABLE(mp5
src/mp5.cu)
CUDA_ADD_EXECUTABLE(mp6
src/mp6.cu)
# We do this painfully here because setting CMAKE_EXE_LINKER_FLAGS
# gives error on Ubuntu. Because CMake prepends the linker flags.
if (UNIX AND NOT APPLE)
set(TIMER_FLAGS "-lm -lrt")
target_link_libraries(mp0 ${TIMER_FLAGS})
target_link_libraries(mp1 ${TIMER_FLAGS})
target_link_libraries(mp2 ${TIMER_FLAGS})
target_link_libraries(mp3 ${TIMER_FLAGS})
target_link_libraries(mp4 ${TIMER_FLAGS})
target_link_libraries(mp5 ${TIMER_FLAGS})
target_link_libraries(mp6 ${TIMER_FLAGS})
endif(UNIX AND NOT APPLE)
# Added tests, to execute use 'ctest'
enable_testing()
# tests for mp0
add_test(mp0 mp0)
set_tests_properties (mp0
PROPERTIES FAIL_REGULAR_EXPRESSION "No CUDA GPU has been detected"
LABELS mp0)
set (numtests 6)
# tests for mp1 mp2 mp3
set (tests mp1 mp2 mp3)
FOREACH (test ${tests})
set (path tests/${test}_data)
set (i 0)
WHILE (${i} LESS ${numtests})
set(testname ${test}_data-${i})
add_test(${testname} ${test}
${path}/${i}/input0.raw
${path}/${i}/input1.raw
${path}/${i}/output.raw)
set_tests_properties (${testname}
PROPERTIES PASS_REGULAR_EXPRESSION "Solution is correct"
LABELS ${testname})
MATH(EXPR i "${i} + 1")
ENDWHILE (${i} LESS ${numtests} )
ENDFOREACH(test)
# tests for mp4 mp5
set (tests mp4 mp5)
set (i 0)
FOREACH (test ${tests})
set (path tests/${test}_data)
set (i 0)
WHILE (${i} LESS ${numtests})
set(testname ${test}_data-${i})
add_test(${testname} ${test}
${path}/${i}/input.raw
${path}/${i}/output.raw)
set_tests_properties (${testname}
PROPERTIES PASS_REGULAR_EXPRESSION "Solution is correct"
LABELS ${testname})
MATH(EXPR i "${i} + 1")
ENDWHILE (${i} LESS ${numtests})
ENDFOREACH(test)
# tests for mp6
set (tests mp6)
FOREACH (test ${tests})
set (path tests/${test}_data)
set (i 0)
WHILE (${i} LESS ${numtests})
set(testname ${test}_data-${i})
add_test(${testname} ${test}
${path}/${i}/input0.ppm
${path}/${i}/input1.csv
${path}/${i}/output.ppm)
set_tests_properties (${testname}
PROPERTIES PASS_REGULAR_EXPRESSION "Solution is correct"
LABELS ${testname})
MATH(EXPR i "${i} + 1")
ENDWHILE (${i} LESS ${numtests} )
ENDFOREACH(test)
# official graded tests
set (numtests 10)
# tests for mp1 mp2 mp3
set (tests mp1 mp2 mp3)
FOREACH (test ${tests})
set (path tests/${test}_grade)
set (i 0)
WHILE (${i} LESS ${numtests})
set(testname ${test}_grade-${i})
add_test(${testname} ${test}
${path}/${i}/input0.raw
${path}/${i}/input1.raw
${path}/${i}/output.raw)
set_tests_properties (${testname}
PROPERTIES PASS_REGULAR_EXPRESSION "Solution is correct"
LABELS ${testname})
MATH(EXPR i "${i} + 1")
ENDWHILE (${i} LESS ${numtests} )
ENDFOREACH(test)