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 <stdio.h>
17 #include <string.h>
18
19 #if !defined(_WIN32)
20 #include <stdbool.h>
21 #endif
22
23 #include "harness/testHarness.h"
24 #include "harness/parseParameters.h"
25 #include "utils.h"
26 #include "procs.h"
27
28 std::string gKernelName;
29 int gWimpyMode = 0;
30
InitCL(cl_device_id device)31 test_status InitCL(cl_device_id device) {
32 auto version = get_device_cl_version(device);
33 auto expected_min_version = Version(2, 0);
34 if (version < expected_min_version)
35 {
36 version_expected_info("Test", "OpenCL",
37 expected_min_version.to_string().c_str(),
38 version.to_string().c_str());
39 return TEST_SKIP;
40 }
41
42 int error;
43 cl_uint max_queues_size;
44 error = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_QUEUES,
45 sizeof(max_queues_size), &max_queues_size, NULL);
46 if (error != CL_SUCCESS)
47 {
48 print_error(error, "Unable to get max queues on device");
49 return TEST_FAIL;
50 }
51
52 if ((max_queues_size == 0) && (version >= Version(3, 0)))
53 {
54 return TEST_SKIP;
55 }
56
57 return TEST_PASS;
58 }
59
60 test_definition test_list[] = {
61 ADD_TEST(device_info), ADD_TEST(device_queue),
62 ADD_TEST(execute_block), ADD_TEST(enqueue_block),
63 ADD_TEST(enqueue_nested_blocks), ADD_TEST(enqueue_wg_size),
64 ADD_TEST(enqueue_flags), ADD_TEST(enqueue_multi_queue),
65 ADD_TEST(host_multi_queue), ADD_TEST(enqueue_ndrange),
66 ADD_TEST(host_queue_order), ADD_TEST(enqueue_profiling),
67 };
68
69 const int test_num = ARRAY_SIZE( test_list );
70
main(int argc,const char * argv[])71 int main(int argc, const char *argv[])
72 {
73 argc = parseCustomParam(argc, argv);
74
75 for (int i = 0; i < argc; ++i) {
76 int argsRemoveNum = 0;
77 if ( strcmp(argv[i], "-kernelName") == 0 ) {
78 if((i + 1) > argc && argv[i + 1] == NULL) {
79 vlog( "Missing value for -kernelName argument\n");
80 return -1;
81 }
82
83 gKernelName = std::string(argv[i + 1]);
84 argsRemoveNum += 2;
85 }
86 if (strcmp(argv[i], "-w") == 0 ){
87 gWimpyMode = 1;
88 argsRemoveNum += 1;
89 }
90
91
92 if (argsRemoveNum > 0) {
93 for (int j = i; j < (argc - argsRemoveNum); ++j)
94 argv[j] = argv[j + argsRemoveNum];
95
96 argc -= argsRemoveNum;
97 --i;
98 }
99 }
100
101 return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0, InitCL);
102 }
103