mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Use index to chose copy engine
Releated-To: NEO-4913 Change-Id: Ie86e4dc2c1c75f639c9c8b7173fc24d88cb9af82 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
2a4af0b89b
commit
4128761479
@@ -112,31 +112,26 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
|
||||
auto productFamily = neoDevice->getHardwareInfo().platform.eProductFamily;
|
||||
|
||||
NEO::CommandStreamReceiver *csr = nullptr;
|
||||
bool useBliter = false;
|
||||
if (desc->ordinal == static_cast<uint32_t>(NEO::EngineGroupType::Copy)) {
|
||||
auto &selectorCopyEngine = this->neoDevice->getDeviceById(0)->getSelectorCopyEngine();
|
||||
csr = this->neoDevice->getDeviceById(0)->getEngine(NEO::EngineHelpers::getBcsEngineType(neoDevice->getHardwareInfo(), selectorCopyEngine), false).commandStreamReceiver;
|
||||
useBliter = true;
|
||||
} else {
|
||||
bool useBliter = desc->ordinal == static_cast<uint32_t>(NEO::EngineGroupType::Copy);
|
||||
|
||||
if (desc->ordinal >= static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups)) {
|
||||
if (desc->ordinal >= static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
|
||||
if (desc->index >= this->neoDevice->getDeviceById(0)->getEngineGroups()[desc->ordinal].size()) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (this->getNEODevice()->getNumAvailableDevices() > 1) {
|
||||
if (desc->index >= this->neoDevice->getDeviceById(0)->getEngineGroups()[desc->ordinal].size()) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
csr = this->neoDevice->getDeviceById(0)->getEngineGroups()[desc->ordinal][desc->index].commandStreamReceiver;
|
||||
} else {
|
||||
if (desc->index >= this->neoDevice->getEngineGroups()[desc->ordinal].size()) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
csr = this->neoDevice->getEngineGroups()[desc->ordinal][desc->index].commandStreamReceiver;
|
||||
csr = this->neoDevice->getDeviceById(0)->getEngineGroups()[desc->ordinal][desc->index].commandStreamReceiver;
|
||||
} else {
|
||||
if (desc->index >= this->neoDevice->getEngineGroups()[desc->ordinal].size()) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
csr = this->neoDevice->getEngineGroups()[desc->ordinal][desc->index].commandStreamReceiver;
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(csr == nullptr);
|
||||
|
||||
*commandQueue = CommandQueue::create(productFamily, this, csr, desc, useBliter);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -271,25 +271,46 @@ TEST_F(ContextCreateCommandQueueTest, givenCallToContextCreateCommandQueueThenCa
|
||||
L0::CommandQueue::fromHandle(commandQueue)->destroy();
|
||||
}
|
||||
|
||||
HWTEST_F(ContextCreateCommandQueueTest, givenEveryPossibleGroupIndexWhenCreatingCommandQueueThenCommandQueueIsCreated) {
|
||||
ze_command_queue_handle_t commandQueue = {};
|
||||
for (uint32_t ordinal = 0; ordinal < static_cast<uint32_t>(NEO::EngineGroupType::MaxEngineGroups); ordinal++) {
|
||||
auto engines = neoDevice->getEngineGroups();
|
||||
for (uint32_t index = 0; index < engines[ordinal].size(); index++) {
|
||||
ze_command_queue_desc_t desc = {};
|
||||
desc.ordinal = ordinal;
|
||||
desc.index = index;
|
||||
ze_result_t res = context->createCommandQueue(device, &desc, &commandQueue);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
EXPECT_NE(nullptr, commandQueue);
|
||||
|
||||
L0::CommandQueue::fromHandle(commandQueue)->destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using CommandQueueSynchronizeTest = Test<ContextFixture>;
|
||||
|
||||
HWTEST_F(CommandQueueSynchronizeTest, givenCallToSynchronizeThenCorrectEnableTimeoutAndTimeoutValuesAreUsed) {
|
||||
struct SynchronizeCsr : public NEO::UltCommandStreamReceiver<FamilyType> {
|
||||
~SynchronizeCsr() {
|
||||
~SynchronizeCsr() override {
|
||||
delete tagAddress;
|
||||
}
|
||||
SynchronizeCsr(const NEO::ExecutionEnvironment &executionEnvironment) : NEO::UltCommandStreamReceiver<FamilyType>(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment), 0) {
|
||||
tagAddress = new uint32_t;
|
||||
}
|
||||
MOCK_METHOD3(waitForCompletionWithTimeout, bool(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait));
|
||||
bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait) override {
|
||||
waitForComplitionCalledTimes++;
|
||||
return true;
|
||||
}
|
||||
|
||||
volatile uint32_t *getTagAddress() const {
|
||||
volatile uint32_t *getTagAddress() const override {
|
||||
return tagAddress;
|
||||
}
|
||||
uint32_t waitForComplitionCalledTimes = 0;
|
||||
uint32_t *tagAddress;
|
||||
};
|
||||
|
||||
auto csr = new ::testing::NiceMock<SynchronizeCsr>(*device->getNEODevice()->getExecutionEnvironment());
|
||||
auto csr = std::unique_ptr<SynchronizeCsr>(new SynchronizeCsr(*device->getNEODevice()->getExecutionEnvironment()));
|
||||
ze_command_queue_desc_t desc = {};
|
||||
ze_command_queue_handle_t commandQueue = {};
|
||||
ze_result_t res = context->createCommandQueue(device, &desc, &commandQueue);
|
||||
@@ -297,31 +318,23 @@ HWTEST_F(CommandQueueSynchronizeTest, givenCallToSynchronizeThenCorrectEnableTim
|
||||
EXPECT_NE(nullptr, commandQueue);
|
||||
|
||||
CommandQueue *queue = reinterpret_cast<CommandQueue *>(L0::CommandQueue::fromHandle(commandQueue));
|
||||
queue->csr = csr;
|
||||
queue->csr = csr.get();
|
||||
|
||||
uint64_t timeout = 10;
|
||||
bool enableTimeoutExpected = true;
|
||||
int64_t timeoutMicrosecondsExpected = timeout;
|
||||
|
||||
EXPECT_CALL(*csr, waitForCompletionWithTimeout(enableTimeoutExpected,
|
||||
timeoutMicrosecondsExpected,
|
||||
::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(true));
|
||||
queue->synchronize(timeout);
|
||||
|
||||
EXPECT_EQ(csr->waitForComplitionCalledTimes, 1u);
|
||||
timeout = std::numeric_limits<uint64_t>::max();
|
||||
enableTimeoutExpected = false;
|
||||
timeoutMicrosecondsExpected = NEO::TimeoutControls::maxTimeout;
|
||||
|
||||
EXPECT_CALL(*csr, waitForCompletionWithTimeout(enableTimeoutExpected,
|
||||
timeoutMicrosecondsExpected,
|
||||
::testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(::testing::Return(true));
|
||||
queue->synchronize(timeout);
|
||||
|
||||
delete csr;
|
||||
EXPECT_EQ(csr->waitForComplitionCalledTimes, 2u);
|
||||
|
||||
L0::CommandQueue::fromHandle(commandQueue)->destroy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user