xref: /aosp_15_r20/external/ComputeLibrary/tests/validation/gpu/unit/Queue.cpp (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1 /*
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 
29 namespace arm_compute
30 {
31 namespace test
32 {
33 namespace validation
34 {
35 TEST_SUITE(CL)
TEST_SUITE(UNIT)36 TEST_SUITE(UNIT)
37 TEST_SUITE(Queue)
38 
39 EMPTY_BODY_FIXTURE_TEST_CASE(CreateQueueWithInvalidContext, CreateQueueWithInvalidContextFixture, framework::DatasetMode::ALL)
40 EMPTY_BODY_FIXTURE_TEST_CASE(CreateQueuerWithInvalidOptions, CreateQueuerWithInvalidOptionsFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
41 EMPTY_BODY_FIXTURE_TEST_CASE(DestroyInvalidQueue, DestroyInvalidQueueFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
42 EMPTY_BODY_FIXTURE_TEST_CASE(SimpleQueue, SimpleQueueFixture<acl::Target::GpuOcl>, framework::DatasetMode::ALL)
43 
44 TEST_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 
76 TEST_SUITE_END() // Queue
77 TEST_SUITE_END() // UNIT
78 TEST_SUITE_END() // CL
79 } // namespace validation
80 } // namespace test
81 } // namespace arm_compute
82