• 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 "procs.h"
17 
18 const char* pipe_kernel_code = {
19     "__kernel void pipe_kernel(__write_only pipe int out_pipe)\n"
20     "{}\n" };
21 
test_pipe_info(cl_device_id deviceID,cl_context context,cl_command_queue queue,int num_elements)22 int test_pipe_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
23 {
24     clMemWrapper pipe;
25     cl_int err;
26     cl_uint pipe_width = 512;
27     cl_uint pipe_depth = 1024;
28     cl_uint returnVal;
29     clProgramWrapper program;
30     clKernelWrapper kernel;
31 
32     pipe = clCreatePipe(context, CL_MEM_HOST_NO_ACCESS, pipe_width, pipe_depth,
33                         NULL, &err);
34     test_error(err, "clCreatePipe failed.");
35 
36     err = clGetPipeInfo(pipe, CL_PIPE_PACKET_SIZE, sizeof(pipe_width),
37                         (void *)&returnVal, NULL);
38     test_error(err, "clGetPipeInfo failed.");
39 
40     if (pipe_width != returnVal)
41     {
42         log_error("Error in clGetPipeInfo() check of pipe packet size\n");
43         return -1;
44     }
45     else
46     {
47         log_info( " CL_PIPE_PACKET_SIZE passed.\n" );
48     }
49 
50     err = clGetPipeInfo(pipe, CL_PIPE_MAX_PACKETS, sizeof(pipe_depth), (void *)&returnVal, NULL);
51     test_error(err, "clGetPipeInfo failed.");
52 
53     if(pipe_depth != returnVal)
54     {
55         log_error( "Error in clGetPipeInfo() check of pipe max packets\n" );
56         return -1;
57     }
58     else
59     {
60         log_info( " CL_PIPE_MAX_PACKETS passed.\n" );
61     }
62 
63     err = create_single_kernel_helper_with_build_options(context, &program, &kernel, 1, (const char**)&pipe_kernel_code, "pipe_kernel", "-cl-std=CL2.0 -cl-kernel-arg-info");
64     test_error_ret(err, " Error creating program", -1);
65 
66     cl_kernel_arg_type_qualifier arg_type_qualifier = 0;
67     cl_kernel_arg_type_qualifier expected_type_qualifier = CL_KERNEL_ARG_TYPE_PIPE;
68     err = clGetKernelArgInfo( kernel, 0, CL_KERNEL_ARG_TYPE_QUALIFIER, sizeof(arg_type_qualifier), &arg_type_qualifier, NULL );
69     test_error_ret(err, " clSetKernelArgInfo failed", -1);
70     err = (arg_type_qualifier != expected_type_qualifier);
71 
72     if(err)
73     {
74         print_error(err, "ERROR: Bad type qualifier\n");
75         return -1;
76     }
77 
78     return err;
79 
80 }
81