Added support for stateless enqeueueSVMMemcpy

Change-Id: I1690735b7888b29572b75756d38698305805b7cb
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
Related-To: NEO-3314
This commit is contained in:
Kamil Kopryk
2019-11-25 16:22:38 +01:00
committed by sys_ocldev
parent 1ecad5faed
commit ec63a03337
2 changed files with 83 additions and 5 deletions

View File

@@ -318,12 +318,25 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemcpy(cl_bool blockingCopy,
pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast<void *>(srcSvmData->gpuAllocation->getGpuAddress())); pageFaultManager->moveAllocationToGpuDomain(reinterpret_cast<void *>(srcSvmData->gpuAllocation->getGpuAddress()));
} }
MultiDispatchInfo dispatchInfo; auto isStatelessRequired = false;
auto &builder = getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer, if (srcSvmData != nullptr) {
this->getContext(), this->getDevice()); isStatelessRequired = forceStateless(srcSvmData->size);
BuiltInOwnershipWrapper builtInLock(builder, this->context); }
BuiltinOpParams operationParams; if (dstSvmData != nullptr) {
isStatelessRequired |= forceStateless(dstSvmData->size);
}
auto builtInType = EBuiltInOps::CopyBufferToBuffer;
if (isStatelessRequired) {
builtInType = EBuiltInOps::CopyBufferToBufferStateless;
}
auto &builder = getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(builtInType,
this->getContext(),
this->getDevice());
BuiltInOwnershipWrapper builtInLock(builder, this->context);
MultiDispatchInfo dispatchInfo;
BuiltinOpParams operationParams;
Surface *surfaces[2]; Surface *surfaces[2];
void *alignedSrcPtr = alignDown(const_cast<void *>(srcPtr), 4); void *alignedSrcPtr = alignDown(const_cast<void *>(srcPtr), 4);

View File

@@ -8,6 +8,7 @@
#include "core/memory_manager/unified_memory_manager.h" #include "core/memory_manager/unified_memory_manager.h"
#include "runtime/built_ins/builtins_dispatch_builder.h" #include "runtime/built_ins/builtins_dispatch_builder.h"
#include "test.h" #include "test.h"
#include "unit_tests/command_queue/command_enqueue_fixture.h"
#include "unit_tests/command_queue/command_queue_fixture.h" #include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/mocks/mock_builtin_dispatch_info_builder.h" #include "unit_tests/mocks/mock_builtin_dispatch_info_builder.h"
@@ -293,3 +294,67 @@ HWTEST_F(EnqueueSvmMemCopyTest, givenEnqueueSVMMemcpyWhenUsingCopyBufferToBuffer
EXPECT_EQ("CopyBufferToBufferMiddle", kernel->getKernelInfo().name); EXPECT_EQ("CopyBufferToBufferMiddle", kernel->getKernelInfo().name);
alignedFree(dstHostPtr); alignedFree(dstHostPtr);
} }
struct EnqueueSvmMemCopyHw : public ::testing::Test {
void SetUp() override {
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
if (is32bit || !device->isFullRangeSvm()) {
GTEST_SKIP();
}
context = std::make_unique<MockContext>(device.get());
srcSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(device->getRootDeviceIndex(), 256, {});
ASSERT_NE(nullptr, srcSvmPtr);
dstHostPtr = alignedMalloc(256, 64);
}
void TearDown() override {
if (is32bit || !device->isFullRangeSvm()) {
return;
}
context->getSVMAllocsManager()->freeSVMAlloc(srcSvmPtr);
alignedFree(dstHostPtr);
}
std::unique_ptr<MockDevice> device;
std::unique_ptr<MockContext> context;
uint64_t bigSize = 5ull * MemoryConstants::gigaByte;
uint64_t smallSize = 4ull * MemoryConstants::gigaByte - 1;
void *srcSvmPtr = nullptr;
void *dstHostPtr = nullptr;
};
using EnqueueSvmMemCopyHwTest = EnqueueSvmMemCopyHw;
HWTEST_F(EnqueueSvmMemCopyHwTest, givenEnqueueSVMMemCopyWhenUsingCopyBufferToBufferStatelessBuilderThenSuccessIsReturned) {
auto cmdQ = std::make_unique<CommandQueueStateless<FamilyType>>(context.get(), device.get());
auto srcSvmData = context->getSVMAllocsManager()->getSVMAlloc(srcSvmPtr);
srcSvmData->size = static_cast<size_t>(bigSize);
auto retVal = cmdQ->enqueueSVMMemcpy(
false, // cl_bool blocking_copy
dstHostPtr, // void *dst_ptr
srcSvmPtr, // const void *src_ptr
static_cast<size_t>(bigSize), // size_t size
0, // cl_uint num_events_in_wait_list
nullptr, // cl_event *event_wait_list
nullptr // cL_event *event
);
EXPECT_EQ(CL_SUCCESS, retVal);
}
HWTEST_F(EnqueueSvmMemCopyHwTest, givenEnqueueSVMMemCopyWhenUsingCopyBufferToBufferStatefulBuilderThenSuccessIsReturned) {
auto cmdQ = std::make_unique<CommandQueueStateful<FamilyType>>(context.get(), device.get());
auto retVal = cmdQ->enqueueSVMMemcpy(
false, // cl_bool blocking_copy
dstHostPtr, // void *dst_ptr
srcSvmPtr, // const void *src_ptr
static_cast<size_t>(smallSize), // size_t size
0, // cl_uint num_events_in_wait_list
nullptr, // cl_event *event_wait_list
nullptr // cL_event *event
);
EXPECT_EQ(CL_SUCCESS, retVal);
}