Skip to content

Commit e4eb6d4

Browse files
Reorganize files
Related-To: NEO-5244 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent d628032 commit e4eb6d4

File tree

7 files changed

+47
-50
lines changed

7 files changed

+47
-50
lines changed

level_zero/core/source/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#
2-
# Copyright (C) 2019-2020 Intel Corporation
2+
# Copyright (C) 2019-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
66

77
set(L0_RUNTIME_SOURCES
88
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
9-
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/additional_kernel_properties.cpp
109
${CMAKE_CURRENT_SOURCE_DIR}/get_extension_function_lookup_map.h
1110
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/get_extension_function_lookup_map.cpp
1211
${CMAKE_CURRENT_SOURCE_DIR}/builtin/builtin_functions_lib.h
@@ -33,6 +32,8 @@ set(L0_RUNTIME_SOURCES
3332
${CMAKE_CURRENT_SOURCE_DIR}/context/context_imp.h
3433
${CMAKE_CURRENT_SOURCE_DIR}/context/context.h
3534
${CMAKE_CURRENT_SOURCE_DIR}/debugger/debug_manager.cpp
35+
${CMAKE_CURRENT_SOURCE_DIR}/device${BRANCH_DIR_SUFFIX}/active_device.cpp
36+
${CMAKE_CURRENT_SOURCE_DIR}/device${BRANCH_DIR_SUFFIX}/additional_kernel_properties.cpp
3637
${CMAKE_CURRENT_SOURCE_DIR}/device/device.h
3738
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp.cpp
3839
${CMAKE_CURRENT_SOURCE_DIR}/device/device_imp.h
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "shared/source/device/device.h"
9+
10+
#include "level_zero/core/source/device/device_imp.h"
11+
12+
namespace L0 {
13+
14+
NEO::Device *DeviceImp::getActiveDevice() const {
15+
if (isMultiDeviceCapable()) {
16+
return this->neoDevice->getDeviceById(0);
17+
}
18+
return this->neoDevice;
19+
}
20+
21+
bool DeviceImp::isMultiDeviceCapable() const {
22+
return neoDevice->getNumAvailableDevices() > 1u;
23+
}
24+
25+
} // namespace L0

level_zero/core/source/additional_kernel_properties.cpp renamed to level_zero/core/source/device/additional_kernel_properties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*

level_zero/core/source/device/device_imp.cpp

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,8 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
130130

131131
ze_result_t DeviceImp::getCommandQueueGroupProperties(uint32_t *pCount,
132132
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) {
133-
NEO::Device *neoDevice = this->neoDevice;
134-
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
135-
neoDevice = this->neoDevice->getDeviceById(0);
136-
}
137-
auto engines = neoDevice->getEngineGroups();
133+
NEO::Device *activeDevice = getActiveDevice();
134+
auto engines = activeDevice->getEngineGroups();
138135

139136
uint32_t numEngineGroups = 0;
140137
for (uint32_t i = 0; i < engines.size(); i++) {
@@ -527,10 +524,6 @@ uint32_t DeviceImp::getMaxNumHwThreads() const { return maxNumHwThreads; }
527524

528525
const NEO::HardwareInfo &DeviceImp::getHwInfo() const { return neoDevice->getHardwareInfo(); }
529526

530-
bool DeviceImp::isMultiDeviceCapable() const {
531-
return neoDevice->getNumAvailableDevices() > 1u;
532-
}
533-
534527
Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint32_t currentDeviceMask, bool isSubDevice) {
535528
auto device = new DeviceImp;
536529
UNRECOVERABLE_IF(device == nullptr);
@@ -769,34 +762,20 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr
769762
if (ret != ZE_RESULT_SUCCESS) {
770763
return ret;
771764
}
772-
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
773-
if (index >= this->neoDevice->getDeviceById(0)->getEngineGroups()[engineGroupIndex].size()) {
774-
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
775-
}
776-
*csr = this->neoDevice->getDeviceById(0)->getEngineGroups()[engineGroupIndex][index].commandStreamReceiver;
777-
} else {
778-
if (index >= this->neoDevice->getEngineGroups()[engineGroupIndex].size()) {
779-
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
780-
}
781-
*csr = this->neoDevice->getEngineGroups()[engineGroupIndex][index].commandStreamReceiver;
765+
NEO::Device *activeDevice = getActiveDevice();
766+
if (index >= activeDevice->getEngineGroups()[engineGroupIndex].size()) {
767+
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
782768
}
769+
*csr = activeDevice->getEngineGroups()[engineGroupIndex][index].commandStreamReceiver;
783770
return ZE_RESULT_SUCCESS;
784771
}
785772

786773
ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr) {
787-
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
788-
for (auto &it : neoDevice->getDeviceById(0)->getEngines()) {
789-
if (it.osContext->isLowPriority()) {
790-
*csr = it.commandStreamReceiver;
791-
return ZE_RESULT_SUCCESS;
792-
}
793-
}
794-
} else {
795-
for (auto &it : neoDevice->getEngines()) {
796-
if (it.osContext->isLowPriority()) {
797-
*csr = it.commandStreamReceiver;
798-
return ZE_RESULT_SUCCESS;
799-
}
774+
NEO::Device *activeDevice = getActiveDevice();
775+
for (auto &it : activeDevice->getEngines()) {
776+
if (it.osContext->isLowPriority()) {
777+
*csr = it.commandStreamReceiver;
778+
return ZE_RESULT_SUCCESS;
800779
}
801780
}
802781
// 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) {
805784
}
806785

807786
ze_result_t DeviceImp::mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) {
808-
NEO::Device *neoDevice = this->neoDevice;
809-
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
810-
neoDevice = this->neoDevice->getDeviceById(0);
811-
}
812-
auto engines = neoDevice->getEngineGroups();
787+
NEO::Device *activeDevice = getActiveDevice();
788+
auto engines = activeDevice->getEngineGroups();
813789
uint32_t numNonEmptyGroups = 0;
814790
uint32_t i = 0;
815791
for (; i < engines.size() && numNonEmptyGroups <= *ordinal; i++) {

level_zero/core/source/device/device_imp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -76,6 +76,7 @@ struct DeviceImp : public Device {
7676
ze_result_t getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index) override;
7777
ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr) override;
7878
ze_result_t mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) override;
79+
NEO::Device *getActiveDevice() const;
7980

