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 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include "harness/testHarness.h"
21
22 #if !defined(_WIN32)
23 #include <unistd.h>
24 #endif
25
26 #include "procs.h"
27
28 test_definition test_list[] = {
29 ADD_TEST( timer_resolution_queries ),
30 ADD_TEST( device_and_host_timers ),
31 };
32
InitCL(cl_device_id device)33 test_status InitCL(cl_device_id device)
34 {
35 auto version = get_device_cl_version(device);
36 auto expected_min_version = Version(2, 1);
37 cl_platform_id platform;
38 cl_ulong timer_res;
39 cl_int error;
40
41 if (version < expected_min_version)
42 {
43 version_expected_info("Test", "OpenCL",
44 expected_min_version.to_string().c_str(),
45 version.to_string().c_str());
46 return TEST_SKIP;
47 }
48
49 error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),
50 &platform, NULL);
51 if (error != CL_SUCCESS)
52 {
53 print_error(error, "Unable to get device platform");
54 return TEST_FAIL;
55 }
56
57 error = clGetPlatformInfo(platform, CL_PLATFORM_HOST_TIMER_RESOLUTION,
58 sizeof(timer_res), &timer_res, NULL);
59 if (error != CL_SUCCESS)
60 {
61 print_error(error, "Unable to get host timer capabilities");
62 return TEST_FAIL;
63 }
64
65 if ((timer_res == 0) && (version >= Version(3, 0)))
66 {
67 return TEST_SKIP;
68 }
69
70 return TEST_PASS;
71 }
72
73
74 const int test_num = ARRAY_SIZE( test_list );
75
main(int argc,const char * argv[])76 int main(int argc, const char *argv[])
77 {
78 return runTestHarnessWithCheck( argc, argv, test_num, test_list, false, 0, InitCL );
79 }
80
81