• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ---------------------------------------------------------------------------
2#  Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3#
4#  Distributed under the Boost Software License, Version 1.0
5#  See accompanying file LICENSE_1_0.txt or copy at
6#  http://www.boost.org/LICENSE_1_0.txt
7#
8# ---------------------------------------------------------------------------
9
10include_directories(../include)
11
12set(BOOST_COMPONENTS unit_test_framework)
13
14if(${BOOST_COMPUTE_USE_CPP11})
15  # allow tests to use C++11 features
16  add_definitions(-DBOOST_COMPUTE_USE_CPP11)
17endif()
18
19if (${BOOST_COMPUTE_USE_OFFLINE_CACHE})
20  set(BOOST_COMPONENTS ${BOOST_COMPONENTS} system filesystem)
21  add_definitions(-DBOOST_COMPUTE_USE_OFFLINE_CACHE)
22endif()
23
24if(${BOOST_COMPUTE_THREAD_SAFE} AND NOT ${BOOST_COMPUTE_USE_CPP11})
25  set(BOOST_COMPONENTS ${BOOST_COMPONENTS} system thread)
26endif()
27
28if(MSVC AND BOOST_COMPONENTS)
29  set(BOOST_COMPONENTS ${BOOST_COMPONENTS} chrono)
30endif()
31
32if(BOOST_COMPONENTS)
33  list(REMOVE_DUPLICATES BOOST_COMPONENTS)
34endif()
35find_package(Boost 1.54 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
36
37if(NOT MSVC)
38  add_definitions(-DBOOST_TEST_DYN_LINK)
39else()
40  if(MSVC AND ${BOOST_COMPUTE_BOOST_ALL_DYN_LINK})
41      add_definitions(-DBOOST_TEST_DYN_LINK)
42  endif()
43endif()
44
45# enable automatic kernel compilation error messages for tests
46add_definitions(-DBOOST_COMPUTE_DEBUG_KERNEL_COMPILATION)
47
48# enable code coverage generation (only with GCC for now)
49if(${BOOST_COMPUTE_ENABLE_COVERAGE} AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
50  add_definitions(-fprofile-arcs -ftest-coverage)
51endif()
52
53# add path to test data dir
54add_definitions(-DBOOST_COMPUTE_TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data")
55
56function(add_compute_test TEST_NAME TEST_SOURCE)
57  get_filename_component(TEST_TARGET ${TEST_SOURCE} NAME_WE)
58  add_executable(${TEST_TARGET} ${TEST_SOURCE})
59  target_link_libraries(${TEST_TARGET}
60    ${OpenCL_LIBRARIES}
61    ${Boost_LIBRARIES}
62  )
63
64  # link with coverage library
65  if(${BOOST_COMPUTE_ENABLE_COVERAGE} AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
66    target_link_libraries(${TEST_TARGET} -fprofile-arcs -ftest-coverage)
67  endif()
68
69  add_test(${TEST_NAME} ${TEST_TARGET})
70endfunction()
71
72add_compute_test("core.buffer" test_buffer.cpp)
73add_compute_test("core.closure" test_closure.cpp)
74add_compute_test("core.command_queue" test_command_queue.cpp)
75add_compute_test("core.context" test_context.cpp)
76add_compute_test("core.device" test_device.cpp)
77add_compute_test("core.event" test_event.cpp)
78add_compute_test("core.function" test_function.cpp)
79add_compute_test("core.kernel" test_kernel.cpp)
80add_compute_test("core.pipe" test_pipe.cpp)
81add_compute_test("core.platform" test_platform.cpp)
82add_compute_test("core.program" test_program.cpp)
83add_compute_test("core.system" test_system.cpp)
84add_compute_test("core.type_traits" test_type_traits.cpp)
85add_compute_test("core.user_event" test_user_event.cpp)
86
87add_compute_test("utility.extents" test_extents.cpp)
88add_compute_test("utility.invoke" test_invoke.cpp)
89add_compute_test("utility.program_cache" test_program_cache.cpp)
90add_compute_test("utility.wait_list" test_wait_list.cpp)
91
92add_compute_test("algorithm.accumulate" test_accumulate.cpp)
93add_compute_test("algorithm.adjacent_difference" test_adjacent_difference.cpp)
94add_compute_test("algorithm.adjacent_find" test_adjacent_find.cpp)
95add_compute_test("algorithm.any_all_none_of" test_any_all_none_of.cpp)
96add_compute_test("algorithm.binary_search" test_binary_search.cpp)
97add_compute_test("algorithm.copy" test_copy.cpp)
98add_compute_test("algorithm.copy_type_mismatch" test_copy_type_mismatch.cpp)
99add_compute_test("algorithm.copy_if" test_copy_if.cpp)
100add_compute_test("algorithm.count" test_count.cpp)
101add_compute_test("algorithm.equal" test_equal.cpp)
102add_compute_test("algorithm.equal_range" test_equal_range.cpp)
103add_compute_test("algorithm.extrema" test_extrema.cpp)
104add_compute_test("algorithm.fill" test_fill.cpp)
105add_compute_test("algorithm.find" test_find.cpp)
106add_compute_test("algorithm.find_end" test_find_end.cpp)
107add_compute_test("algorithm.for_each" test_for_each.cpp)
108add_compute_test("algorithm.gather" test_gather.cpp)
109add_compute_test("algorithm.generate" test_generate.cpp)
110add_compute_test("algorithm.includes" test_includes.cpp)
111add_compute_test("algorithm.inner_product" test_inner_product.cpp)
112add_compute_test("algorithm.inplace_merge" test_inplace_merge.cpp)
113add_compute_test("algorithm.inplace_reduce" test_inplace_reduce.cpp)
114add_compute_test("algorithm.insertion_sort" test_insertion_sort.cpp)
115add_compute_test("algorithm.iota" test_iota.cpp)
116add_compute_test("algorithm.is_permutation" test_is_permutation.cpp)
117add_compute_test("algorithm.is_sorted" test_is_sorted.cpp)
118add_compute_test("algorithm.merge_sort_gpu" test_merge_sort_gpu.cpp)
119add_compute_test("algorithm.merge" test_merge.cpp)
120add_compute_test("algorithm.mismatch" test_mismatch.cpp)
121add_compute_test("algorithm.next_permutation" test_next_permutation.cpp)
122add_compute_test("algorithm.nth_element" test_nth_element.cpp)
123add_compute_test("algorithm.partial_sum" test_partial_sum.cpp)
124add_compute_test("algorithm.partition" test_partition.cpp)
125add_compute_test("algorithm.partition_point" test_partition_point.cpp)
126add_compute_test("algorithm.prev_permutation" test_prev_permutation.cpp)
127add_compute_test("algorithm.radix_sort" test_radix_sort.cpp)
128add_compute_test("algorithm.radix_sort_by_key" test_radix_sort_by_key.cpp)
129add_compute_test("algorithm.random_fill" test_random_fill.cpp)
130add_compute_test("algorithm.random_shuffle" test_random_shuffle.cpp)
131add_compute_test("algorithm.reduce" test_reduce.cpp)
132add_compute_test("algorithm.reduce_by_key" test_reduce_by_key.cpp)
133add_compute_test("algorithm.remove" test_remove.cpp)
134add_compute_test("algorithm.replace" test_replace.cpp)
135add_compute_test("algorithm.reverse" test_reverse.cpp)
136add_compute_test("algorithm.rotate" test_rotate.cpp)
137add_compute_test("algorithm.rotate_copy" test_rotate_copy.cpp)
138add_compute_test("algorithm.scan" test_scan.cpp)
139add_compute_test("algorithm.scatter" test_scatter.cpp)
140add_compute_test("algorithm.scatter_if" test_scatter_if.cpp)
141add_compute_test("algorithm.search" test_search.cpp)
142add_compute_test("algorithm.search_n" test_search_n.cpp)
143add_compute_test("algorithm.set_difference" test_set_difference.cpp)
144add_compute_test("algorithm.set_intersection" test_set_intersection.cpp)
145add_compute_test("algorithm.set_symmetric_difference" test_set_symmetric_difference.cpp)
146add_compute_test("algorithm.set_union" test_set_union.cpp)
147add_compute_test("algorithm.sort" test_sort.cpp)
148add_compute_test("algorithm.sort_by_key" test_sort_by_key.cpp)
149add_compute_test("algorithm.stable_partition" test_stable_partition.cpp)
150add_compute_test("algorithm.stable_sort" test_stable_sort.cpp)
151add_compute_test("algorithm.stable_sort_by_key" test_stable_sort_by_key.cpp)
152add_compute_test("algorithm.transform" test_transform.cpp)
153add_compute_test("algorithm.transform_if" test_transform_if.cpp)
154add_compute_test("algorithm.transform_reduce" test_transform_reduce.cpp)
155add_compute_test("algorithm.unique" test_unique.cpp)
156add_compute_test("algorithm.unique_copy" test_unique_copy.cpp)
157add_compute_test("algorithm.lexicographical_compare" test_lexicographical_compare.cpp)
158
159add_compute_test("allocator.buffer_allocator" test_buffer_allocator.cpp)
160add_compute_test("allocator.pinned_allocator" test_pinned_allocator.cpp)
161
162add_compute_test("async.wait" test_async_wait.cpp)
163add_compute_test("async.wait_guard" test_async_wait_guard.cpp)
164
165add_compute_test("container.array" test_array.cpp)
166add_compute_test("container.dynamic_bitset" test_dynamic_bitset.cpp)
167add_compute_test("container.flat_map" test_flat_map.cpp)
168add_compute_test("container.flat_set" test_flat_set.cpp)
169add_compute_test("container.mapped_view" test_mapped_view.cpp)
170add_compute_test("container.stack" test_stack.cpp)
171add_compute_test("container.string" test_string.cpp)
172add_compute_test("container.valarray" test_valarray.cpp)
173add_compute_test("container.vector" test_vector.cpp)
174
175add_compute_test("exception.context_error" test_context_error.cpp)
176add_compute_test("exception.no_device_found" test_no_device_found.cpp)
177add_compute_test("exception.opencl_error" test_opencl_error.cpp)
178add_compute_test("exception.unsupported_extension" test_unsupported_extension.cpp)
179
180add_compute_test("functional.as" test_functional_as.cpp)
181add_compute_test("functional.bind" test_functional_bind.cpp)
182add_compute_test("functional.convert" test_functional_convert.cpp)
183add_compute_test("functional.get" test_functional_get.cpp)
184add_compute_test("functional.hash" test_functional_hash.cpp)
185add_compute_test("functional.identity" test_functional_identity.cpp)
186add_compute_test("functional.popcount" test_functional_popcount.cpp)
187add_compute_test("functional.unpack" test_functional_unpack.cpp)
188
189add_compute_test("image.image1d" test_image1d.cpp)
190add_compute_test("image.image2d" test_image2d.cpp)
191add_compute_test("image.image3d" test_image3d.cpp)
192add_compute_test("image.image_sampler" test_image_sampler.cpp)
193
194add_compute_test("iterator.buffer_iterator" test_buffer_iterator.cpp)
195add_compute_test("iterator.constant_iterator" test_constant_iterator.cpp)
196add_compute_test("iterator.counting_iterator" test_counting_iterator.cpp)
197add_compute_test("iterator.discard_iterator" test_discard_iterator.cpp)
198add_compute_test("iterator.function_input_iterator" test_function_input_iterator.cpp)
199add_compute_test("iterator.permutation_iterator" test_permutation_iterator.cpp)
200add_compute_test("iterator.strided_iterator" test_strided_iterator.cpp)
201add_compute_test("iterator.transform_iterator" test_transform_iterator.cpp)
202add_compute_test("iterator.zip_iterator" test_zip_iterator.cpp)
203
204add_compute_test("memory.local_buffer" test_local_buffer.cpp)
205add_compute_test("memory.svm_ptr" test_svm_ptr.cpp)
206
207add_compute_test("random.bernoulli_distribution" test_bernoulli_distribution.cpp)
208add_compute_test("random.discrete_distribution" test_discrete_distribution.cpp)
209add_compute_test("random.linear_congruential_engine" test_linear_congruential_engine.cpp)
210add_compute_test("random.mersenne_twister_engine" test_mersenne_twister_engine.cpp)
211add_compute_test("random.threefry_engine" test_threefry_engine.cpp)
212add_compute_test("random.normal_distribution" test_normal_distribution.cpp)
213add_compute_test("random.uniform_int_distribution" test_uniform_int_distribution.cpp)
214add_compute_test("random.uniform_real_distribution" test_uniform_real_distribution.cpp)
215
216add_compute_test("types.fundamental" test_types.cpp)
217add_compute_test("types.complex" test_complex.cpp)
218add_compute_test("types.pair" test_pair.cpp)
219add_compute_test("types.tuple" test_tuple.cpp)
220add_compute_test("types.struct" test_struct.cpp)
221
222add_compute_test("type_traits.result_of" test_result_of.cpp)
223
224add_compute_test("experimental.clamp_range" test_clamp_range.cpp)
225add_compute_test("experimental.malloc" test_malloc.cpp)
226add_compute_test("experimental.sort_by_transform" test_sort_by_transform.cpp)
227add_compute_test("experimental.tabulate" test_tabulate.cpp)
228
229# miscellaneous tests
230add_compute_test("misc.amd_cpp_kernel_language" test_amd_cpp_kernel_language.cpp)
231add_compute_test("misc.lambda" test_lambda.cpp)
232add_compute_test("misc.user_defined_types" test_user_defined_types.cpp)
233add_compute_test("misc.literal_conversion" test_literal_conversion.cpp)
234
235# extra tests (interop tests, linkage tests, etc.)
236add_subdirectory(extra)
237