Compute Library
 22.05
Queue.cpp
Go to the documentation of this file.
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 
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)
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 {
47 
50 
51  acl::Queue queue(ctx, &err);
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
#define ARM_COMPUTE_ASSERT(cond)
Definition: Validate.h:37
cl_command_queue clCreateCommandQueueWithProperties(cl_context context, cl_device_id device, const cl_queue_properties *properties, cl_int *errcode_ret)
Definition: OpenCL.cpp:297
AclStatus AclGetClContext(AclContext ctx, cl_context *opencl_context)
Extract the underlying OpenCL context used by a given Compute Library context object.
Copyright (c) 2017-2022 Arm Limited.
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
cl_int clReleaseCommandQueue(cl_command_queue command_queue)
Definition: OpenCL.cpp:610
StatusCode
Status code enum.
Definition: Acl.hpp:50
Call succeeded, leading to valid state for all involved objects/data.
Definition: AclTypes.h:51
AclStatus AclGetClDevice(AclContext ctx, cl_device_id *opencl_device)
Extract the underlying OpenCL device id used by a given Compute Library context object.
#define EMPTY_BODY_FIXTURE_TEST_CASE(TEST_NAME, FIXTURE, MODE)
Definition: Macros.h:233
Gpu target that leverages OpenCL.
const T * get() const
Access uderlying object.
Definition: Acl.hpp:156
TEST_CASE(FusedActivation, framework::DatasetMode::ALL)
Validate fused activation expecting the following behaviours:
TEST_SUITE(QASYMM8_to_F32) FIXTURE_DATA_TEST_CASE(RunSmall
Queue classData type enumeration.
Definition: Acl.hpp:416
Context classAvailable tuning modes.
Definition: Acl.hpp:317