Code cleanup - avoid copy 3/n

Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk 2021-07-25 23:50:05 +00:00 committed by Compute-Runtime-Automation
parent 88c6c9def8
commit aed1da7495
7 changed files with 15 additions and 19 deletions

View File

@ -139,14 +139,10 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) {
NEO::Device *activeDevice = getActiveDevice();
auto engines = activeDevice->getEngineGroups();
uint32_t numEngineGroups = 0;
for (uint32_t i = 0; i < engines.size(); i++) {
if (engines[i].size() > 0) {
numEngineGroups++;
}
}
auto &engineGroups = activeDevice->getEngineGroups();
auto numEngineGroups = static_cast<uint32_t>(std::count_if(std::begin(engineGroups), std::end(engineGroups), [](const auto &engines) {
return !engines.empty();
}));
if (*pCount == 0) {
*pCount = numEngineGroups;
@ -158,7 +154,7 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
i < static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups) && engineGroupCount < *pCount;
i++) {
if (engines[i].empty()) {
if (engineGroups[i].empty()) {
continue;
}
const auto &hardwareInfo = this->neoDevice->getHardwareInfo();
@ -182,7 +178,7 @@ ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
}
auto &l0HwHelper = L0HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
l0HwHelper.setAdditionalGroupProperty(pCommandQueueGroupProperties[engineGroupCount], i);
pCommandQueueGroupProperties[engineGroupCount].numQueues = static_cast<uint32_t>(engines[i].size());
pCommandQueueGroupProperties[engineGroupCount].numQueues = static_cast<uint32_t>(engineGroups[i].size());
engineGroupCount++;
}
@ -916,7 +912,7 @@ ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr) {
ze_result_t DeviceImp::mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) {
NEO::Device *activeDevice = getActiveDevice();
auto engines = activeDevice->getEngineGroups();
const auto &engines = activeDevice->getEngineGroups();
uint32_t numNonEmptyGroups = 0;
uint32_t i = 0;
for (; i < engines.size() && numNonEmptyGroups <= *ordinal; i++) {

View File

@ -1187,7 +1187,7 @@ TEST_F(CommandListCreate, whenInvokingAppendMemoryCopyFromContextForImmediateCom
}
TEST_F(CommandListCreate, givenQueueDescriptionwhenCreatingImmediateCommandListForEveryEnigneThenItHasImmediateCommandQueueCreated) {
auto engines = neoDevice->getEngineGroups();
auto &engines = neoDevice->getEngineGroups();
uint32_t numaAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups); ordinal++) {
if (engines[ordinal].size()) {

View File

@ -1144,7 +1144,7 @@ TEST_F(CommandListCreate, whenCreatingImmCmdListWithASyncModeAndAppendEventReset
}
TEST_F(CommandListCreate, givenQueueDescriptionwhenCreatingImmediateCommandListForCopyEnigneThenItHasImmediateCommandQueueCreated) {
auto engines = neoDevice->getEngineGroups();
auto &engines = neoDevice->getEngineGroups();
uint32_t numaAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups); ordinal++) {
if (engines[ordinal].size()) {

View File

@ -887,7 +887,7 @@ TEST_F(ContextCreateCommandQueueTest, givenCallToContextCreateCommandQueueThenCa
HWTEST_F(ContextCreateCommandQueueTest, givenEveryPossibleGroupIndexWhenCreatingCommandQueueThenCommandQueueIsCreated) {
ze_command_queue_handle_t commandQueue = {};
auto engines = neoDevice->getEngineGroups();
auto &engines = neoDevice->getEngineGroups();
uint32_t numaAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups); ordinal++) {
if (engines[ordinal].size()) {
@ -912,7 +912,7 @@ HWTEST_F(ContextCreateCommandQueueTest, givenEveryPossibleGroupIndexWhenCreating
HWTEST_F(ContextCreateCommandQueueTest, givenOrdinalBigerThanAvailableEnginesWhenCreatingCommandQueueThenInvalidArgReturned) {
ze_command_queue_handle_t commandQueue = {};
auto engines = neoDevice->getEngineGroups();
auto &engines = neoDevice->getEngineGroups();
uint32_t numaAvailableEngineGroups = 0;
for (uint32_t ordinal = 0; ordinal < static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups); ordinal++) {
if (engines[ordinal].size()) {

View File

@ -840,7 +840,7 @@ void CommandQueue::processProperties(const cl_queue_properties *properties) {
this->queueFamilySelected = true;
if (getDevice().getNumAvailableDevices() == 1) {
auto queueFamily = getDevice().getNonEmptyEngineGroup(selectedQueueFamilyIndex);
auto engine = queueFamily->at(selectedQueueIndex);
const auto &engine = queueFamily->at(selectedQueueIndex);
auto engineType = engine.getEngineType();
this->overrideEngine(engineType);
this->queueCapabilities = getClDevice().getDeviceInfo().queueFamilyProperties[selectedQueueFamilyIndex].capabilities;

View File

@ -562,7 +562,7 @@ HWTEST_F(LowPriorityCommandQueueTest, GivenDeviceWithSubdevicesWhenCreatingLowPr
auto commandQueueObj = castToObject<CommandQueue>(cmdQ);
auto subDevice = context.getDevice(0)->getDeviceById(0);
auto engine = subDevice->getEngine(getChosenEngineType(subDevice->getHardwareInfo()), EngineUsage::LowPriority);
auto &engine = subDevice->getEngine(getChosenEngineType(subDevice->getHardwareInfo()), EngineUsage::LowPriority);
EXPECT_EQ(engine.commandStreamReceiver, &commandQueueObj->getGpgpuCommandStreamReceiver());
EXPECT_EQ(engine.osContext, &commandQueueObj->getGpgpuCommandStreamReceiver().getOsContext());

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -22,6 +22,6 @@ struct EngineControl {
CommandStreamReceiver *commandStreamReceiver = nullptr;
OsContext *osContext = nullptr;
aub_stream::EngineType &getEngineType() { return osContext->getEngineType(); }
aub_stream::EngineType &getEngineType() const { return osContext->getEngineType(); }
};
} // namespace NEO