• 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 "harness/compat.h"
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <sys/types.h>
22 #include <sys/stat.h>
23 
24 #include "procs.h"
25 
26 
27 
test_array_info_size(cl_device_id deviceID,cl_context context,cl_command_queue queue,int num_elements)28 int test_array_info_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
29 {
30     cl_mem          memobj;
31     cl_int          err;
32     size_t          w = 32, h = 32, d = 32;
33     size_t          retSize;
34     size_t          elementSize = sizeof( cl_int );
35 
36     memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, elementSize * w * h * d,
37                             NULL, &err);
38     test_error(err, "clCreateBuffer failed.");
39 
40     err = clGetMemObjectInfo(memobj, CL_MEM_SIZE, sizeof( size_t ), (void *)&retSize, NULL);
41     if ( err ){
42         log_error( "Error calling clGetMemObjectInfo(): %d\n", err );
43         clReleaseMemObject(memobj);
44         return -1;
45     }
46     if ( (elementSize * w * h * d) != retSize ) {
47         log_error( "Error in clGetMemObjectInfo() check of size\n" );
48         clReleaseMemObject(memobj);
49         return -1;
50     }
51     else{
52         log_info( " CL_MEM_SIZE passed.\n" );
53     }
54 
55     // cleanup
56     clReleaseMemObject(memobj);
57 
58     return err;
59 
60 }   // end testArrayElementSize()
61 
62 
63 // FIXME: need to test other flags
64 
65