blob: 8154a7954f39e44fd789af6f029d43d6210ad8a0 [file] [log] [blame]
Georgios Pinitasc3c352e2021-03-18 10:59:40 +00001/*
2 * Copyright (c) 2021 Arm Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "tests/validation/fixtures/UNIT/QueueFixture.h"
25
26#include "arm_compute/AclOpenClExt.h"
27#include "src/gpu/cl/ClQueue.h"
28
29namespace arm_compute
30{
31namespace test
32{
33namespace validation
34{
35TEST_SUITE(CL)
36TEST_SUITE(UNIT)
37TEST_SUITE(Queue)
38
39EMPTY_BODY_FIXTURE_TEST_CASE(CreateQueueWithInvalidContext, CreateQueueWithInvalidContextFixture, framework::DatasetMode::ALL)
40EMPTY_BODY_FIXTURE_TEST_CASE(CreateQueuerWithInvalidOptions, CreateQueuerWithInvalidOptionsFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
41EMPTY_BODY_FIXTURE_TEST_CASE(DestroyInvalidQueue, DestroyInvalidQueueFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
42EMPTY_BODY_FIXTURE_TEST_CASE(SimpleQueue, SimpleQueueFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
43
44TEST_CASE(KhrQueuePriorities, framework::DatasetMode::ALL)
45{
46 acl::StatusCode err = acl::StatusCode::Success;
47
48 acl::Context ctx(acl::Target::GpuOcl, &err);
49 ARM_COMPUTE_ASSERT(err == acl::StatusCode::Success);
50
51 acl::Queue queue(ctx, &err);
52 ARM_COMPUTE_ASSERT(err == acl::StatusCode::Success);
53
54 cl_device_id cl_dev;
55 auto status = AclGetClDevice(ctx.get(), &cl_dev);
56 ARM_COMPUTE_ASSERT(status == AclSuccess);
57
58 std::string extensions = cl::Device(cl_dev).getInfo<CL_DEVICE_EXTENSIONS>();
59 if(extensions.find("cl_khr_priority_hints") != std::string::npos)
60 {
61 cl_int error = CL_SUCCESS;
62
63 cl_context cl_ctx;
64 auto status = AclGetClContext(ctx.get(), &cl_ctx);
65 ARM_COMPUTE_ASSERT(status == AclSuccess);
66
67 /* Check a queue with high priority */
68 cl_queue_properties queue_properties[] = { CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0 };
69 cl_command_queue priority_queue = clCreateCommandQueueWithProperties(cl_ctx, cl_dev, queue_properties, &error);
70 ARM_COMPUTE_ASSERT(error == CL_SUCCESS);
71
72 clReleaseCommandQueue(priority_queue);
73 }
74}
75
76TEST_SUITE_END() // Queue
77TEST_SUITE_END() // UNIT
78TEST_SUITE_END() // CL
79} // namespace validation
80} // namespace test
81} // namespace arm_compute