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(work_group_all),
28 ADD_TEST(work_group_any),
29 ADD_TEST(work_group_reduce_add),
30 ADD_TEST(work_group_reduce_min),
31 ADD_TEST(work_group_reduce_max),
32 ADD_TEST(work_group_scan_inclusive_add),
33 ADD_TEST(work_group_scan_inclusive_min),
34 ADD_TEST(work_group_scan_inclusive_max),
35 ADD_TEST(work_group_scan_exclusive_add),
36 ADD_TEST(work_group_scan_exclusive_min),
37 ADD_TEST(work_group_scan_exclusive_max),
38 ADD_TEST(work_group_broadcast_1D),
39 ADD_TEST(work_group_broadcast_2D),
40 ADD_TEST(work_group_broadcast_3D),
41 };
42
43 const int test_num = ARRAY_SIZE(test_list);
44
InitCL(cl_device_id device)45 test_status InitCL(cl_device_id device) {
46 auto version = get_device_cl_version(device);
47 auto expected_min_version = Version(2, 0);
48 if (version < expected_min_version)
49 {
50 version_expected_info("Test", expected_min_version.to_string().c_str(), version.to_string().c_str());
51 return TEST_SKIP;
52 }
53
54 if (version >= Version(3, 0))
55 {
56 int error;
57 cl_bool isSupported;
58 error = clGetDeviceInfo(
59 device, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT,
60 sizeof(isSupported), &isSupported, NULL);
61 if (error != CL_SUCCESS)
62 {
63 print_error(error,
64 "Unable to query support for collective functions");
65 return TEST_FAIL;
66 }
67
68 if (isSupported == CL_FALSE)
69 {
70 return TEST_SKIP;
71 }
72 }
73
74 return TEST_PASS;
75 }
76
main(int argc,const char * argv[])77 int main(int argc, const char *argv[]) {
78 return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0, InitCL);
79 }
80
81