8081
NEO::Device *neoDevice = nullptr;
8182
bool isSubdevice = false;

level_zero/core/test/unit_tests/sources/device/test_device.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,6 @@ struct MultipleDevicesTest : public ::testing::Test {
467467
const uint32_t numSubDevices = 2u;
468468
};
469469

470-
TEST_F(MultipleDevicesTest, whenDeviceContainsSubDevicesThenItIsMultiDeviceCapable) {
471-
L0::Device *device0 = driverHandle->devices[0];
472-
EXPECT_TRUE(device0->isMultiDeviceCapable());
473-
474-
L0::Device *device1 = driverHandle->devices[1];
475-
EXPECT_TRUE(device1->isMultiDeviceCapable());
476-
}
477-
478470
TEST_F(MultipleDevicesTest, whenRetrievingNumberOfSubdevicesThenCorrectNumberIsReturned) {
479471
L0::Device *device0 = driverHandle->devices[0];
480472

shared/test/unit_test/fixtures/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2019-2020 Intel Corporation
2+
# Copyright (C) 2019-2021 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -15,3 +15,5 @@ target_sources(${TARGET_NAME} PRIVATE
1515
${CMAKE_CURRENT_SOURCE_DIR}/preemption_fixture.cpp
1616
${CMAKE_CURRENT_SOURCE_DIR}/preemption_fixture.h
1717
)
18+
19+
add_subdirectories()

0 commit comments

Comments
 (0)