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 <string.h>
20 #include "procs.h"
21 #include "harness/testHarness.h"
22 
23 MTdata gMTdata;
24 
25 test_definition test_list[] = {
26     ADD_TEST_VERSION(sub_group_info_ext, Version(2, 0)),
27     ADD_TEST_VERSION(sub_group_info_core, Version(2, 1)),
28     ADD_TEST_VERSION(work_item_functions_ext, Version(2, 0)),
29     ADD_TEST_VERSION(work_item_functions_core, Version(2, 1)),
30     ADD_TEST_VERSION(subgroup_functions_ext, Version(2, 0)),
31     ADD_TEST_VERSION(subgroup_functions_core, Version(2, 1)),
32     ADD_TEST_VERSION(barrier_functions_ext, Version(2, 0)),
33     ADD_TEST_VERSION(barrier_functions_core, Version(2, 1)),
34     ADD_TEST_VERSION(ifp_ext, Version(2, 0)),
35     ADD_TEST_VERSION(ifp_core, Version(2, 1)),
36     ADD_TEST(subgroup_functions_extended_types),
37     ADD_TEST(subgroup_functions_non_uniform_vote),
38     ADD_TEST(subgroup_functions_non_uniform_arithmetic),
39     ADD_TEST(subgroup_functions_ballot),
40     ADD_TEST(subgroup_functions_clustered_reduce),
41     ADD_TEST(subgroup_functions_shuffle),
42     ADD_TEST(subgroup_functions_shuffle_relative)
43 };
44 
45 const int test_num = ARRAY_SIZE(test_list);
46 
InitCL(cl_device_id device)47 static test_status InitCL(cl_device_id device)
48 {
49     auto version = get_device_cl_version(device);
50     test_status ret = TEST_PASS;
51     if (version >= Version(3, 0))
52     {
53         cl_uint max_sub_groups;
54         int error;
55 
56         error = clGetDeviceInfo(device, CL_DEVICE_MAX_NUM_SUB_GROUPS,
57                                 sizeof(max_sub_groups), &max_sub_groups, NULL);
58         if (error != CL_SUCCESS)
59         {
60             print_error(error, "Unable to get max number of subgroups");
61             return TEST_FAIL;
62         }
63 
64         if (max_sub_groups == 0)
65         {
66             ret = TEST_SKIP;
67         }
68     }
69     return ret;
70 }
71 
main(int argc,const char * argv[])72 int main(int argc, const char *argv[])
73 {
74     gMTdata = init_genrand(0);
75     return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0,
76                                    InitCL);
77 }
78