OpenCL Queue Families extension 12/n

Fix engine selection for copy engines

Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
Relate-To: NEO-5120
This commit is contained in:
Maciej Dziuban
2021-01-19 17:32:22 +00:00
committed by Compute-Runtime-Automation
parent 3ab932b101
commit 160e5ec112
5 changed files with 67 additions and 4 deletions

View File

@ -778,7 +778,12 @@ void CommandQueue::processProperties(const cl_queue_properties *properties) {
}
void CommandQueue::overrideEngine(aub_stream::EngineType engineType) {
if (engineType == aub_stream::EngineType::ENGINE_BCS) {
const HardwareInfo &hwInfo = getDevice().getHardwareInfo();
const HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
const EngineGroupType engineGroupType = hwHelper.getEngineGroupType(engineType, hwInfo);
const bool isEngineCopyOnly = hwHelper.isCopyOnlyEngineType(engineGroupType);
if (isEngineCopyOnly) {
bcsEngine = &device->getEngine(engineType, false, false);
timestampPacketContainer = std::make_unique<TimestampPacketContainer>();
isCopyOnly = true;

View File

@ -474,6 +474,45 @@ TEST(DeviceGenEngineTest, givenEmptyGroupsWhenGettingNonEmptyGroupsThenReturnCor
EXPECT_EQ(nullptr, device->getNonEmptyEngineGroup(2));
}
TEST(DeviceGenEngineTest, givenNoEmptyGroupsWhenGettingNonEmptyGroupIndexThenReturnCorrectResults) {
const auto nonEmptyEngineGroup = std::vector<EngineControl>{EngineControl{nullptr, nullptr}};
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto &engineGroups = device->getEngineGroups();
engineGroups.clear();
engineGroups.push_back(nonEmptyEngineGroup);
engineGroups.push_back(nonEmptyEngineGroup);
engineGroups.push_back(nonEmptyEngineGroup);
engineGroups.push_back(nonEmptyEngineGroup);
EXPECT_EQ(0u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(0u)));
EXPECT_EQ(1u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(1u)));
EXPECT_EQ(2u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(2u)));
EXPECT_EQ(3u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(3u)));
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(4u)));
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(5u)));
}
TEST(DeviceGenEngineTest, givenEmptyGroupsWhenGettingNonEmptyGroupIndexThenReturnCorrectResults) {
const auto emptyEngineGroup = std::vector<EngineControl>{};
const auto nonEmptyEngineGroup = std::vector<EngineControl>{EngineControl{nullptr, nullptr}};
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto &engineGroups = device->getEngineGroups();
engineGroups.clear();
engineGroups.push_back(emptyEngineGroup);
engineGroups.push_back(nonEmptyEngineGroup);
engineGroups.push_back(emptyEngineGroup);
engineGroups.push_back(nonEmptyEngineGroup);
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(0u)));
EXPECT_EQ(0u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(1u)));
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(2u)));
EXPECT_EQ(1u, device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(3u)));
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(4u)));
EXPECT_ANY_THROW(device->getIndexOfNonEmptyEngineGroup(static_cast<EngineGroupType>(5u)));
}
TEST(DeviceGenEngineTest, whenGettingQueueFamilyCapabilitiesAllThenReturnCorrectValue) {
const cl_command_queue_capabilities_intel expectedProperties = CL_QUEUE_CAPABILITY_CREATE_SINGLE_QUEUE_EVENTS_INTEL |
CL_QUEUE_CAPABILITY_CREATE_CROSS_QUEUE_EVENTS_INTEL |

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -18,6 +18,7 @@
namespace NEO {
class MockCommandQueue : public CommandQueue {
public:
using CommandQueue::bcsEngine;
using CommandQueue::blitEnqueueAllowed;
using CommandQueue::blitEnqueueImageAllowed;
using CommandQueue::bufferCpuCopyAllowed;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -243,6 +243,21 @@ const std::vector<EngineControl> *Device::getNonEmptyEngineGroup(size_t index) c
return nullptr;
}
size_t Device::getIndexOfNonEmptyEngineGroup(EngineGroupType engineGroupType) const {
const auto groupIndex = static_cast<size_t>(engineGroupType);
UNRECOVERABLE_IF(groupIndex >= engineGroups.size());
UNRECOVERABLE_IF(engineGroups[groupIndex].empty());
size_t result = 0u;
for (auto currentGroupIndex = 0u; currentGroupIndex < groupIndex; currentGroupIndex++) {
if (!engineGroups[currentGroupIndex].empty()) {
result++;
}
}
return result;
}
EngineControl &Device::getEngine(aub_stream::EngineType engineType, bool lowPriority, bool internalUsage) {
for (auto &engine : engines) {
if (engine.osContext->getEngineType() == engineType &&

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -18,6 +18,8 @@
#include "opencl/source/os_interface/performance_counters.h"
#include "engine_group_types.h"
namespace NEO {
class OSTime;
class SourceLevelDebugger;
@ -50,6 +52,7 @@ class Device : public ReferenceTrackedObject<Device> {
return this->engineGroups;
}
const std::vector<EngineControl> *getNonEmptyEngineGroup(size_t index) const;
size_t getIndexOfNonEmptyEngineGroup(EngineGroupType engineGroupType) const;
EngineControl &getEngine(uint32_t index);
EngineControl &getDefaultEngine();
EngineControl &getInternalEngine();