• 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 #include "harness/testHarness.h"
19 #include "harness/typeWrappers.h"
20 
21 #include "procs.h"
22 #include "utils.h"
23 
24 static const cl_uint MIN_DEVICE_PREFFERED_QUEUE_SIZE =  16 * 1024;
25 static const cl_uint MAX_DEVICE_QUEUE_SIZE           = 256 * 1024;
26 static const cl_uint MAX_DEVICE_EMBEDDED_QUEUE_SIZE  =  64 * 1024;
27 
28 #ifdef CL_VERSION_2_0
29 
test_device_info(cl_device_id device,cl_context context,cl_command_queue queue,int num_elements)30 int test_device_info(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements)
31 {
32     cl_int err_ret;
33     int embedded = 0;
34     size_t ret_len;
35     char profile[32] = {0};
36     cl_command_queue_properties properties;
37     cl_uint size;
38 
39     err_ret = clGetDeviceInfo(device, CL_DEVICE_PROFILE, sizeof(profile), profile, &ret_len);
40     test_error(err_ret, "clGetDeviceInfo(CL_DEVICE_PROFILE) failed");
41     if(ret_len < sizeof(profile) && strcmp(profile, "FULL_PROFILE") == 0) embedded = 0;
42     else if(ret_len < sizeof(profile) && strcmp(profile, "EMBEDDED_PROFILE") == 0) embedded = 1;
43     else
44     {
45         log_error("Unknown device profile: %s\n", profile);
46         return -1;
47     }
48 
49     err_ret = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, sizeof(properties), &properties, &ret_len);
50     test_error(err_ret, "clGetDeviceInfo(CL_DEVICE_QUEUE_ON_HOST_PROPERTIES) failed");
51     if(!(properties&CL_QUEUE_PROFILING_ENABLE))
52     {
53         log_error("Host command-queue does not support mandated minimum capability: CL_QUEUE_PROFILING_ENABLE\n");
54         return -1;
55     }
56 
57     err_ret = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, sizeof(properties), &properties, &ret_len);
58     test_error(err_ret, "clGetDeviceInfo(CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES) failed");
59     if(!(properties&CL_QUEUE_PROFILING_ENABLE))
60     {
61         log_error("Device command-queue does not support mandated minimum capability: CL_QUEUE_PROFILING_ENABLE\n");
62         return -1;
63     }
64     if(!(properties&CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE))
65     {
66         log_error("Device command-queue does not support mandated minimum capability: CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE\n");
67         return -1;
68     }
69 
70     err_ret = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, sizeof(size), &size, &ret_len);
71     test_error(err_ret, "clGetDeviceInfo(CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE) failed");
72     if(size < MIN_DEVICE_PREFFERED_QUEUE_SIZE)
73     {
74         log_error("Device command-queue preferred size is less than minimum %dK: %dK\n", MIN_DEVICE_PREFFERED_QUEUE_SIZE/1024, size/1024);
75         return -1;
76     }
77 
78     err_ret = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, sizeof(size), &size, &ret_len);
79     test_error(err_ret, "clGetDeviceInfo(CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE) failed");
80     if(size < (embedded ? MAX_DEVICE_EMBEDDED_QUEUE_SIZE : MAX_DEVICE_QUEUE_SIZE))
81     {
82         log_error("Device command-queue maximum size is less than minimum %dK: %dK\n", (embedded ? MAX_DEVICE_EMBEDDED_QUEUE_SIZE : MAX_DEVICE_QUEUE_SIZE)/1024, size/1024);
83         return -1;
84     }
85 
86     err_ret = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_QUEUES, sizeof(size), &size, &ret_len);
87     test_error(err_ret, "clGetDeviceInfo(CL_DEVICE_MAX_ON_DEVICE_QUEUES) failed");
88     if(size < 1)
89     {
90         log_error("Maximum number of device queues is less than minimum 1: %d\n", size);
91         return -1;
92     }
93 
94     err_ret = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_EVENTS, sizeof(size), &size, &ret_len);
95     test_error(err_ret, "clGetDeviceInfo(CL_DEVICE_MAX_ON_DEVICE_EVENTS) failed");
96     if(size < 1024)
97     {
98         log_error("Maximum number of events in use by a device queue is less than minimum 1024: %d\n", size);
99         return -1;
100     }
101 
102     return 0;
103 }
104 
105 #endif
106 
107