fix OCL: set correct memory location after initial transfer to buffer

when multi-storage buffer is initialized with memory then we need to track
location of actual data

remove redundant parameters from copyHostPointer function

Related-To: NEO-5735
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-02-02 16:34:16 +00:00
committed by Compute-Runtime-Automation
parent 5a613405c6
commit 371ee24554
2 changed files with 61 additions and 27 deletions

View File

@@ -12,6 +12,7 @@
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/local_memory_access_modes.h"
#include "shared/source/memory_manager/memory_operations_handler.h"
#include "shared/source/memory_manager/migration_sync_data.h"
#include "shared/source/memory_manager/unified_memory_manager.h"
#include "shared/test/common/fixtures/memory_management_fixture.h"
#include "shared/test/common/helpers/raii_gfx_core_helper.h"
@@ -2190,6 +2191,42 @@ TEST(MultiRootDeviceBufferTest2, WhenBufferIsCreatedThenSecondAndSubsequentAlloc
EXPECT_EQ(memoryManager->allocationsFromExistingStorage[1], buffer->getMultiGraphicsAllocation().getGraphicsAllocation(2u));
}
TEST(MultiRootDeviceBufferTest2, givenHostPtrToCopyWhenBufferIsCreatedWithMultiStorageThenMemoryIsPutInFirstDeviceInContext) {
DebugManagerStateRestore restorer;
DebugManager.flags.AllocateBuffersInLocalMemoryForMultiRootDeviceContexts.set(true);
UltClDeviceFactory deviceFactory{2, 0};
{
cl_device_id deviceIds[] = {
deviceFactory.rootDevices[0],
deviceFactory.rootDevices[1]};
MockContext context{nullptr, nullptr};
context.initializeWithDevices(ClDeviceVector{deviceIds, 2}, false);
cl_int retVal = 0;
uint32_t data{};
std::unique_ptr<Buffer> buffer(Buffer::create(&context, CL_MEM_COPY_HOST_PTR, sizeof(data), &data, retVal));
EXPECT_EQ(2u, context.getRootDeviceIndices().size());
EXPECT_EQ(0u, buffer->getMultiGraphicsAllocation().getMigrationSyncData()->getCurrentLocation());
}
{
cl_device_id deviceIds[] = {
deviceFactory.rootDevices[1],
deviceFactory.rootDevices[0]};
MockContext context{nullptr, nullptr};
context.initializeWithDevices(ClDeviceVector{deviceIds, 2}, false);
cl_int retVal = 0;
uint32_t data{};
std::unique_ptr<Buffer> buffer(Buffer::create(&context, CL_MEM_COPY_HOST_PTR, sizeof(data), &data, retVal));
EXPECT_EQ(2u, context.getRootDeviceIndices().size());
EXPECT_EQ(1u, buffer->getMultiGraphicsAllocation().getMigrationSyncData()->getCurrentLocation());
}
}
TEST_F(MultiRootDeviceBufferTest, givenBufferWhenGetSurfaceSizeCalledWithoutAlignSizeForAuxTranslationThenCorrectValueReturned) {
cl_int retVal = 0;
cl_mem_flags flags = CL_MEM_READ_WRITE;