mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Correct CL_QUEUE_PROPERTIES_ARRAY query
Add support of this query for Device Queues. Change-Id: Ia4ad110af22e509efe8b9ae4c27bcccd4271f4a5 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
1c0e2430c5
commit
cfe1d76781
@ -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<DeviceQueue>(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();
|
||||
|
||||
|
@ -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<uint64_t> &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<uint64_t> propertiesVector;
|
||||
cl_uint queueSize = 0;
|
||||
|
||||
GraphicsAllocation *queueBuffer = nullptr;
|
||||
|
@ -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<QueueType, class CommandQueue>::value) {
|
||||
auto cmdQ = reinterpret_cast<CommandQueue *>(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);
|
||||
|
@ -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<std::vector<uint64_t>> 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;
|
||||
|
Reference in New Issue
Block a user