From 933ff15ce55be17d263ea22f8692a1e00c8a2ba4 Mon Sep 17 00:00:00 2001 From: Jakub Szuppe Date: Tue, 24 May 2016 21:46:38 +0200 Subject: [PATCH] Better names for tests --- test/test_copy_type_mismatch.cpp | 146 ++++++++++++++++--------------- 1 file changed, 75 insertions(+), 71 deletions(-) diff --git a/test/test_copy_type_mismatch.cpp b/test/test_copy_type_mismatch.cpp index f56e8c03..34749940 100644 --- a/test/test_copy_type_mismatch.cpp +++ b/test/test_copy_type_mismatch.cpp @@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(is_same_ignore_const) )); } -BOOST_AUTO_TEST_CASE(copy_host_float_to_device_double) +BOOST_AUTO_TEST_CASE(copy_to_device_float_to_double) { if(!device.supports_extension("cl_khr_fp64")) { std::cout << "skipping test: device does not support double" << std::endl; @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(copy_host_float_to_device_double) CHECK_RANGE_EQUAL(double_, 4, device_vector, (6.1f, 10.2f, 19.3f, 25.4f)); } -BOOST_AUTO_TEST_CASE(copy_host_float_to_device_int) +BOOST_AUTO_TEST_CASE(copy_to_device_float_to_int) { using compute::int_; using compute::float_; @@ -111,7 +111,9 @@ BOOST_AUTO_TEST_CASE(copy_host_float_to_device_int) ); } -BOOST_AUTO_TEST_CASE(copy_host_float_to_device_int_mapping_device_vector) +// HOST -> DEVICE + +BOOST_AUTO_TEST_CASE(copy_to_device_float_to_int_mapping_device_vector) { using compute::int_; using compute::uint_; @@ -150,7 +152,7 @@ BOOST_AUTO_TEST_CASE(copy_host_float_to_device_int_mapping_device_vector) parameters->set(cache_key, "map_copy_threshold", map_copy_threshold); } -BOOST_AUTO_TEST_CASE(copy_host_float_to_device_int_convert_on_host) +BOOST_AUTO_TEST_CASE(copy_to_device_float_to_int_convert_on_host) { using compute::int_; using compute::uint_; @@ -194,7 +196,7 @@ BOOST_AUTO_TEST_CASE(copy_host_float_to_device_int_convert_on_host) parameters->set(cache_key, "direct_copy_threshold", direct_copy_threshold); } -BOOST_AUTO_TEST_CASE(copy_host_float_to_device_int_with_transform) +BOOST_AUTO_TEST_CASE(copy_to_device_float_to_int_with_transform) { using compute::int_; using compute::uint_; @@ -238,7 +240,7 @@ BOOST_AUTO_TEST_CASE(copy_host_float_to_device_int_with_transform) parameters->set(cache_key, "direct_copy_threshold", direct_copy_threshold); } -BOOST_AUTO_TEST_CASE(copy_async_host_float_to_device_int) +BOOST_AUTO_TEST_CASE(copy_async_to_device_float_to_int) { using compute::int_; using compute::float_; @@ -264,72 +266,10 @@ BOOST_AUTO_TEST_CASE(copy_async_host_float_to_device_int) ); } -BOOST_AUTO_TEST_CASE(copy_device_float_to_device_int) -{ - using compute::int_; - using compute::float_; - - float_ data[] = { 6.1f, -10.2f, 19.3f, 25.4f }; - bc::vector device_fvector(data, data + 4, queue); - bc::vector device_ivector(4, context); - - // copy device float vector to device int vector - bc::copy( - device_fvector.begin(), - device_fvector.end(), - device_ivector.begin(), - queue - ); - - CHECK_RANGE_EQUAL( - int_, - 4, - device_ivector, - ( - static_cast(6.1f), - static_cast(-10.2f), - static_cast(19.3f), - static_cast(25.4f) - ) - ); -} - -BOOST_AUTO_TEST_CASE(copy_async_device_float_to_device_int) -{ - using compute::int_; - using compute::float_; - - float_ data[] = { 6.1f, -10.2f, 19.3f, 25.4f }; - bc::vector device_fvector(data, data + 4, queue); - bc::vector device_ivector(4, context); - - // copy device float vector to device int vector - compute::future future = - bc::copy_async( - device_fvector.begin(), - device_fvector.end(), - device_ivector.begin(), - queue - ); - future.wait(); - - CHECK_RANGE_EQUAL( - int_, - 4, - device_ivector, - ( - static_cast(6.1f), - static_cast(-10.2f), - static_cast(19.3f), - static_cast(25.4f) - ) - ); -} - // Test copying from a std::list to a bc::vector. This differs from // the test copying from std::vector because std::list has non-contiguous // storage for its data values. -BOOST_AUTO_TEST_CASE(copy_from_host_float_list_to_int_device_map) +BOOST_AUTO_TEST_CASE(copy_to_device_float_to_int_list_device_map) { using compute::int_; using compute::uint_; @@ -372,7 +312,7 @@ BOOST_AUTO_TEST_CASE(copy_from_host_float_list_to_int_device_map) // Test copying from a std::list to a bc::vector. This differs from // the test copying from std::vector because std::list has non-contiguous // storage for its data values. -BOOST_AUTO_TEST_CASE(copy_from_host_float_list_to_int_device_convert_on_host) +BOOST_AUTO_TEST_CASE(copy_to_device_float_to_int_list_convert_on_host) { using compute::int_; using compute::uint_; @@ -418,9 +358,73 @@ BOOST_AUTO_TEST_CASE(copy_from_host_float_list_to_int_device_convert_on_host) } +// DEVICE -> DEVICE + +BOOST_AUTO_TEST_CASE(copy_on_device_float_to_int) +{ + using compute::int_; + using compute::float_; + + float_ data[] = { 6.1f, -10.2f, 19.3f, 25.4f }; + bc::vector device_fvector(data, data + 4, queue); + bc::vector device_ivector(4, context); + + // copy device float vector to device int vector + bc::copy( + device_fvector.begin(), + device_fvector.end(), + device_ivector.begin(), + queue + ); + + CHECK_RANGE_EQUAL( + int_, + 4, + device_ivector, + ( + static_cast(6.1f), + static_cast(-10.2f), + static_cast(19.3f), + static_cast(25.4f) + ) + ); +} + +BOOST_AUTO_TEST_CASE(copy_async_on_device_float_to_int) +{ + using compute::int_; + using compute::float_; + + float_ data[] = { 6.1f, -10.2f, 19.3f, 25.4f }; + bc::vector device_fvector(data, data + 4, queue); + bc::vector device_ivector(4, context); + + // copy device float vector to device int vector + compute::future future = + bc::copy_async( + device_fvector.begin(), + device_fvector.end(), + device_ivector.begin(), + queue + ); + future.wait(); + + CHECK_RANGE_EQUAL( + int_, + 4, + device_ivector, + ( + static_cast(6.1f), + static_cast(-10.2f), + static_cast(19.3f), + static_cast(25.4f) + ) + ); +} + // DEVICE -> HOST -BOOST_AUTO_TEST_CASE(copy_device_float_to_host_int) +BOOST_AUTO_TEST_CASE(copy_to_host_float_to_int) { using compute::int_; using compute::float_;