CMakeLists.txt 11 KB

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