inline void test_fill(T v1, T v2, T v3, bc::command_queue queue) { if(boost::is_same<typename bc::scalar_type<T>::type, bc::double_>::value && !queue.get_device().supports_extension("cl_khr_fp64")) { std::cerr << "Skipping test_fill<" << bc::type_name<T>() << ">() " "on device which doesn't support cl_khr_fp64" << std::endl; return; } bc::vector<T> vector(4, queue.get_context()); bc::fill(vector.begin(), vector.end(), v1, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v1, v1, v1, v1)); vector.resize(1000, queue); bc::fill(vector.begin(), vector.end(), v2, queue); queue.finish(); BOOST_CHECK_EQUAL(vector.front(), v2); BOOST_CHECK_EQUAL(vector.back(), v2); bc::fill(vector.begin() + 500, vector.end(), v3, queue); queue.finish(); BOOST_CHECK_EQUAL(vector.front(), v2); BOOST_CHECK_EQUAL(vector[499], v2); BOOST_CHECK_EQUAL(vector[500], v3); BOOST_CHECK_EQUAL(vector.back(), v3); }
inline void test_fill_n(T v1, T v2, T v3, bc::command_queue queue) { if(boost::is_same<typename bc::scalar_type<T>::type, bc::double_>::value && !queue.get_device().supports_extension("cl_khr_fp64")) { std::cerr << "Skipping test_fill_n<" << bc::type_name<T>() << ">() " "on device which doesn't support cl_khr_fp64" << std::endl; return; } bc::vector<T> vector(4, queue.get_context()); bc::fill_n(vector.begin(), 4, v1, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v1, v1, v1, v1)); bc::fill_n(vector.begin(), 3, v2, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v2, v2, v2, v1)); bc::fill_n(vector.begin() + 1, 2, v3, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v2, v3, v3, v1)); bc::fill_n(vector.begin(), 4, v2, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v2, v2, v2, v2)); // fill last element bc::fill_n(vector.end() - 1, 1, v3, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v2, v2, v2, v3)); // fill first element bc::fill_n(vector.begin(), 1, v1, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v1, v2, v2, v3)); }
inline void test_fill_n(T v1, T v2, T v3, bc::command_queue queue) { bc::vector<T> vector(4, queue.get_context()); bc::fill_n(vector.begin(), 4, v1, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v1, v1, v1, v1)); bc::fill_n(vector.begin(), 3, v2, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v2, v2, v2, v1)); bc::fill_n(vector.begin() + 1, 2, v3, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v2, v3, v3, v1)); bc::fill_n(vector.begin(), 4, v2, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v2, v2, v2, v2)); // fill last element bc::fill_n(vector.end() - 1, 1, v3, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v2, v2, v2, v3)); // fill first element bc::fill_n(vector.begin(), 1, v1, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v1, v2, v2, v3)); }
inline void test_fill(T v1, T v2, T v3, bc::command_queue queue) { bc::vector<T> vector(4, queue.get_context()); bc::fill(vector.begin(), vector.end(), v1, queue); queue.finish(); CHECK_RANGE_EQUAL(T, 4, vector, (v1, v1, v1, v1)); vector.resize(1000, queue); bc::fill(vector.begin(), vector.end(), v2, queue); queue.finish(); BOOST_CHECK_EQUAL(vector.front(), v2); BOOST_CHECK_EQUAL(vector.back(), v2); bc::fill(vector.begin() + 500, vector.end(), v3, queue); queue.finish(); BOOST_CHECK_EQUAL(vector.front(), v2); BOOST_CHECK_EQUAL(vector[499], v2); BOOST_CHECK_EQUAL(vector[500], v3); BOOST_CHECK_EQUAL(vector.back(), v3); }