]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/test/test_image1d.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / compute / test / test_image1d.cpp
CommitLineData
7c673cae
FG
1//---------------------------------------------------------------------------//
2// Copyright (c) 2013-2015 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// See http://boostorg.github.com/compute for more information.
9//---------------------------------------------------------------------------//
10
11#define BOOST_TEST_MODULE TestImage1D
12#include <boost/test/unit_test.hpp>
13
14#include <iostream>
15
16#include <boost/compute/image/image1d.hpp>
17#include <boost/compute/utility/dim.hpp>
18
19#include "quirks.hpp"
20#include "context_setup.hpp"
21
22namespace compute = boost::compute;
23
24BOOST_AUTO_TEST_CASE(image1d_get_supported_formats)
25{
26 const std::vector<compute::image_format> formats =
27 compute::image1d::get_supported_formats(context);
28}
29
b32b8144 30#ifdef BOOST_COMPUTE_CL_VERSION_1_2
7c673cae
FG
31BOOST_AUTO_TEST_CASE(fill_image1d)
32{
33 REQUIRES_OPENCL_VERSION(1, 2); // device OpenCL version check
34
35 // single-channel unsigned char
36 compute::image_format format(CL_R, CL_UNSIGNED_INT8);
37
38 if(!compute::image1d::is_supported_format(format, context)){
39 std::cerr << "skipping fill_image1d test, image format not supported" << std::endl;
40 return;
41 }
42
43 compute::image1d img(context, 64, format);
44
45 BOOST_CHECK_EQUAL(img.width(), size_t(64));
46 BOOST_CHECK(img.size() == compute::dim(64));
47 BOOST_CHECK(img.format() == format);
48
49 // fill image with '128'
50 compute::uint4_ fill_color(128, 0, 0, 0);
51 queue.enqueue_fill_image(img, &fill_color, img.origin(), img.size());
52
53 // read value of first pixel
54 compute::uchar_ first_pixel = 0;
55 queue.enqueue_read_image(img, compute::dim(0), compute::dim(1), &first_pixel);
56 BOOST_CHECK_EQUAL(first_pixel, compute::uchar_(128));
57}
b32b8144 58#endif // BOOST_COMPUTE_CL_VERSION_1_2
7c673cae
FG
59
60// check type_name() for image1d
61BOOST_AUTO_TEST_CASE(image1d_type_name)
62{
63 BOOST_CHECK(
64 std::strcmp(
65 boost::compute::type_name<boost::compute::image1d>(), "image1d_t"
66 ) == 0
67 );
68}
69
70BOOST_AUTO_TEST_SUITE_END()