• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     version_expected_info("Test", expected_min_version.to_string().c_str(), version.to_string().c_str());
36     return TEST_SKIP;
37   }
38 
39   int error;
40   cl_uint max_queues_size;
41   error = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_QUEUES,
42                           sizeof(max_queues_size), &max_queues_size, NULL);
43   if (error != CL_SUCCESS) {
44     print_error(error, "Unable to get max queues on device");
45     return TEST_FAIL;
46   }
47 
48   if ((max_queues_size == 0) && (version >= Version(3, 0)))
49   {
50       return TEST_SKIP;
51   }
52 
53   return TEST_PASS;
54 }
55 
56 test_definition test_list[] = {
57     ADD_TEST( device_info ),
58     ADD_TEST( device_queue ),
59     ADD_TEST( execute_block ),
60     ADD_TEST( enqueue_block ),
61     ADD_TEST( enqueue_nested_blocks ),
62     ADD_TEST( enqueue_wg_size ),
63     ADD_TEST( enqueue_flags ),
64     ADD_TEST( enqueue_multi_queue ),
65     ADD_TEST( host_multi_queue ),
66     ADD_TEST( enqueue_ndrange ),
67     ADD_TEST( host_queue_order ),
68 };
69 
70 const int test_num = ARRAY_SIZE( test_list );
71 
main(int argc,const char * argv[])72 int main(int argc, const char *argv[])
73 {
74     argc = parseCustomParam(argc, argv);
75 
76     for (int i = 0; i < argc; ++i) {
77       int argsRemoveNum = 0;
78       if ( strcmp(argv[i], "-kernelName") == 0 ) {
79         if((i + 1) > argc && argv[i + 1] == NULL) {
80           vlog( "Missing value for -kernelName argument\n");
81           return -1;
82         }
83 
84         gKernelName = std::string(argv[i + 1]);
85         argsRemoveNum += 2;
86       }
87      if (strcmp(argv[i], "-w") == 0 ){
88         gWimpyMode = 1;
89         argsRemoveNum += 1;
90      }
91 
92 
93       if (argsRemoveNum > 0) {
94         for (int j = i; j < (argc - argsRemoveNum); ++j)
95           argv[j] = argv[j + argsRemoveNum];
96 
97         argc -= argsRemoveNum;
98         --i;
99       }
100     }
101 
102     return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0, InitCL);
103 }
104