• 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 #ifndef _utils_h_
17 #define _utils_h_
18 
19 #include "harness/testHarness.h"
20 #include "harness/mt19937.h"
21 
22 #include <string>
23 
24 #ifndef CL_VERSION_2_0
25 #define CL_VERSION_2_0
26 #endif
27 
28 #define MAX_QUEUES    1000 // Max number of queues to test
29 #define MAX_GWS       256 // Global Work Size (must be multiple of 16)
30 
31 
32 #define NL "\n"
33 #define arr_size(a) (sizeof(a)/sizeof(a[0]))
34 #define check_error(errCode,msg,...) ((errCode != CL_SUCCESS) ? (log_error("ERROR: " msg "! (%s:%d)\n", ## __VA_ARGS__, __FILE__, __LINE__), 1) : 0)
35 
36 #define KERNEL(name) { arr_size(name), name, #name }
37 
38 extern std::string gKernelName;
39 
40 typedef struct
41 {
42     unsigned int num_lines;
43     const char** lines;
44     const char*  kernel_name;
45 } kernel_src;
46 
47 typedef int (*fn_check)(cl_int*, cl_int, cl_int);
48 
49 typedef struct
50 {
51     kernel_src src;
52     fn_check   check;
53 } kernel_src_check;
54 
55 typedef struct
56 {
57     size_t size;
58     const void*  ptr;
59 } kernel_arg;
60 
61 typedef struct
62 {
63   kernel_src src;
64   cl_int dim;
65   cl_bool localSize;
66   cl_bool offset;
67 } kernel_src_dim_check;
68 
69 int run_single_kernel(cl_context context, cl_command_queue queue, const char** source, unsigned int num_lines, const char* kernel_name, void* results, size_t res_size);
70 int run_single_kernel_args(cl_context context, cl_command_queue queue, const char** source, unsigned int num_lines, const char* kernel_name, void* results, size_t res_size, cl_uint num_args, kernel_arg* args);
71 int run_n_kernel_args(cl_context context, cl_command_queue queue, const char** source, unsigned int num_lines, const char* kernel_name, size_t local, size_t global, void* results, size_t res_size, cl_uint num_args, kernel_arg* args);
72 
73 #endif
74