@@ -1764,3 +1764,54 @@ TEST_F(ImageMultiRootDeviceTests, WhenImageIsCreatedAndEnqueueReadImageCalledThe
17641764
17651765 alignedFree (hostBuffer);
17661766}
1767+
1768+ TEST_F (ImageMultiRootDeviceTests, WhenImageIsCreatedAndEnqueueCopyImageCalledThenImagesMultiGraphicsAllocationLastUsedRootDeviceIndexHasCorrectRootDeviceIndex) {
1769+ REQUIRE_IMAGES_OR_SKIP (defaultHwInfo);
1770+
1771+ cl_int retVal = 0 ;
1772+
1773+ size_t height = 4 ;
1774+ size_t width = 4 ;
1775+ size_t region[] = {width * height, 1 , 1 };
1776+ size_t orgin[] = {0 , 0 , 0 };
1777+
1778+ cl_image_format format;
1779+ format.image_channel_order = CL_RGBA;
1780+ format.image_channel_data_type = CL_UNSIGNED_INT8;
1781+
1782+ cl_image_desc desc{};
1783+ desc.image_type = CL_MEM_OBJECT_IMAGE2D;
1784+ desc.image_width = width * sizeof (unsigned int );
1785+ desc.image_height = height * sizeof (unsigned int );
1786+
1787+ cl_mem_flags flags = CL_MEM_READ_WRITE;
1788+
1789+ auto surfaceFormat = Image::getSurfaceFormatFromTable (
1790+ flags, &format, context->getDevice (0 )->getHardwareInfo ().capabilityTable .supportsOcl21Features );
1791+
1792+ std::unique_ptr<Image> image1 (Image::create (context.get (), MemoryPropertiesHelper::createMemoryProperties (flags, 0 , 0 , &context->getDevice (0 )->getDevice ()), flags, 0 , surfaceFormat, &desc, nullptr , retVal));
1793+ std::unique_ptr<Image> image2 (Image::create (context.get (), MemoryPropertiesHelper::createMemoryProperties (flags, 0 , 0 , &context->getDevice (0 )->getDevice ()), flags, 0 , surfaceFormat, &desc, nullptr , retVal));
1794+
1795+ auto cmdQ1 = context->getSpecialQueue (1u );
1796+ cmdQ1->enqueueCopyImage (image1.get (), image2.get (), orgin, orgin, region, 0 , nullptr , nullptr );
1797+ EXPECT_EQ (image1->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 1u );
1798+ EXPECT_EQ (image2->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 1u );
1799+
1800+ cmdQ1->enqueueCopyImage (image1.get (), image2.get (), orgin, orgin, region, 0 , nullptr , nullptr );
1801+ EXPECT_EQ (image1->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 1u );
1802+ EXPECT_EQ (image2->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 1u );
1803+
1804+ auto cmdQ2 = context->getSpecialQueue (2u );
1805+ cmdQ2->enqueueCopyImage (image1.get (), image2.get (), orgin, orgin, region, 0 , nullptr , nullptr );
1806+ EXPECT_EQ (image1->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 2u );
1807+ EXPECT_EQ (image2->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 2u );
1808+
1809+ cmdQ1->enqueueCopyImage (image1.get (), image2.get (), orgin, orgin, region, 0 , nullptr , nullptr );
1810+ EXPECT_EQ (image1->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 1u );
1811+ EXPECT_EQ (image2->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 1u );
1812+
1813+ static_cast <MemoryAllocation *>(image1->getMigrateableMultiGraphicsAllocation ().getGraphicsAllocation (2u ))->overrideMemoryPool (MemoryPool::LocalMemory);
1814+ cmdQ2->enqueueCopyImage (image1.get (), image2.get (), orgin, orgin, region, 0 , nullptr , nullptr );
1815+ EXPECT_EQ (image1->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 2u );
1816+ EXPECT_EQ (image2->getMultiGraphicsAllocation ().getLastUsedRootDeviceIndex (), 2u );
1817+ }
0 commit comments