Reorganize files

Related-To: NEO-5244

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2021-02-02 15:43:39 +00:00
committed by Compute-Runtime-Automation
parent d628032206
commit e4eb6d4c64
7 changed files with 47 additions and 50 deletions

View File

@@ -1,12 +1,11 @@
#
# Copyright (C) 2019-2020 Intel Corporation
# Copyright (C) 2019-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(L0_RUNTIME_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/additional_kernel_properties.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_extension_function_lookup_map.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/get_extension_function_lookup_map.cpp
${CMAKE_CURRENT_SOURCE_DIR}/builtin/builtin_functions_lib.h
@@ -33,6 +32,8 @@ set(L0_RUNTIME_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/context/context_imp.h
${CMAKE_CURRENT_SOURCE_DIR}/context/context.h
${CMAKE_CURRENT_SOURCE_DIR}/debugger/debug_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device${BRANCH_DIR_SUFFIX}/active_device.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device${BRANCH_DIR_SUFFIX}/additional_kernel_properties.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device/device.h
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp.h

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/device/device.h"
#include "level_zero/core/source/device/device_imp.h"
namespace L0 {
NEO::Device *DeviceImp::getActiveDevice() const {
if (isMultiDeviceCapable()) {
return this->neoDevice->getDeviceById(0);
}
return this->neoDevice;
}
bool DeviceImp::isMultiDeviceCapable() const {
return neoDevice->getNumAvailableDevices() > 1u;
}
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@@ -130,11 +130,8 @@ 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 *neoDevice = this->neoDevice;
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
neoDevice = this->neoDevice->getDeviceById(0);
}
auto engines = neoDevice->getEngineGroups();
NEO::Device *activeDevice = getActiveDevice();
auto engines = activeDevice->getEngineGroups();
uint32_t numEngineGroups = 0;
for (uint32_t i = 0; i < engines.size(); i++) {
@@ -527,10 +524,6 @@ uint32_t DeviceImp::getMaxNumHwThreads() const { return maxNumHwThreads; }
const NEO::HardwareInfo &DeviceImp::getHwInfo() const { return neoDevice->getHardwareInfo(); }
bool DeviceImp::isMultiDeviceCapable() const {
return neoDevice->getNumAvailableDevices() > 1u;
}
Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint32_t currentDeviceMask, bool isSubDevice) {
auto device = new DeviceImp;
UNRECOVERABLE_IF(device == nullptr);
@@ -769,34 +762,20 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr
if (ret != ZE_RESULT_SUCCESS) {
return ret;
}
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
if (index >= this->neoDevice->getDeviceById(0)->getEngineGroups()[engineGroupIndex].size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*csr = this->neoDevice->getDeviceById(0)->getEngineGroups()[engineGroupIndex][index].commandStreamReceiver;
} else {
if (index >= this->neoDevice->getEngineGroups()[engineGroupIndex].size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*csr = this->neoDevice->getEngineGroups()[engineGroupIndex][index].commandStreamReceiver;
NEO::Device *activeDevice = getActiveDevice();
if (index >= activeDevice->getEngineGroups()[engineGroupIndex].size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*csr = activeDevice->getEngineGroups()[engineGroupIndex][index].commandStreamReceiver;
return ZE_RESULT_SUCCESS;
}
ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr) {
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
for (auto &it : neoDevice->getDeviceById(0)->getEngines()) {
if (it.osContext->isLowPriority()) {
*csr = it.commandStreamReceiver;
return ZE_RESULT_SUCCESS;
}
}
} else {
for (auto &it : neoDevice->getEngines()) {
if (it.osContext->isLowPriority()) {
*csr = it.commandStreamReceiver;
return ZE_RESULT_SUCCESS;
}
NEO::Device *activeDevice = getActiveDevice();
for (auto &it : activeDevice->getEngines()) {
if (it.osContext->isLowPriority()) {
*csr = it.commandStreamReceiver;
return ZE_RESULT_SUCCESS;
}
}
// if the code falls through, we have no low priority context created by neoDevice.
@@ -805,11 +784,8 @@ ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr) {
}
ze_result_t DeviceImp::mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) {
NEO::Device *neoDevice = this->neoDevice;
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
neoDevice = this->neoDevice->getDeviceById(0);
}
auto engines = neoDevice->getEngineGroups();
NEO::Device *activeDevice = getActiveDevice();
auto engines = activeDevice->getEngineGroups();
uint32_t numNonEmptyGroups = 0;
uint32_t i = 0;
for (; i < engines.size() && numNonEmptyGroups <= *ordinal; i++) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -76,6 +76,7 @@ struct DeviceImp : public Device {
ze_result_t getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index) override;
ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr) override;
ze_result_t mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) override;
NEO::Device *getActiveDevice() const;
NEO::Device *neoDevice = nullptr;
bool isSubdevice = false;

View File

@@ -467,14 +467,6 @@ struct MultipleDevicesTest : public ::testing::Test {
const uint32_t numSubDevices = 2u;
};
TEST_F(MultipleDevicesTest, whenDeviceContainsSubDevicesThenItIsMultiDeviceCapable) {
L0::Device *device0 = driverHandle->devices[0];
EXPECT_TRUE(device0->isMultiDeviceCapable());
L0::Device *device1 = driverHandle->devices[1];
EXPECT_TRUE(device1->isMultiDeviceCapable());
}
TEST_F(MultipleDevicesTest, whenRetrievingNumberOfSubdevicesThenCorrectNumberIsReturned) {
L0::Device *device0 = driverHandle->devices[0];