xref: /aosp_15_r20/external/OpenCL-CTS/test_conformance/workgroups/main.cpp (revision 6467f958c7de8070b317fc65bcb0f6472e388d82)
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 "harness/testHarness.h"
19 #include "procs.h"
20 #include <stdio.h>
21 #include <string.h>
22 #if !defined(_WIN32)
23 #include <unistd.h>
24 #endif
25 
26 test_definition test_list[] = {
27     ADD_TEST_VERSION(work_group_all, Version(2, 0)),
28     ADD_TEST_VERSION(work_group_any, Version(2, 0)),
29     ADD_TEST_VERSION(work_group_reduce_add, Version(2, 0)),
30     ADD_TEST_VERSION(work_group_reduce_min, Version(2, 0)),
31     ADD_TEST_VERSION(work_group_reduce_max, Version(2, 0)),
32     ADD_TEST_VERSION(work_group_scan_inclusive_add, Version(2, 0)),
33     ADD_TEST_VERSION(work_group_scan_inclusive_min, Version(2, 0)),
34     ADD_TEST_VERSION(work_group_scan_inclusive_max, Version(2, 0)),
35     ADD_TEST_VERSION(work_group_scan_exclusive_add, Version(2, 0)),
36     ADD_TEST_VERSION(work_group_scan_exclusive_min, Version(2, 0)),
37     ADD_TEST_VERSION(work_group_scan_exclusive_max, Version(2, 0)),
38     ADD_TEST_VERSION(work_group_broadcast_1D, Version(2, 0)),
39     ADD_TEST_VERSION(work_group_broadcast_2D, Version(2, 0)),
40     ADD_TEST_VERSION(work_group_broadcast_3D, Version(2, 0)),
41     ADD_TEST(work_group_suggested_local_size_1D),
42     ADD_TEST(work_group_suggested_local_size_2D),
43     ADD_TEST(work_group_suggested_local_size_3D)
44 };
45 
46 const int test_num = ARRAY_SIZE(test_list);
47 
InitCL(cl_device_id device)48 test_status InitCL(cl_device_id device) {
49     auto version = get_device_cl_version(device);
50     auto expected_min_version = Version(1, 2);
51     if (version < expected_min_version)
52     {
53         version_expected_info("Test", "OpenCL",
54                               expected_min_version.to_string().c_str(),
55                               version.to_string().c_str());
56         return TEST_SKIP;
57     }
58 
59     if (version >= Version(3, 0))
60     {
61         int error;
62         cl_bool isSupported;
63         error = clGetDeviceInfo(
64             device, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT,
65             sizeof(isSupported), &isSupported, NULL);
66         if (error != CL_SUCCESS)
67         {
68             print_error(error,
69                         "Unable to query support for collective functions");
70             return TEST_FAIL;
71         }
72 
73         if (isSupported == CL_FALSE)
74         {
75             return TEST_SKIP;
76         }
77     }
78 
79   return TEST_PASS;
80 }
81 
main(int argc,const char * argv[])82 int main(int argc, const char *argv[]) {
83   return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0, InitCL);
84 }
85 
86