diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index e8de6d0da1..e65f13b33e 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -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(familyIndex); + } +} + IndirectHeap &CommandQueue::getIndirectHeap(IndirectHeap::Type heapType, size_t minRequiredSize) { return getGpgpuCommandStreamReceiver().getIndirectHeap(heapType, minRequiredSize); } diff --git a/opencl/source/command_queue/command_queue.h b/opencl/source/command_queue/command_queue.h index bb7dc31284..c8d712dfe0 100644 --- a/opencl/source/command_queue/command_queue.h +++ b/opencl/source/command_queue/command_queue.h @@ -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; } diff --git a/opencl/source/helpers/queue_helpers.h b/opencl/source/helpers/queue_helpers.h index 7245840e5b..b88031d6d4 100644 --- a/opencl/source/helpers/queue_helpers.h +++ b/opencl/source/helpers/queue_helpers.h @@ -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(queue->getQueueFamilyIndex())); - } else { - retVal = CL_INVALID_VALUE; - } + retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set(queue->getQueueFamilyIndex())); break; case CL_QUEUE_INDEX_INTEL: - if (queue->isQueueFamilySelected()) { - retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set(queue->getQueueIndexWithinFamily())); - } else { - retVal = CL_INVALID_VALUE; - } + retVal = changeGetInfoStatusToCLResultType(getInfoHelper.set(queue->getQueueIndexWithinFamily())); break; default: getIntelQueueInfo(queue, paramName, getInfoHelper, retVal); diff --git a/opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp b/opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp index af3cb5918e..b1a3a24c3e 100644 --- a/opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp +++ b/opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp @@ -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) {