1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16
17#include "VtsHalRenderscriptV1_0TargetTest.h"
18
19/*
20 * This test creates a 1D Allocation with 128 Float Elements, and two float
21 * vector dataIn & dataOut. dataIn is pre-populated with data, and copied into
22 * the Allocation using allocation1DWrite. Then the Allocation is copied into
23 * dataOut with allocation1DRead.
24 *
25 * Calls: elementCreate, typeCreate, allocationCreateTyped, allocation1DWrite,
26 * allocation1DRead
27 *
28 * Expect: dataIn & dataOut are the same.
29 */
30TEST_F(RenderscriptHidlTest, Simple1DCopyTest) {
31    // float1
32    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
33    ASSERT_NE(Element(0), element);
34
35    // 128 x float1
36    Type type = context->typeCreate(element, 128, 0, 0, false, false, YuvFormat::YUV_NONE);
37    ASSERT_NE(Type(0), type);
38
39    // 128 x float1
40    Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
41                                                           (int)AllocationUsageType::SCRIPT,
42                                                           (Ptr)nullptr);
43    ASSERT_NE(Allocation(0), allocation);
44
45    std::vector<float> dataIn(128), dataOut(128);
46    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
47    hidl_vec<uint8_t> _data;
48    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
49    context->allocation1DWrite(allocation, 0, 0, (Size)dataIn.size(), _data);
50    context->allocation1DRead(allocation, 0, 0, (uint32_t)dataOut.size(), (Ptr)dataOut.data(),
51                              (Size)dataOut.size()*sizeof(float));
52    EXPECT_EQ(dataIn, dataOut);
53}
54
55/*
56 * This test creates a 2D Allocation with 128 * 128 Float Elements, and two
57 * float vector dataIn & dataOut. dataIn is pre-populated with data, and copied
58 * into the Allocation using allocation2DWrite. Then the Allocation is copied
59 * into dataOut with allocation2DRead.
60 *
61 * Calls: elementCreate, typeCreate, allocationCreateTyped, allocation2DWrite,
62 * allocation2DRead
63 *
64 * Expect: dataIn & dataOut are the same.
65 */
66TEST_F(RenderscriptHidlTest, Simple2DCopyTest) {
67    // float1
68    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
69    ASSERT_NE(Element(0), element);
70
71    // 128 x 128 x float1
72    Type type = context->typeCreate(element, 128, 128, 0, false, false, YuvFormat::YUV_NONE);
73    ASSERT_NE(Type(0), type);
74
75    // 128 x 128 x float1
76    Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
77                                                           (int)AllocationUsageType::SCRIPT,
78                                                           (Ptr)nullptr);
79    ASSERT_NE(Allocation(0), allocation);
80
81    std::vector<float> dataIn(128*128), dataOut(128*128);
82    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
83    hidl_vec<uint8_t> _data;
84    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
85    context->allocation2DWrite(allocation, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 128, 128,
86                               _data, 0);
87    context->allocation2DRead(allocation, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 128, 128,
88                              (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float), 0);
89    EXPECT_EQ(dataIn, dataOut);
90}
91
92/*
93 * This test creates a 3D Allocation with 32 * 32 * 32 Float Elements, and two
94 * float vector dataIn & dataOut. dataIn is pre-populated with data, and copied
95 * into the Allocation using allocation3DWrite. Then the Allocation is copied
96 * into dataOut with allocation3DRead.
97 *
98 * Calls: elementCreate, typeCreate, allocationCreateTyped, allocation3DWrite,
99 * allocation3DRead
100 *
101 * Expect: dataIn & dataOut are the same.
102 */
103TEST_F(RenderscriptHidlTest, Simple3DCopyTest) {
104    // float1
105    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
106    ASSERT_NE(Element(0), element);
107
108    // 32 x 32 x 32 x float1
109    Type type = context->typeCreate(element, 32, 32, 32, false, false, YuvFormat::YUV_NONE);
110    ASSERT_NE(Type(0), type);
111
112    // 32 x 32 x 32 x float1
113    Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
114                                                           (int)AllocationUsageType::SCRIPT,
115                                                           (Ptr)nullptr);
116    ASSERT_NE(Allocation(0), allocation);
117
118    std::vector<float> dataIn(32*32*32), dataOut(32*32*32);
119    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
120    hidl_vec<uint8_t> _data;
121    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
122    context->allocation3DWrite(allocation, 0, 0, 0, 0, 32, 32, 32, _data, 0);
123    context->allocation3DRead(allocation, 0, 0, 0, 0, 32, 32, 32, (Ptr)dataOut.data(),
124                              (Size)dataOut.size()*sizeof(float), 0);
125    EXPECT_EQ(dataIn, dataOut);
126}
127
128/*
129 * This test creates a 2D Allocation with 512 * 512 Float Elements with
130 * allocationCreateFromBitmap, and two float vector dataIn & dataOut. dataIn is
131 * pre-populated with data, and copied into the Allocation using
132 * allocationCopyToBitmap. Then the Allocation is copied into dataOut with
133 * allocationRead.
134 *
135 * Calls: elementCreate, typeCreate, allocationCreateFromBitmap,
136 * allocationCopyToBitmap, allocationRead
137 *
138 * Expect: dataIn & dataOut are the same.
139 */
140TEST_F(RenderscriptHidlTest, SimpleBitmapTest) {
141    // float1
142    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
143    ASSERT_NE(Element(0), element);
144
145    // 512 x 512 x float1
146    Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
147    ASSERT_NE(Type(0), type);
148
149    std::vector<float> dataIn(512*512), dataOut1(512*512), dataOut2(512*512);
150    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
151    hidl_vec<uint8_t> _data;
152    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
153    // 512 x 512 x float1
154    Allocation allocation = context->allocationCreateFromBitmap(type,
155                                                                AllocationMipmapControl::NONE,
156                                                                _data,
157                                                                (int)AllocationUsageType::SCRIPT);
158    ASSERT_NE(Allocation(0), allocation);
159
160    context->allocationCopyToBitmap(allocation, (Ptr)dataOut1.data(),
161                                    (Size)dataOut1.size()*sizeof(float));
162    EXPECT_EQ(dataIn, dataOut1);
163
164    context->allocationRead(allocation, (Ptr)dataOut2.data(), (Size)dataOut2.size()*sizeof(float));
165    EXPECT_EQ(dataIn, dataOut2);
166}
167
168/*
169 * This test creates two 2D Allocations, one with 512 * 512 Float Elements, the
170 * other with 256 * 256 Float Elements. The larger Allocation is pre-populated
171 * with dataIn, and copied into the smaller Allocation using
172 * allocationCopy2DRange. Then the Allocation is copied into dataOut with
173 * allocationRead.
174 *
175 * Calls: elementCreate, typeCreate, allocationCreateFromBitmap,
176 * allocationCreateTyped, allocationCopy2DRange, allocationRead
177 *
178 * Expect: dataIn & dataOut are the same.
179 */
180TEST_F(RenderscriptHidlTest, AllocationCopy2DRangeTest) {
181    // float1
182    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
183    ASSERT_NE(Element(0), element);
184
185    // 512 x 512 x float1
186    Type typeSrc = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
187    ASSERT_NE(Type(0), typeSrc);
188
189    // 256 x 256 x float1
190    Type typeDst = context->typeCreate(element, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
191    ASSERT_NE(Type(0), typeDst);
192
193    std::vector<float> dataIn(512*512), dataOut(256*256), expected(256*256);
194    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
195    hidl_vec<uint8_t> _data;
196    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
197    // 512 x 512 x float1
198    Allocation allocSrc = context->allocationCreateFromBitmap(typeSrc,
199                                                              AllocationMipmapControl::NONE, _data,
200                                                              (int)AllocationUsageType::SCRIPT);
201    ASSERT_NE(Allocation(0), allocSrc);
202
203    // 256 x 256 x float1
204    Allocation allocDst = context->allocationCreateTyped(typeDst, AllocationMipmapControl::NONE,
205                                                         (int)AllocationUsageType::SCRIPT,
206                                                         (Ptr)nullptr);
207    ASSERT_NE(Allocation(0), allocDst);
208
209    context->allocationCopy2DRange(allocDst, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256, 256,
210                                   allocSrc, 128, 128, 0, AllocationCubemapFace::POSITIVE_X);
211    context->allocationRead(allocDst, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float));
212    for (int i = 0; i < 256; ++i) {
213        for (int j = 0; j < 256; ++j) {
214            expected[i*256 + j] = dataIn[(i+128)*512 + (j+128)];
215        }
216    }
217    EXPECT_EQ(expected, dataOut);
218}
219
220/*
221 * This test creates two 3D Allocations, one with 128 * 128 * 128 Float
222 * Elements, the other with 64 * 64 * 64 Float Elements. The larger Allocation
223 * is pre-populated with dataIn, and copied into the smaller Allocation using
224 * allocationCopy3DRange. Then the Allocation is copied into dataOut with
225 * allocationRead.
226 *
227 * Calls: elementCreate, typeCreate, allocationCreateTyped, allocation3DWrite,
228 * allocationCopy3DRange, allocationRead
229 *
230 * Expect: dataIn & dataOut are the same.
231 */
232TEST_F(RenderscriptHidlTest, AllocationCopy3DRangeTest) {
233    // float1
234    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
235    ASSERT_NE(Element(0), element);
236
237    // 128 x 128 x 128 x float1
238    Type typeSrc = context->typeCreate(element, 128, 128, 128, false, false, YuvFormat::YUV_NONE);
239    ASSERT_NE(Type(0), typeSrc);
240
241    // 64 x 64 x 64 x float1
242    Type typeDst = context->typeCreate(element, 64, 64, 64, false, false, YuvFormat::YUV_NONE);
243    ASSERT_NE(Type(0), typeDst);
244
245    std::vector<float> dataIn(128*128*128), dataOut(64*64*64), expected(64*64*64);
246    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
247    hidl_vec<uint8_t> _data;
248    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
249    // 512 x 512 x float1
250    Allocation allocSrc = context->allocationCreateTyped(typeSrc, AllocationMipmapControl::NONE,
251                                                         (int)AllocationUsageType::SCRIPT,
252                                                         (Ptr)nullptr);
253    ASSERT_NE(Allocation(0), allocSrc);
254
255    // 256 x 256 x float1
256    Allocation allocDst = context->allocationCreateTyped(typeDst, AllocationMipmapControl::NONE,
257                                                         (int)AllocationUsageType::SCRIPT,
258                                                         (Ptr)nullptr);
259    ASSERT_NE(Allocation(0), allocDst);
260
261    context->allocation3DWrite(allocSrc, 0, 0, 0, 0, 128, 128, 128, _data, 128*sizeof(float));
262    context->allocationCopy3DRange(allocDst, 0, 0, 0, 0, 64, 64, 64, allocSrc, 32, 32, 32, 0);
263    context->allocationRead(allocDst, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float));
264    for (int i = 0; i < 64; ++i) {
265        for (int j = 0; j < 64; ++j) {
266            for (int k = 0; k < 64; ++k) {
267                expected[i*64*64 + j*64 + k] = dataIn[(i+32)*128*128 + (j+32)*128 + (k+32)];
268            }
269        }
270    }
271    EXPECT_EQ(expected, dataOut);
272}
273
274/*
275 * This test creates one 2D Allocations, one with 512 * 512 Float Elements, and
276 * one 2D AllocationAdapter with a window of 256 * 256 based on the Allocation.
277 * The Allocation is pre-populated with dataIn. Then the Allocation is copied
278 * into dataOut with allocationRead on the AllocationAdapter.
279 *
280 * Calls: elementCreate, typeCreate, allocationCreateFromBitmap,
281 * allocationAdapterCreate, allocationAdapterOffset, allocation2DRead
282 *
283 * Expect: dataIn & dataOut are the same.
284 */
285TEST_F(RenderscriptHidlTest, SimpleAdapterTest) {
286    // float1
287    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
288    ASSERT_NE(Element(0), element);
289
290    // 512 x 512 x float1
291    Type type = context->typeCreate(element, 512, 512, 0, false, false, YuvFormat::YUV_NONE);
292    ASSERT_NE(Type(0), type);
293
294    std::vector<float> dataIn(512*512), dataOut(256*256), expected;
295    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
296    hidl_vec<uint8_t> _data;
297    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
298    // 512 x 512 x float1
299    Allocation allocation = context->allocationCreateFromBitmap(type,
300                                                                AllocationMipmapControl::NONE,
301                                                                _data,
302                                                                (int)AllocationUsageType::SCRIPT);
303    ASSERT_NE(Allocation(0), allocation);
304
305    // 256 x 256 x float1
306    Type subType = context->typeCreate(element, 256, 256, 0, false, false, YuvFormat::YUV_NONE);
307    ASSERT_NE(Type(0), subType);
308
309    // 256 x 256 x float1
310    AllocationAdapter allocationAdapter = context->allocationAdapterCreate(subType, allocation);
311    ASSERT_NE(AllocationAdapter(0), allocationAdapter);
312
313    std::vector<uint32_t> offsets(9, 0);
314    offsets[0] = 128;
315    offsets[1] = 128;
316    hidl_vec<uint32_t> _offsets;
317    _offsets.setToExternal(offsets.data(), offsets.size());
318    // origin at (128,128)
319    context->allocationAdapterOffset(allocationAdapter, _offsets);
320
321    context->allocation2DRead(allocationAdapter, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 256,
322                              256, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float), 0);
323    for (int i = 128; i < 128 + 256; ++i) {
324        for (int j = 128; j < 128 + 256; ++j) {
325            expected.push_back(i * 512 + j);
326        }
327    }
328    EXPECT_EQ(expected, dataOut);
329}
330
331/*
332 * This test creates one 2D Allocations, one with 64 * 64 USIGNED_8 Elements,
333 * and with AllocationMipmapControl::FULL. The Allocation is pre-populated with
334 * dataIn and the mipmaps are filled with allocationGenerateMipmaps. Then
335 * dataOut is then overridden with allocation2DRead.
336 *
337 * Calls: elementCreate, typeCreate, allocationCreateTyped, allocation2DWrite,
338 * allocationGenerateMipmaps, allocationSyncAll, allocation2DRead
339 *
340 * Expect: dataIn & dataOut are the same.
341 */
342TEST_F(RenderscriptHidlTest, SimpleMipmapTest) {
343    // uint8_t
344    Element element = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
345    ASSERT_NE(Element(0), element);
346
347    // 64 x 64 x uint8_t
348    Type type = context->typeCreate(element, 64, 64, 0, true, false, YuvFormat::YUV_NONE);
349    ASSERT_NE(Type(0), type);
350
351    std::vector<uint8_t> dataIn(64*64), dataOut(32*32), expected(32*32);
352    std::generate(dataIn.begin(), dataIn.end(),
353                  [](){ static int val = 0; return (uint8_t)(0xFF & val++); });
354    hidl_vec<uint8_t> _data;
355    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(uint8_t));
356    // 64 x 64 x uint8_t
357    Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::FULL,
358                                                         (int)AllocationUsageType::SCRIPT,
359                                                         (Ptr)nullptr);
360    ASSERT_NE(Allocation(0), allocation);
361
362    context->allocation2DWrite(allocation, 0, 0, 0, AllocationCubemapFace::POSITIVE_X, 64, 64,
363                               _data, 64*sizeof(uint8_t));
364    context->allocationGenerateMipmaps(allocation);
365    context->allocationSyncAll(allocation, AllocationUsageType::SCRIPT);
366    context->allocation2DRead(allocation, 0, 0, 1, AllocationCubemapFace::POSITIVE_X, 32, 32,
367                              (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(uint8_t),
368                              32*sizeof(uint8_t));
369    for (int i = 0; i < 32; ++i) {
370        for (int j = 0; j < 32; ++j) {
371            expected[i*32 + j] = ((uint32_t)dataIn[i*2*64 + j*2] + dataIn[i*2*64 + j*2 + 1] +
372                                  dataIn[i*2*64 + j*2 + 64] + dataIn[i*2*64 + j*2 + 64+1]) / 4;
373        }
374    }
375    EXPECT_EQ(expected, dataOut);
376}
377
378/*
379 * This test creates one 2D Allocations, one with 128 * 128 Float Elements with
380 * allocationCubeCreateFromBitmap. The Allocation is pre-populated with dataIn
381 * and the mipmaps are filled with allocationGenerateMipmaps. Then dataOut is
382 * then overridden with allocation2DRead.
383 *
384 * Calls: elementCreate, typeCreate, allocationCubeCreateFromBitmap,
385 * allocation2DRead
386 *
387 * Expect: dataIn & dataOut are the same.
388 */
389TEST_F(RenderscriptHidlTest, SimpleCubemapTest) {
390    // float1
391    Element element = context->elementCreate(DataType::FLOAT_32, DataKind::USER, false, 1);
392    ASSERT_NE(Element(0), element);
393
394    // 128 x 128 x float1
395    Type type = context->typeCreate(element, 128, 128, 0, false, true, YuvFormat::YUV_NONE);
396    ASSERT_NE(Type(0), type);
397
398    std::vector<float> dataIn(128*128*6), dataOut(128*128), expected(128*128);
399    std::generate(dataIn.begin(), dataIn.end(), [](){ static int val = 0; return (float)val++; });
400    hidl_vec<uint8_t> _data;
401    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(float));
402    // 128 x 128 x float1 x 6
403    Allocation allocation = context->allocationCubeCreateFromBitmap(
404        type, AllocationMipmapControl::NONE, _data, (int)AllocationUsageType::SCRIPT);
405    ASSERT_NE(Allocation(0), allocation);
406
407    context->allocation2DRead(allocation, 0, 0, 0, AllocationCubemapFace::NEGATIVE_Z, 128,
408                              128, (Ptr)dataOut.data(), (Size)dataOut.size()*sizeof(float),
409                              128*sizeof(float));
410    for (int i = 0; i < 128; ++i) {
411        for (int j = 0; j < 128; ++j) {
412            expected[i*128 + j] = i*128*6 + j + 128*5;
413        }
414    }
415    EXPECT_EQ(expected, dataOut);
416}
417
418/*
419 * This test creates a complex element type (uint8_t, uint32_t) out of known
420 * elements. It then verifies the element structure was created correctly.
421 * Finally, the test creates a 1-wide, 1-dimension allocation of this type
422 * and transfers memory to and from a single cell of this Allocation.
423 *
424 * Calls: elementCreate, elementComplexCreate, elementGetSubElements,
425 * typeCreate, allocationCreateTyped, allocationElementWrite,
426 * allocationElementRead
427 */
428TEST_F(RenderscriptHidlTest, ComplexElementTest) {
429    Element element1 = context->elementCreate(DataType::UNSIGNED_8, DataKind::USER, false, 1);
430    ASSERT_NE(Element(0), element1);
431
432    Element element2 = context->elementCreate(DataType::UNSIGNED_32, DataKind::USER, false, 1);
433    ASSERT_NE(Element(0), element2);
434
435    hidl_vec<Element> eins = {element1, element2};
436    hidl_vec<hidl_string> names = {hidl_string("first"), hidl_string("second")};
437    hidl_vec<Size> arraySizesPtr = {1, 1};
438    Element element3 = context->elementComplexCreate(eins, names, arraySizesPtr);
439    ASSERT_NE(Element(0), element3);
440
441    std::vector<Element> ids;
442    std::vector<std::string> namesOut;
443    std::vector<Size> arraySizesOut;
444    context->elementGetSubElements(element3, 2, [&](const hidl_vec<Element>& _ids,
445                                                    const hidl_vec<hidl_string>& _names,
446                                                    const hidl_vec<Size>& _arraySizes){
447                                                        ids = _ids;
448                                                        namesOut.push_back(_names[0]);
449                                                        namesOut.push_back(_names[1]);
450                                                        arraySizesOut = _arraySizes;
451                                                    });
452    EXPECT_EQ(element1, ids[0]);
453    EXPECT_EQ(element2, ids[1]);
454    EXPECT_EQ("first", namesOut[0]);
455    EXPECT_EQ("second", namesOut[1]);
456    EXPECT_EQ(Size(1), arraySizesOut[0]);
457    EXPECT_EQ(Size(1), arraySizesOut[1]);
458
459    // 1 x (uint8_t, uint32_t)
460    Type type = context->typeCreate(element3, 1, 0, 0, false, false, YuvFormat::YUV_NONE);
461    ASSERT_NE(Type(0), type);
462
463    // 1 x (uint8_t, uint32_t)
464    Allocation allocation = context->allocationCreateTyped(type, AllocationMipmapControl::NONE,
465                                                           (int)AllocationUsageType::SCRIPT,
466                                                           (Ptr)nullptr);
467    ASSERT_NE(Allocation(0), allocation);
468
469    std::vector<uint32_t> dataIn(1), dataOut(1);
470    std::generate(dataIn.begin(), dataIn.end(), [](){ static uint32_t val = 0; return val++; });
471    hidl_vec<uint8_t> _data;
472    _data.setToExternal((uint8_t*)dataIn.data(), dataIn.size()*sizeof(uint32_t));
473    context->allocationElementWrite(allocation, 0, 0, 0, 0, _data, 1);
474    context->allocationElementRead(allocation, 0, 0, 0, 0, (Ptr)dataOut.data(),
475                                   (Size)dataOut.size()*sizeof(uint32_t), 1);
476    EXPECT_EQ(dataIn, dataOut);
477}
478