OpenCL Queue Families extension 17/n

Return index of default queue (created without using the extension)

Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
Related-To: NEO-5120
This commit is contained in:
Maciej Dziuban 2021-02-11 13:26:05 +00:00 committed by Compute-Runtime-Automation
parent ae484993e2
commit a68a4aa74e
4 changed files with 29 additions and 16 deletions

View File

@ -575,6 +575,18 @@ bool CommandQueue::validateCapabilityForOperation(cl_command_queue_capabilities_
return operationValid && waitListValid && outEventValid;
}
cl_uint CommandQueue::getQueueFamilyIndex() const {
if (isQueueFamilySelected()) {
return queueFamilyIndex;
} else {
const auto &hwInfo = device->getHardwareInfo();
const auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
const auto engineGroupType = hwHelper.getEngineGroupType(gpgpuEngine->getEngineType(), hwInfo);
const auto familyIndex = device->getDevice().getIndexOfNonEmptyEngineGroup(engineGroupType);
return static_cast<cl_uint>(familyIndex);
}
}
IndirectHeap &CommandQueue::getIndirectHeap(IndirectHeap::Type heapType, size_t minRequiredSize) {
return getGpgpuCommandStreamReceiver().getIndirectHeap(heapType, minRequiredSize);
}

View File

@ -303,7 +303,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
bool validateCapability(cl_command_queue_capabilities_intel capability) const;
bool validateCapabilitiesForEventWaitList(cl_uint numEventsInWaitList, const cl_event *waitList) const;
bool validateCapabilityForOperation(cl_command_queue_capabilities_intel capability, cl_uint numEventsInWaitList, const cl_event *waitList, const cl_event *outEvent) const;
cl_uint getQueueFamilyIndex() const { return queueFamilyIndex; }
cl_uint getQueueFamilyIndex() const;
cl_uint getQueueIndexWithinFamily() const { return queueIndexWithinFamily; }
bool isQueueFamilySelected() const { return queueFamilySelected; }

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -65,18 +65,10 @@ void getIntelQueueInfo(CommandQueue *queue, cl_command_queue_info paramName, Get
inline void getHostQueueInfo(CommandQueue *queue, cl_command_queue_info paramName, GetInfoHelper &getInfoHelper, cl_int &retVal) {
switch (paramName) {
case CL_QUEUE_FAMILY_INTEL:
if (queue->isQueueFamilySelected()) {
retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set<cl_uint>(queue->getQueueFamilyIndex()));
} else {
retVal = CL_INVALID_VALUE;
}
retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set<cl_uint>(queue->getQueueFamilyIndex()));
break;
case CL_QUEUE_INDEX_INTEL:
if (queue->isQueueFamilySelected()) {
retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set<cl_uint>(queue->getQueueIndexWithinFamily()));
} else {
retVal = CL_INVALID_VALUE;
}
retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set<cl_uint>(queue->getQueueIndexWithinFamily()));
break;
default:
getIntelQueueInfo(queue, paramName, getInfoHelper, retVal);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -123,17 +123,25 @@ INSTANTIATE_TEST_CASE_P(
::testing::ValuesIn(DefaultCommandQueueProperties));
TEST(GetCommandQueueFamilyInfoTest, givenQueueFamilyNotSelectedWhenGettingFamilyAndQueueIndexThenInvalidValueueIsReturned) {
MockCommandQueue queue;
MockContext context{};
MockCommandQueue queue{context};
queue.queueFamilySelected = false;
queue.queueFamilyIndex = 12u;
cl_int retVal{};
const auto &hwInfo = context.getDevice(0)->getHardwareInfo();
const auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
const auto engineGroupType = hwHelper.getEngineGroupType(context.getDevice(0)->getDefaultEngine().getEngineType(), hwInfo);
const auto expectedFamilyIndex = context.getDevice(0)->getDevice().getIndexOfNonEmptyEngineGroup(engineGroupType);
cl_uint familyIndex{};
retVal = queue.getCommandQueueInfo(
CL_QUEUE_FAMILY_INTEL,
sizeof(cl_uint),
&familyIndex,
nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(expectedFamilyIndex, familyIndex);
cl_uint queueIndex{};
retVal = queue.getCommandQueueInfo(
@ -141,7 +149,8 @@ TEST(GetCommandQueueFamilyInfoTest, givenQueueFamilyNotSelectedWhenGettingFamily
sizeof(cl_uint),
&queueIndex,
nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(0u, queueIndex);
}
TEST(GetCommandQueueFamilyInfoTest, givenQueueFamilySelectedWhenGettingFamilyAndQueueIndexThenValuesAreReturned) {