|
| 1 | +#include <gtest/gtest.h> |
| 2 | + |
| 3 | +#include <helpers/PiImage.hpp> |
| 4 | +#include <helpers/PiMock.hpp> |
| 5 | +#include <numeric> |
| 6 | +#include <sycl/sycl.hpp> |
| 7 | + |
| 8 | +TEST(AccessorPlaceholderTest, NoCommandGroupPlaceholderNoneTargetDevice) { |
| 9 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 10 | + static constexpr sycl::access::target actarget = sycl::access::target::device; |
| 11 | + using AccT = sycl::accessor<int, 1, acmode, actarget>; |
| 12 | + int data(14); |
| 13 | + sycl::range<1> r(1); |
| 14 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 15 | + AccT acc(data_buf); |
| 16 | + EXPECT_TRUE(acc.is_placeholder()); |
| 17 | +} |
| 18 | + |
| 19 | +TEST(AccessorPlaceholderTest, NoCommandGroupPlaceholderTrueTargetDevice) { |
| 20 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 21 | + static constexpr sycl::access::target actarget = sycl::access::target::device; |
| 22 | + static constexpr sycl::access::placeholder acplaceholder = |
| 23 | + sycl::access::placeholder::true_t; |
| 24 | + using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>; |
| 25 | + int data(14); |
| 26 | + sycl::range<1> r(1); |
| 27 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 28 | + AccT acc(data_buf); |
| 29 | + EXPECT_TRUE(acc.is_placeholder()); |
| 30 | +} |
| 31 | + |
| 32 | +TEST(AccessorPlaceholderTest, NoCommandGroupPlaceholderFalseTargetDevice) { |
| 33 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 34 | + static constexpr sycl::access::target actarget = sycl::access::target::device; |
| 35 | + static constexpr sycl::access::placeholder acplaceholder = |
| 36 | + sycl::access::placeholder::false_t; |
| 37 | + using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>; |
| 38 | + int data(14); |
| 39 | + sycl::range<1> r(1); |
| 40 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 41 | + AccT acc(data_buf); |
| 42 | + EXPECT_TRUE(acc.is_placeholder()); |
| 43 | +} |
| 44 | + |
| 45 | +TEST(AccessorPlaceholderTest, PlaceholderNoneTargetDevice) { |
| 46 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 47 | + static constexpr sycl::access::target actarget = sycl::access::target::device; |
| 48 | + using AccT = sycl::accessor<int, 1, acmode, actarget>; |
| 49 | + int data(14); |
| 50 | + sycl::range<1> r(1); |
| 51 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 52 | + sycl::unittest::PiMock Mock; |
| 53 | + sycl::platform Plt = Mock.getPlatform(); |
| 54 | + sycl::queue q{Plt.get_devices()[0]}; |
| 55 | + q.submit([&](sycl::handler &cgh) { |
| 56 | + AccT acc(data_buf, cgh); |
| 57 | + EXPECT_FALSE(acc.is_placeholder()); |
| 58 | + }); |
| 59 | +} |
| 60 | + |
| 61 | +TEST(AccessorPlaceholderTest, PlaceholderTrueTargetDevice) { |
| 62 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 63 | + static constexpr sycl::access::target actarget = sycl::access::target::device; |
| 64 | + static constexpr sycl::access::placeholder acplaceholder = |
| 65 | + sycl::access::placeholder::true_t; |
| 66 | + using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>; |
| 67 | + int data(14); |
| 68 | + sycl::range<1> r(1); |
| 69 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 70 | + sycl::unittest::PiMock Mock; |
| 71 | + sycl::platform Plt = Mock.getPlatform(); |
| 72 | + sycl::queue q{Plt.get_devices()[0]}; |
| 73 | + q.submit([&](sycl::handler &cgh) { |
| 74 | + AccT acc(data_buf, cgh); |
| 75 | + EXPECT_FALSE(acc.is_placeholder()); |
| 76 | + }); |
| 77 | +} |
| 78 | + |
| 79 | +TEST(AccessorPlaceholderTest, PlaceholderFalseTargetDevice) { |
| 80 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 81 | + static constexpr sycl::access::target actarget = sycl::access::target::device; |
| 82 | + static constexpr sycl::access::placeholder acplaceholder = |
| 83 | + sycl::access::placeholder::false_t; |
| 84 | + using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>; |
| 85 | + int data(14); |
| 86 | + sycl::range<1> r(1); |
| 87 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 88 | + sycl::unittest::PiMock Mock; |
| 89 | + sycl::platform Plt = Mock.getPlatform(); |
| 90 | + sycl::queue q{Plt.get_devices()[0]}; |
| 91 | + q.submit([&](sycl::handler &cgh) { |
| 92 | + AccT acc(data_buf, cgh); |
| 93 | + EXPECT_FALSE(acc.is_placeholder()); |
| 94 | + }); |
| 95 | +} |
| 96 | + |
| 97 | +TEST(AccessorPlaceholderTest, PlaceholderNoneTargetHost) { |
| 98 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 99 | + static constexpr sycl::access::target actarget = |
| 100 | + sycl::access::target::host_buffer; |
| 101 | + using AccT = sycl::accessor<int, 1, acmode, actarget>; |
| 102 | + int data(14); |
| 103 | + sycl::range<1> r(1); |
| 104 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 105 | + AccT acc(data_buf); |
| 106 | + EXPECT_FALSE(acc.is_placeholder()); |
| 107 | + EXPECT_EQ(acc[0], data); |
| 108 | +} |
| 109 | + |
| 110 | +TEST(AccessorPlaceholderTest, PlaceholderTrueTargetHost) { |
| 111 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 112 | + static constexpr sycl::access::target actarget = |
| 113 | + sycl::access::target::host_buffer; |
| 114 | + static constexpr sycl::access::placeholder acplaceholder = |
| 115 | + sycl::access::placeholder::true_t; |
| 116 | + using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>; |
| 117 | + int data(14); |
| 118 | + sycl::range<1> r(1); |
| 119 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 120 | + AccT acc(data_buf); |
| 121 | + EXPECT_FALSE(acc.is_placeholder()); |
| 122 | +} |
| 123 | + |
| 124 | +TEST(AccessorPlaceholderTest, PlaceholderFalseTargetHost) { |
| 125 | + static constexpr sycl::access_mode acmode = sycl::access_mode::read; |
| 126 | + static constexpr sycl::access::target actarget = |
| 127 | + sycl::access::target::host_buffer; |
| 128 | + static constexpr sycl::access::placeholder acplaceholder = |
| 129 | + sycl::access::placeholder::false_t; |
| 130 | + using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>; |
| 131 | + int data(14); |
| 132 | + sycl::range<1> r(1); |
| 133 | + sycl::buffer<int, 1> data_buf(&data, r); |
| 134 | + AccT acc(data_buf); |
| 135 | + EXPECT_FALSE(acc.is_placeholder()); |
| 136 | +} |
0 commit comments