diff --git a/opencl/source/device_queue/device_queue.cpp b/opencl/source/device_queue/device_queue.cpp index 8ffb490c52..bbe0ce1edf 100644 --- a/opencl/source/device_queue/device_queue.cpp +++ b/opencl/source/device_queue/device_queue.cpp @@ -38,6 +38,7 @@ DeviceQueue::DeviceQueue(Context *context, queueSize = device->getDeviceInfo().queueOnDevicePreferredSize; } + storeProperties(&properties); allocateResources(); initDeviceQueue(); } @@ -101,6 +102,16 @@ cl_int DeviceQueue::getCommandQueueInfo(cl_command_queue_info paramName, return getQueueInfo(this, paramName, paramValueSize, paramValue, paramValueSizeRet); } +void DeviceQueue::storeProperties(const cl_queue_properties *properties) { + if (properties) { + for (size_t i = 0; properties[i] != 0; i += 2) { + propertiesVector.push_back(properties[i]); + propertiesVector.push_back(properties[i + 1]); + } + propertiesVector.push_back(0); + } +} + void DeviceQueue::allocateResources() { auto &caps = device->getDeviceInfo(); diff --git a/opencl/source/device_queue/device_queue.h b/opencl/source/device_queue/device_queue.h index 132d5c2941..8d4e5a9f5b 100644 --- a/opencl/source/device_queue/device_queue.h +++ b/opencl/source/device_queue/device_queue.h @@ -49,6 +49,7 @@ class DeviceQueue : public BaseObject<_device_queue> { Context &getContext() { return *context; } cl_uint getQueueSize() { return queueSize; } cl_command_queue_properties getCommandQueueProperties() const { return commandQueueProperties; } + const std::vector &getPropertiesVector() const { return propertiesVector; } GraphicsAllocation *getQueueBuffer() { return queueBuffer; } GraphicsAllocation *getEventPoolBuffer() { return eventPoolBuffer; } GraphicsAllocation *getSlbBuffer() { return slbBuffer; } @@ -109,12 +110,14 @@ class DeviceQueue : public BaseObject<_device_queue> { static const uint32_t numberOfDeviceEnqueues; protected: + void storeProperties(const cl_queue_properties *properties); void allocateResources(); void initDeviceQueue(); Context *context = nullptr; ClDevice *device = nullptr; cl_command_queue_properties commandQueueProperties = 0; + std::vector propertiesVector; cl_uint queueSize = 0; GraphicsAllocation *queueBuffer = nullptr; diff --git a/opencl/source/helpers/queue_helpers.h b/opencl/source/helpers/queue_helpers.h index e2c151d90f..b8b627a206 100644 --- a/opencl/source/helpers/queue_helpers.h +++ b/opencl/source/helpers/queue_helpers.h @@ -87,14 +87,9 @@ cl_int getQueueInfo(QueueType *queue, retVal = CL_INVALID_COMMAND_QUEUE; break; case CL_QUEUE_PROPERTIES_ARRAY: { - const cl_queue_properties *source = nullptr; - size_t sourceSize = 0; - if (std::is_same::value) { - auto cmdQ = reinterpret_cast(queue); - auto &propertiesVector = cmdQ->getPropertiesVector(); - source = propertiesVector.data(); - sourceSize = propertiesVector.size() * sizeof(cl_queue_properties); - } + auto &propertiesVector = queue->getPropertiesVector(); + auto source = propertiesVector.data(); + auto sourceSize = propertiesVector.size() * sizeof(cl_queue_properties); auto getInfoStatus = GetInfo::getInfo(paramValue, paramValueSize, source, sourceSize); retVal = changeGetInfoStatusToCLResultType(getInfoStatus); GetInfo::setParamValueReturnSize(paramValueSizeRet, sourceSize, getInfoStatus); diff --git a/opencl/test/unit_test/api/cl_create_command_queue_with_properties_tests.cpp b/opencl/test/unit_test/api/cl_create_command_queue_with_properties_tests.cpp index b3a1b4ac09..1da84a747f 100644 --- a/opencl/test/unit_test/api/cl_create_command_queue_with_properties_tests.cpp +++ b/opencl/test/unit_test/api/cl_create_command_queue_with_properties_tests.cpp @@ -455,6 +455,33 @@ TEST_F(clCreateCommandQueueWithPropertiesApi, GivenCommandQueueCreatedWithVariou } } +TEST_F(clCreateCommandQueueWithPropertiesApi, GivenDeviceQueueCreatedWithVariousPropertiesWhenQueryingPropertiesArrayThenCorrectValuesAreReturned) { + REQUIRE_DEVICE_ENQUEUE_OR_SKIP(pContext); + + cl_int retVal = CL_SUCCESS; + cl_queue_properties propertiesArray[5]; + size_t propertiesArraySize; + + std::vector> propertiesToTest{ + {CL_QUEUE_PROPERTIES, CL_QUEUE_ON_DEVICE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0}, + {CL_QUEUE_PROPERTIES, CL_QUEUE_ON_DEVICE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, CL_QUEUE_SIZE, 16, 0}}; + + for (auto properties : propertiesToTest) { + auto commandQueue = clCreateCommandQueueWithProperties(pContext, testedClDevice, properties.data(), &retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + + retVal = clGetCommandQueueInfo(commandQueue, CL_QUEUE_PROPERTIES_ARRAY, + sizeof(propertiesArray), propertiesArray, &propertiesArraySize); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(properties.size() * sizeof(cl_queue_properties), propertiesArraySize); + for (size_t i = 0; i < properties.size(); i++) { + EXPECT_EQ(properties[i], propertiesArray[i]); + } + + clReleaseCommandQueue(commandQueue); + } +} + using LowPriorityCommandQueueTest = ::testing::Test; HWTEST_F(LowPriorityCommandQueueTest, GivenDeviceWithSubdevicesWhenCreatingLowPriorityCommandQueueThenEngineFromFirstSubdeviceIsTaken) { DebugManagerStateRestore restorer;