mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Enable memory transfer between images
Unlock flow for multi device setup in: - enqueueCopyImage Update cleanAllGraphicsAllocations test Related-To: NEO-4589 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
0747cb80f5
commit
4f54ea5c87
@ -32,6 +32,11 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImage(
|
||||
const cl_event *eventWaitList,
|
||||
cl_event *event) {
|
||||
|
||||
auto rootDeviceIndex = getDevice().getRootDeviceIndex();
|
||||
|
||||
srcImage->getMigrateableMultiGraphicsAllocation().ensureMemoryOnDevice(*getDevice().getMemoryManager(), rootDeviceIndex);
|
||||
dstImage->getMigrateableMultiGraphicsAllocation().ensureMemoryOnDevice(*getDevice().getMemoryManager(), rootDeviceIndex);
|
||||
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyImageToImage3d,
|
||||
this->getClDevice());
|
||||
BuiltInOwnershipWrapper builtInLock(builder);
|
||||
|
@ -1809,14 +1809,20 @@ TEST_F(BufferTransferTests, givenBufferWhenTransferFromHostPtrCalledThenCopyRequ
|
||||
|
||||
using MultiRootDeviceBufferTest = MultiRootDeviceFixture;
|
||||
|
||||
TEST_F(MultiRootDeviceBufferTest, WhenCleanAllGraphicsAllocationsCalledThenGraphicsAllocationsAreProperlyRemoved) {
|
||||
TEST_F(MultiRootDeviceBufferTest, WhenCleanAllGraphicsAllocationsCalledThenGraphicsAllocationsAreProperlyRemovedAccordingToIsParentObjectFlag) {
|
||||
AllocationInfoType allocationInfo;
|
||||
allocationInfo.resize(3u);
|
||||
|
||||
allocationInfo[1u] = {};
|
||||
allocationInfo[1u].memory = mockMemoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{1u, MemoryConstants::pageSize});
|
||||
|
||||
Buffer::cleanAllGraphicsAllocations(*context, *context->getMemoryManager(), allocationInfo, false);
|
||||
bool isParentObject = true;
|
||||
Buffer::cleanAllGraphicsAllocations(*context, *context->getMemoryManager(), allocationInfo, isParentObject);
|
||||
EXPECT_EQ(mockMemoryManager->freeGraphicsMemoryCalled, 0u);
|
||||
|
||||
isParentObject = false;
|
||||
Buffer::cleanAllGraphicsAllocations(*context, *context->getMemoryManager(), allocationInfo, isParentObject);
|
||||
EXPECT_EQ(mockMemoryManager->freeGraphicsMemoryCalled, 1u);
|
||||
}
|
||||
|
||||
TEST_F(MultiRootDeviceBufferTest, WhenBufferIsCreatedThenBufferGraphicsAllocationHasCorrectRootDeviceIndex) {
|
||||
|
@ -1764,3 +1764,54 @@ TEST_F(ImageMultiRootDeviceTests, WhenImageIsCreatedAndEnqueueReadImageCalledThe
|
||||
|
||||
alignedFree(hostBuffer);
|
||||
}
|
||||
|
||||
TEST_F(ImageMultiRootDeviceTests, WhenImageIsCreatedAndEnqueueCopyImageCalledThenImagesMultiGraphicsAllocationLastUsedRootDeviceIndexHasCorrectRootDeviceIndex) {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
|
||||
cl_int retVal = 0;
|
||||
|
||||
size_t height = 4;
|
||||
size_t width = 4;
|
||||
size_t region[] = {width * height, 1, 1};
|
||||
size_t orgin[] = {0, 0, 0};
|
||||
|
||||
cl_image_format format;
|
||||
format.image_channel_order = CL_RGBA;
|
||||
format.image_channel_data_type = CL_UNSIGNED_INT8;
|
||||
|
||||
cl_image_desc desc{};
|
||||
desc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
desc.image_width = width * sizeof(unsigned int);
|
||||
desc.image_height = height * sizeof(unsigned int);
|
||||
|
||||
cl_mem_flags flags = CL_MEM_READ_WRITE;
|
||||
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(
|
||||
flags, &format, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
||||
|
||||
std::unique_ptr<Image> image1(Image::create(context.get(), MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()), flags, 0, surfaceFormat, &desc, nullptr, retVal));
|
||||
std::unique_ptr<Image> image2(Image::create(context.get(), MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()), flags, 0, surfaceFormat, &desc, nullptr, retVal));
|
||||
|
||||
auto cmdQ1 = context->getSpecialQueue(1u);
|
||||
cmdQ1->enqueueCopyImage(image1.get(), image2.get(), orgin, orgin, region, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(image1->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 1u);
|
||||
EXPECT_EQ(image2->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 1u);
|
||||
|
||||
cmdQ1->enqueueCopyImage(image1.get(), image2.get(), orgin, orgin, region, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(image1->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 1u);
|
||||
EXPECT_EQ(image2->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 1u);
|
||||
|
||||
auto cmdQ2 = context->getSpecialQueue(2u);
|
||||
cmdQ2->enqueueCopyImage(image1.get(), image2.get(), orgin, orgin, region, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(image1->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 2u);
|
||||
EXPECT_EQ(image2->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 2u);
|
||||
|
||||
cmdQ1->enqueueCopyImage(image1.get(), image2.get(), orgin, orgin, region, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(image1->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 1u);
|
||||
EXPECT_EQ(image2->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 1u);
|
||||
|
||||
static_cast<MemoryAllocation *>(image1->getMigrateableMultiGraphicsAllocation().getGraphicsAllocation(2u))->overrideMemoryPool(MemoryPool::LocalMemory);
|
||||
cmdQ2->enqueueCopyImage(image1.get(), image2.get(), orgin, orgin, region, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(image1->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 2u);
|
||||
EXPECT_EQ(image2->getMultiGraphicsAllocation().getLastUsedRootDeviceIndex(), 2u);
|
||||
}
|
||||
|
Reference in New Issue
Block a user