mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Add support for queue groups (3/N)
- Select correct NEO device in when more than one subdevice available. Change-Id: I3b5823c12310fde1c6a4e3c5870cbcd5e691ba86 Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
6570a7a828
commit
c1e4e5152b
@@ -76,6 +76,8 @@ CommandList *CommandList::createImmediate(uint32_t productFamily, Device *device
|
||||
device->getCsrForOrdinalAndIndex(&csr, desc->ordinal, desc->index);
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(nullptr == csr);
|
||||
|
||||
auto commandQueue = CommandQueue::create(productFamily, device, csr, desc, isCopyOnly);
|
||||
if (!commandQueue) {
|
||||
return nullptr;
|
||||
|
||||
@@ -124,7 +124,12 @@ 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) {
|
||||
auto engines = this->getNEODevice()->getEngineGroups();
|
||||
NEO::Device *neoDevice = this->neoDevice;
|
||||
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
|
||||
neoDevice = this->neoDevice->getDeviceById(0);
|
||||
}
|
||||
auto engines = neoDevice->getEngineGroups();
|
||||
|
||||
uint32_t numEngineGroups = 0;
|
||||
for (uint32_t i = 0; i < engines.size(); i++) {
|
||||
if (engines[i].size() > 0) {
|
||||
@@ -745,7 +750,11 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
ze_result_t DeviceImp::mapOrdinalForAvailableEngineGroup(uint32_t *ordinal) {
|
||||
auto engines = this->getNEODevice()->getEngineGroups();
|
||||
NEO::Device *neoDevice = this->neoDevice;
|
||||
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
|
||||
neoDevice = this->neoDevice->getDeviceById(0);
|
||||
}
|
||||
auto engines = neoDevice->getEngineGroups();
|
||||
uint32_t numNonEmptyGroups = 0;
|
||||
uint32_t i = 0;
|
||||
for (; i < engines.size() && numNonEmptyGroups <= *ordinal; i++) {
|
||||
|
||||
@@ -39,10 +39,12 @@ struct DeviceFixture {
|
||||
struct MultiDeviceFixture {
|
||||
virtual void SetUp() { // NOLINT(readability-identifier-naming)
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(numSubDevices);
|
||||
auto executionEnvironment = new NEO::ExecutionEnvironment;
|
||||
auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment);
|
||||
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
|
||||
driverHandle->initialize(std::move(devices));
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
}
|
||||
|
||||
virtual void TearDown() { // NOLINT(readability-identifier-naming)
|
||||
@@ -50,8 +52,9 @@ struct MultiDeviceFixture {
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
std::vector<L0::Device *> devices;
|
||||
std::vector<NEO::Device *> devices;
|
||||
const uint32_t numRootDevices = 4u;
|
||||
const uint32_t numSubDevices = 2u;
|
||||
};
|
||||
|
||||
struct ContextFixture : DeviceFixture {
|
||||
|
||||
@@ -10,7 +10,7 @@ if(TESTS_GEN9)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enable_l0_mocks_gen9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_launch_kernel_gen9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdqueue_thread_arbitration_policy_gen9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdqueue_gen9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_device_gen9.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "opencl/source/helpers/hardware_commands_helper.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/cmdqueue/cmdqueue_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
|
||||
@@ -160,5 +162,49 @@ HWTEST2_F(CommandQueueThreadArbitrationPolicyTests,
|
||||
}
|
||||
}
|
||||
|
||||
struct CommandQueueGroupMultiDevice : public MultiDeviceFixture, public ::testing::Test {
|
||||
void SetUp() override {
|
||||
MultiDeviceFixture::SetUp();
|
||||
uint32_t count = 1;
|
||||
ze_device_handle_t hDevice;
|
||||
ze_result_t res = driverHandle->getDevice(&count, &hDevice);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
device = L0::Device::fromHandle(hDevice);
|
||||
ASSERT_NE(nullptr, device);
|
||||
}
|
||||
void TearDown() override {
|
||||
MultiDeviceFixture::TearDown();
|
||||
}
|
||||
L0::Device *device = nullptr;
|
||||
};
|
||||
|
||||
HWTEST2_F(CommandQueueGroupMultiDevice,
|
||||
givenCommandQueuePropertiesCallThenCallSucceedsAndCommandListImmediateIsCreated, IsGen9) {
|
||||
uint32_t count = 0;
|
||||
ze_result_t res = device->getCommandQueueGroupProperties(&count, nullptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_GE(count, 1u);
|
||||
|
||||
std::vector<ze_command_queue_group_properties_t> queueProperties(count);
|
||||
res = device->getCommandQueueGroupProperties(&count, queueProperties.data());
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
uint32_t queueGroupOrdinal = 0u;
|
||||
uint32_t queueGroupIndex = 0u;
|
||||
ze_command_queue_desc_t desc = {};
|
||||
desc.ordinal = queueGroupOrdinal;
|
||||
desc.index = queueGroupIndex;
|
||||
|
||||
std::unique_ptr<L0::CommandList> commandList0(CommandList::createImmediate(productFamily,
|
||||
device,
|
||||
&desc,
|
||||
false,
|
||||
false));
|
||||
L0::CommandQueueImp *cmdQueue = reinterpret_cast<CommandQueueImp *>(commandList0->cmdQImmediate);
|
||||
L0::DeviceImp *deviceImp = reinterpret_cast<L0::DeviceImp *>(device);
|
||||
auto expectedCSR = deviceImp->neoDevice->getDeviceById(0)->getEngineGroups()[queueGroupOrdinal][queueGroupIndex].commandStreamReceiver;
|
||||
EXPECT_EQ(cmdQueue->getCsr(), expectedCSR);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user