• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2017 The Khronos Group Inc.
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 #include "../testBase.h"
17 #include "../common.h"
18 
19 extern int test_copy_image_generic( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo,
20                                    const size_t sourcePos[], const size_t destPos[], const size_t regionSize[], MTdata d );
21 
set_image_dimensions(image_descriptor * imageInfo,size_t width,size_t height,size_t arraySize,size_t rowPadding,size_t slicePadding)22 static void set_image_dimensions( image_descriptor *imageInfo, size_t width, size_t height, size_t arraySize, size_t rowPadding, size_t slicePadding )
23 {
24     size_t pixelSize = get_pixel_size( imageInfo->format );
25 
26     imageInfo->width = width;
27     imageInfo->height = height;
28     imageInfo->arraySize = arraySize;
29     imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
30 
31     if (gEnablePitch)
32     {
33         do {
34             rowPadding++;
35             imageInfo->rowPitch = imageInfo->width * pixelSize + rowPadding;
36         } while ((imageInfo->rowPitch % pixelSize) != 0);
37     }
38 
39     if (arraySize == 0)
40     {
41         imageInfo->type = CL_MEM_OBJECT_IMAGE2D;
42         imageInfo->slicePitch = 0;
43     }
44     else
45     {
46         imageInfo->type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
47         imageInfo->slicePitch = imageInfo->rowPitch * (imageInfo->height + slicePadding);
48     }
49 }
50 
51 
test_copy_image_size_2D_2D_array(cl_context context,cl_command_queue queue,image_descriptor * srcImageInfo,image_descriptor * dstImageInfo,MTdata d)52 int test_copy_image_size_2D_2D_array( cl_context context, cl_command_queue queue, image_descriptor *srcImageInfo, image_descriptor *dstImageInfo, MTdata d )
53 {
54     size_t sourcePos[ 4 ] = { 0 }, destPos[ 4 ] = { 0 }, regionSize[ 3 ];
55     int ret = 0, retCode;
56 
57     image_descriptor *threeImage, *twoImage;
58 
59     if( srcImageInfo->arraySize > 0 )
60     {
61         threeImage = srcImageInfo;
62         twoImage = dstImageInfo;
63     }
64     else
65     {
66         threeImage = dstImageInfo;
67         twoImage = srcImageInfo;
68     }
69 
70     size_t twoImage_lod = 0, twoImage_width_lod = twoImage->width, twoImage_row_pitch_lod;
71     size_t twoImage_height_lod = twoImage->height;
72     size_t threeImage_lod = 0, threeImage_width_lod = threeImage->width, threeImage_row_pitch_lod, threeImage_slice_pitch_lod;
73     size_t threeImage_height_lod = threeImage->height;
74     size_t width_lod, height_lod;
75     size_t twoImage_max_mip_level,threeImage_max_mip_level;
76 
77     if( gTestMipmaps )
78     {
79         twoImage_max_mip_level = twoImage->num_mip_levels;
80         threeImage_max_mip_level = threeImage->num_mip_levels;
81         // Work at random mip levels
82         twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
83         threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
84         twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
85         threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
86         twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
87         threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
88         twoImage_row_pitch_lod = twoImage_width_lod * get_pixel_size( twoImage->format );
89         threeImage_row_pitch_lod = threeImage_width_lod * get_pixel_size( threeImage->format );
90         threeImage_slice_pitch_lod = threeImage_height_lod * threeImage_row_pitch_lod;
91     }
92     width_lod  = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
93     height_lod  = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
94 
95     // First, try just a full covering region
96     sourcePos[ 0 ] = sourcePos[ 1 ] = sourcePos[ 2 ] = sourcePos[ 3 ] = 0;
97     destPos[ 0 ] = destPos[ 1 ] = destPos[ 2 ] = destPos[ 3 ] = 0;
98     regionSize[ 0 ] = width_lod;
99     regionSize[ 1 ] = height_lod;
100     regionSize[ 2 ] = 1;
101 
102     if( srcImageInfo->arraySize == 0 )
103     {
104         // 2D to 2D array
105         destPos[ 2 ] = (size_t)random_in_range( 0, (int)dstImageInfo->arraySize - 1, d );
106         if(gTestMipmaps)
107         {
108             sourcePos[ 2 ] = twoImage_lod;
109             destPos[ 3 ] = threeImage_lod;
110             regionSize[ 0 ] = width_lod;
111             regionSize[ 1 ] = height_lod;
112         }
113     }
114     else
115     {
116         // 2D array to 2D
117         sourcePos[ 2 ] = (size_t)random_in_range( 0, (int)srcImageInfo->arraySize - 1, d );
118         if(gTestMipmaps)
119         {
120             sourcePos[ 3 ] = threeImage_lod;
121             destPos[ 2 ] = twoImage_lod;
122             regionSize[ 0 ] = width_lod;
123             regionSize[ 1 ] = height_lod;
124         }
125     }
126 
127     retCode = test_copy_image_generic( context, queue, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
128     if( retCode < 0 )
129         return retCode;
130     else
131         ret += retCode;
132 
133     // Now try a sampling of different random regions
134     for( int i = 0; i < 8; i++ )
135     {
136         if( gTestMipmaps )
137         {
138             // Work at a random mip level
139             twoImage_lod = (size_t)random_in_range( 0, twoImage_max_mip_level ? twoImage_max_mip_level - 1 : 0, d );
140             threeImage_lod = (size_t)random_in_range( 0, threeImage_max_mip_level ? threeImage_max_mip_level - 1 : 0, d );
141             twoImage_width_lod = ( twoImage->width >> twoImage_lod )? ( twoImage->width >> twoImage_lod ) : 1;
142             threeImage_width_lod = ( threeImage->width >> threeImage_lod )? ( threeImage->width >> threeImage_lod ) : 1;
143             twoImage_height_lod = ( twoImage->height >> twoImage_lod )? ( twoImage->height >> twoImage_lod ) : 1;
144             threeImage_height_lod = ( threeImage->height >> threeImage_lod )? ( threeImage->height >> threeImage_lod ) : 1;
145             width_lod  = ( twoImage_width_lod > threeImage_width_lod ) ? threeImage_width_lod : twoImage_width_lod;
146             height_lod  = ( twoImage_height_lod > threeImage_height_lod ) ? threeImage_height_lod : twoImage_height_lod;
147         }
148         // Pick a random size
149         regionSize[ 0 ] = random_in_ranges( 8, srcImageInfo->width, dstImageInfo->width, d );
150         regionSize[ 1 ] = random_in_ranges( 8, srcImageInfo->height, dstImageInfo->height, d );
151         if( gTestMipmaps )
152         {
153             regionSize[ 0 ] = ( width_lod > 8 ) ? random_in_range( 8, width_lod, d ) : width_lod;
154             regionSize[ 1 ] = ( height_lod > 8) ? random_in_range( 8, height_lod, d ): height_lod;
155         }
156 
157         // Now pick positions within valid ranges
158         sourcePos[ 0 ] = ( srcImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
159         sourcePos[ 1 ] = ( srcImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
160         sourcePos[ 2 ] = ( srcImageInfo->arraySize > 0 ) ? (size_t)random_in_range( 0, (int)( srcImageInfo->arraySize - 1 ), d ) : gTestMipmaps ? twoImage_lod : 0;
161         if (gTestMipmaps)
162         {
163             if( srcImageInfo->arraySize > 0 )
164             {
165                 sourcePos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
166                 sourcePos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
167                 sourcePos[ 3 ] = threeImage_lod;
168             }
169             else
170             {
171                 sourcePos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
172                 sourcePos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
173 
174             }
175         }
176 
177         destPos[ 0 ] = ( dstImageInfo->width > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->width - regionSize[ 0 ] - 1 ), d ) : 0;
178         destPos[ 1 ] = ( dstImageInfo->height > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->height - regionSize[ 1 ] - 1 ), d ) : 0;
179         destPos[ 2 ] = ( dstImageInfo->arraySize > 0 ) ? (size_t)random_in_range( 0, (int)( dstImageInfo->arraySize - 1 ), d ) : gTestMipmaps ? twoImage_lod : 0;
180         if (gTestMipmaps)
181         {
182             if( dstImageInfo->arraySize > 0 )
183             {
184                 destPos[ 0 ] = ( threeImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
185                 destPos[ 1 ] = ( threeImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( threeImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
186                 destPos[ 3 ] = threeImage_lod;
187             }
188             else
189             {
190                 destPos[ 0 ] = ( twoImage_width_lod > regionSize[ 0 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_width_lod - regionSize[ 0 ] - 1 ), d ) : 0;
191                 destPos[ 1 ] = ( twoImage_height_lod > regionSize[ 1 ] ) ? (size_t)random_in_range( 0, (int)( twoImage_height_lod - regionSize[ 1 ] - 1 ), d ) : 0;
192 
193             }
194         }
195 
196         // Go for it!
197         retCode = test_copy_image_generic( context, queue, srcImageInfo, dstImageInfo, sourcePos, destPos, regionSize, d );
198         if( retCode < 0 )
199             return retCode;
200         else
201             ret += retCode;
202     }
203 
204     return ret;
205 }
206 
207 
test_copy_image_set_2D_2D_array(cl_device_id device,cl_context context,cl_command_queue queue,cl_image_format * format,bool reverse=false)208 int test_copy_image_set_2D_2D_array( cl_device_id device, cl_context context, cl_command_queue queue, cl_image_format *format, bool reverse = false )
209 {
210     size_t maxWidth, maxHeight, maxArraySize;
211     cl_ulong maxAllocSize, memSize;
212     image_descriptor srcImageInfo = { 0 };
213     image_descriptor dstImageInfo = { 0 };
214     RandomSeed  seed( gRandomSeed );
215 
216     srcImageInfo.format = dstImageInfo.format = format;
217 
218     int error = clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof( maxWidth ), &maxWidth, NULL );
219     error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof( maxHeight ), &maxHeight, NULL );
220     error |= clGetDeviceInfo( device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof( maxArraySize ), &maxArraySize, NULL );
221     error |= clGetDeviceInfo( device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof( maxAllocSize ), &maxAllocSize, NULL );
222     error |= clGetDeviceInfo( device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof( memSize ), &memSize, NULL );
223     test_error( error, "Unable to get max image 2D size from device" );
224 
225     if (memSize > (cl_ulong)SIZE_MAX) {
226       memSize = (cl_ulong)SIZE_MAX;
227       maxAllocSize = (cl_ulong)SIZE_MAX;
228     }
229 
230     if( gTestSmallImages )
231     {
232         for( dstImageInfo.width = 4; dstImageInfo.width < 17; dstImageInfo.width++ )
233         {
234             for( dstImageInfo.height = 4; dstImageInfo.height < 13; dstImageInfo.height++ )
235             {
236                 for( dstImageInfo.arraySize = 4; dstImageInfo.arraySize < 9; dstImageInfo.arraySize++ )
237                 {
238                     size_t rowPadding = gEnablePitch ? 256 : 0;
239                     size_t slicePadding = gEnablePitch ? 3 : 0;
240 
241                     set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding );
242                     set_image_dimensions( &srcImageInfo, dstImageInfo.width, dstImageInfo.height, 0, rowPadding, slicePadding );
243 
244                     if (gTestMipmaps)
245                     {
246                       srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed);
247                       srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D;
248                       dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed);
249                       dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
250                       srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format );
251                       srcImageInfo.slicePitch = 0;
252                       dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format );
253                       dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height;
254                     }
255 
256                     if( gDebugTrace )
257                     {
258                         if (reverse)
259                             log_info( "   at size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
260                         else
261                             log_info( "   at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
262                     }
263                     int ret;
264                     if( reverse )
265                         ret = test_copy_image_size_2D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed );
266                     else
267                         ret = test_copy_image_size_2D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed );
268                     if( ret )
269                         return -1;
270                 }
271             }
272         }
273     }
274     else if( gTestMaxImages )
275     {
276         // Try a specific set of maximum sizes
277         size_t numberOfSizes2DArray, numberOfSizes2D;
278         size_t sizes2DArray[100][3], sizes2D[100][3];
279 
280         // Try to allocate a bit smaller images because we need the 2D ones as well for the copy.
281         get_max_sizes(&numberOfSizes2DArray, 100, sizes2DArray, maxWidth, maxHeight, 1, maxArraySize, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D_ARRAY, dstImageInfo.format);
282         get_max_sizes(&numberOfSizes2D, 100, sizes2D, maxWidth, maxHeight, 1, 1, maxAllocSize/2, memSize/2, CL_MEM_OBJECT_IMAGE2D, dstImageInfo.format);
283 
284         for( size_t i = 0; i < numberOfSizes2D; i++ )
285         {
286           for( size_t j = 0; j < numberOfSizes2DArray; j++ )
287           {
288             size_t rowPadding = gEnablePitch ? 256 : 0;
289             size_t slicePadding = gEnablePitch ? 3 : 0;
290 
291             set_image_dimensions( &dstImageInfo, sizes2DArray[ j ][ 0 ], sizes2DArray[ j ][ 1 ], sizes2DArray[ j ][ 2 ], rowPadding, slicePadding );
292             set_image_dimensions( &srcImageInfo, sizes2D[ i ][ 0 ], sizes2D[ i ][ 1 ], 0, rowPadding, slicePadding );
293 
294             cl_ulong dstSize = get_image_size(&dstImageInfo);
295             cl_ulong srcSize = get_image_size(&srcImageInfo);
296 
297             if (gTestMipmaps)
298             {
299               srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed);
300               srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D;
301               dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed);
302               dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
303               srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format );
304               srcImageInfo.slicePitch = 0;
305               dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format );
306               dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height;
307               dstSize = 4 * compute_mipmapped_image_size( dstImageInfo );
308               srcSize = 4 * compute_mipmapped_image_size( srcImageInfo );
309             }
310 
311             if( dstSize < maxAllocSize && dstSize < ( memSize / 3 ) && srcSize < maxAllocSize && srcSize < ( memSize / 3 ) )
312             {
313               if (reverse)
314                 log_info( "Testing %d x %d x %d to %d x %d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
315               else
316                 log_info( "Testing %d x %d to %d x %d x %d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
317 
318               if( gDebugTrace )
319               {
320                 if (reverse)
321                   log_info( "   at max size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
322                 else
323                   log_info( "   at max size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
324               }
325               int ret;
326               if( reverse )
327                 ret = test_copy_image_size_2D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed );
328               else
329                 ret = test_copy_image_size_2D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed );
330               if( ret )
331                 return -1;
332             }
333             else
334             {
335               if (reverse)
336                 log_info("Not testing max size %d x %d x %d to %d x %d due to memory constraints.\n",
337                 (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height);
338               else
339                 log_info("Not testing max size %d x %d to %d x %d x %d due to memory constraints.\n",
340                 (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize);
341             }
342 
343           }
344         }
345     }
346     else
347     {
348         for( int i = 0; i < NUM_IMAGE_ITERATIONS; i++ )
349         {
350             cl_ulong srcSize, dstSize;
351             size_t rowPadding = gEnablePitch ? 256 : 0;
352             size_t slicePadding = gEnablePitch ? 3 : 0;
353             // Loop until we get a size that a) will fit in the max alloc size and b) that an allocation of that
354             // image, the result array, plus offset arrays, will fit in the global ram space
355             do
356             {
357                 dstImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
358                 dstImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
359                 dstImageInfo.arraySize = (size_t)random_log_in_range( 16, (int)maxArraySize / 32, seed );
360                 srcImageInfo.width = (size_t)random_log_in_range( 16, (int)maxWidth / 32, seed );
361                 srcImageInfo.height = (size_t)random_log_in_range( 16, (int)maxHeight / 32, seed );
362 
363                 if (gTestMipmaps)
364                 {
365                     srcImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(srcImageInfo.width, srcImageInfo.height, 0), seed);
366                     srcImageInfo.type = CL_MEM_OBJECT_IMAGE2D;
367                     dstImageInfo.num_mip_levels = (cl_uint) random_log_in_range(2, (int)compute_max_mip_levels(dstImageInfo.width, dstImageInfo.height, 0), seed);
368                     dstImageInfo.type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
369                     srcImageInfo.rowPitch = srcImageInfo.width * get_pixel_size( srcImageInfo.format );
370                     srcImageInfo.slicePitch = 0;
371                     dstImageInfo.rowPitch = dstImageInfo.width * get_pixel_size( dstImageInfo.format );
372                     dstImageInfo.slicePitch = dstImageInfo.rowPitch * dstImageInfo.height;
373                     srcSize = 4 * compute_mipmapped_image_size( srcImageInfo );
374                     dstSize = 4 * compute_mipmapped_image_size( dstImageInfo );
375                 }
376                 else
377                 {
378                     set_image_dimensions( &srcImageInfo, srcImageInfo.width, srcImageInfo.height, 0, rowPadding, slicePadding );
379                     set_image_dimensions( &dstImageInfo, dstImageInfo.width, dstImageInfo.height, dstImageInfo.arraySize, rowPadding, slicePadding );
380 
381                     srcSize = (cl_ulong)srcImageInfo.rowPitch * (cl_ulong)srcImageInfo.height * 4;
382                     dstSize = (cl_ulong)dstImageInfo.slicePitch * (cl_ulong)dstImageInfo.arraySize * 4;
383                 }
384             } while( srcSize > maxAllocSize || ( srcSize * 3 ) > memSize || dstSize > maxAllocSize || ( dstSize * 3 ) > memSize);
385 
386             if( gDebugTrace )
387             {
388                 if (reverse)
389                     log_info( "   at size %d,%d,%d to %d,%d\n", (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize, (int)srcImageInfo.width, (int)srcImageInfo.height );
390                 else
391                     log_info( "   at size %d,%d to %d,%d,%d\n", (int)srcImageInfo.width, (int)srcImageInfo.height, (int)dstImageInfo.width, (int)dstImageInfo.height, (int)dstImageInfo.arraySize );
392             }
393             int ret;
394             if( reverse )
395                 ret = test_copy_image_size_2D_2D_array( context, queue, &dstImageInfo, &srcImageInfo, seed );
396             else
397                 ret = test_copy_image_size_2D_2D_array( context, queue, &srcImageInfo, &dstImageInfo, seed );
398             if( ret )
399                 return -1;
400         }
401     }
402 
403     return 0;
404 }
405