mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Add indirect allocations to residency at kernel submission time
Change-Id: Idc6ce7ac72de84107990a5c9786c868d4bfa4322 Signed-off-by: Raiyan Latif <raiyan.latif@intel.com>
This commit is contained in:
@@ -22,6 +22,36 @@ namespace ult {
|
||||
|
||||
using CommandListAppendLaunchKernel = Test<ModuleFixture>;
|
||||
|
||||
HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithIndirectAllocationsAllowedThenCommandListReturnsExpectedIndirectAllocationsAllowed) {
|
||||
createKernel();
|
||||
kernel->unifiedMemoryControls.indirectDeviceAllocationsAllowed = true;
|
||||
kernel->unifiedMemoryControls.indirectSharedAllocationsAllowed = true;
|
||||
kernel->unifiedMemoryControls.indirectHostAllocationsAllowed = true;
|
||||
EXPECT_TRUE(kernel->getUnifiedMemoryControls().indirectDeviceAllocationsAllowed);
|
||||
EXPECT_TRUE(kernel->hasIndirectAllocationsAllowed());
|
||||
|
||||
ze_group_count_t groupCount{1, 1, 1};
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
||||
auto result = commandList->appendLaunchKernel(kernel->toHandle(), &groupCount, nullptr, 0, nullptr);
|
||||
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
ASSERT_TRUE(commandList->hasIndirectAllocationsAllowed());
|
||||
}
|
||||
|
||||
HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithIndirectAllocationsNotAllowedThenCommandListReturnsExpectedIndirectAllocationsAllowed) {
|
||||
createKernel();
|
||||
kernel->unifiedMemoryControls.indirectDeviceAllocationsAllowed = false;
|
||||
kernel->unifiedMemoryControls.indirectSharedAllocationsAllowed = false;
|
||||
kernel->unifiedMemoryControls.indirectHostAllocationsAllowed = false;
|
||||
|
||||
ze_group_count_t groupCount{1, 1, 1};
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, false));
|
||||
auto result = commandList->appendLaunchKernel(kernel->toHandle(), &groupCount, nullptr, 0, nullptr);
|
||||
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
ASSERT_FALSE(commandList->hasIndirectAllocationsAllowed());
|
||||
}
|
||||
|
||||
HWTEST_F(CommandListAppendLaunchKernel, givenNotEnoughSpaceInCommandStreamWhenAppendingKernelThenBbEndIsAddedAndNewCmdBufferAllocated) {
|
||||
using MI_BATCH_BUFFER_END = typename FamilyType::MI_BATCH_BUFFER_END;
|
||||
createKernel();
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_kernel.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
|
||||
@@ -284,5 +286,64 @@ HWTEST_F(CommandQueueCommands, givenCommandQueueWhenExecutingCommandListsThenHar
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
using CommandQueueIndirectAllocations = Test<ModuleFixture>;
|
||||
HWTEST_F(CommandQueueIndirectAllocations, givenCommandQueueWhenExecutingCommandListsThenExpectedIndirectAllocationsAddedToResidencyContainer) {
|
||||
const ze_command_queue_desc_t desc = {
|
||||
ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT,
|
||||
ZE_COMMAND_QUEUE_FLAG_NONE,
|
||||
ZE_COMMAND_QUEUE_MODE_DEFAULT,
|
||||
ZE_COMMAND_QUEUE_PRIORITY_NORMAL,
|
||||
0};
|
||||
|
||||
MockCsrHw2<FamilyType> csr(*neoDevice->getExecutionEnvironment(), 0);
|
||||
csr.initializeTagAllocation();
|
||||
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
|
||||
|
||||
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
|
||||
device,
|
||||
&csr,
|
||||
&desc,
|
||||
true);
|
||||
ASSERT_NE(nullptr, commandQueue);
|
||||
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, true));
|
||||
|
||||
void *deviceAlloc = nullptr;
|
||||
auto result = device->getDriverHandle()->allocDeviceMem(device->toHandle(), ZE_DEVICE_MEM_ALLOC_FLAG_DEFAULT, 16384u, 4096u, &deviceAlloc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
auto gpuAlloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(deviceAlloc)->gpuAllocation;
|
||||
ASSERT_NE(nullptr, gpuAlloc);
|
||||
|
||||
createKernel();
|
||||
kernel->unifiedMemoryControls.indirectDeviceAllocationsAllowed = true;
|
||||
EXPECT_TRUE(kernel->getUnifiedMemoryControls().indirectDeviceAllocationsAllowed);
|
||||
|
||||
ze_group_count_t groupCount{1, 1, 1};
|
||||
result = commandList->appendLaunchKernel(kernel->toHandle(),
|
||||
&groupCount,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
auto itorEvent = std::find(std::begin(commandList->commandContainer.getResidencyContainer()),
|
||||
std::end(commandList->commandContainer.getResidencyContainer()),
|
||||
gpuAlloc);
|
||||
EXPECT_EQ(itorEvent, std::end(commandList->commandContainer.getResidencyContainer()));
|
||||
|
||||
auto commandListHandle = commandList->toHandle();
|
||||
result = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
itorEvent = std::find(std::begin(commandList->commandContainer.getResidencyContainer()),
|
||||
std::end(commandList->commandContainer.getResidencyContainer()),
|
||||
gpuAlloc);
|
||||
EXPECT_NE(itorEvent, std::end(commandList->commandContainer.getResidencyContainer()));
|
||||
|
||||
device->getDriverHandle()->getSvmAllocsManager()->freeSVMAlloc(deviceAlloc);
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user