1 //
2 // Copyright (c) 2020 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 "harness/typeWrappers.h"
18
19 #include <vector>
20
21 struct test_query_pipe_properties_data
22 {
23 std::vector<cl_pipe_properties> properties;
24 std::string description;
25 };
26
create_pipe_and_check_array_properties(cl_context context,const test_query_pipe_properties_data & test_case)27 static int create_pipe_and_check_array_properties(
28 cl_context context, const test_query_pipe_properties_data& test_case)
29 {
30 log_info("TC description: %s\n", test_case.description.c_str());
31
32 cl_int error = CL_SUCCESS;
33
34 clMemWrapper test_pipe;
35
36 if (test_case.properties.size() > 0)
37 {
38 test_pipe = clCreatePipe(context, CL_MEM_HOST_NO_ACCESS, 4, 4,
39 test_case.properties.data(), &error);
40 test_error(error, "clCreatePipe failed");
41 }
42 else
43 {
44 test_pipe =
45 clCreatePipe(context, CL_MEM_HOST_NO_ACCESS, 4, 4, NULL, &error);
46 test_error(error, "clCreatePipe failed");
47 }
48
49 std::vector<cl_pipe_properties> check_properties;
50 size_t set_size = 0;
51
52 error = clGetPipeInfo(test_pipe, CL_PIPE_PROPERTIES, 0, NULL, &set_size);
53 test_error(error,
54 "clGetPipeInfo failed asking for "
55 "CL_PIPE_PROPERTIES size.");
56
57 if (set_size == 0 && test_case.properties.size() == 0)
58 {
59 return TEST_PASS;
60 }
61 if (set_size != test_case.properties.size() * sizeof(cl_pipe_properties))
62 {
63 log_error("ERROR: CL_PIPE_PROPERTIES size is %d, expected %d.\n",
64 set_size,
65 test_case.properties.size() * sizeof(cl_pipe_properties));
66 return TEST_FAIL;
67 }
68
69 log_error("Unexpected test case size. This test needs to be updated to "
70 "compare pipe properties.\n");
71 return TEST_FAIL;
72 }
73
test_pipe_properties_queries(cl_device_id deviceID,cl_context context,cl_command_queue queue,int num_elements)74 int test_pipe_properties_queries(cl_device_id deviceID, cl_context context,
75 cl_command_queue queue, int num_elements)
76 {
77 cl_int error = CL_SUCCESS;
78
79 cl_bool pipeSupport = CL_FALSE;
80 error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_SUPPORT,
81 sizeof(pipeSupport), &pipeSupport, NULL);
82 test_error(error, "Unable to query CL_DEVICE_PIPE_SUPPORT");
83
84 if (pipeSupport == CL_FALSE)
85 {
86 return TEST_SKIPPED_ITSELF;
87 }
88
89 int result = TEST_PASS;
90
91 std::vector<test_query_pipe_properties_data> test_cases;
92 test_cases.push_back({ {}, "NULL properties" });
93
94 for (auto test_case : test_cases)
95 {
96 result |= create_pipe_and_check_array_properties(context, test_case);
97 }
98
99 return result;
100 }
101