USM - add new API for memory fill.

- This API will eventually replace memset API

Change-Id: I33bb43904d76a56f74493f2567a8526f7f2c1ee4
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2019-11-15 08:08:17 +01:00
committed by sys_ocldev
parent a988607cc6
commit 06941a51af
5 changed files with 100 additions and 0 deletions

View File

@@ -133,6 +133,11 @@ TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemsetINTELWhenGettingE
EXPECT_EQ(retVal, reinterpret_cast<void *>(clEnqueueMemsetINTEL));
}
TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemFillINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) {
auto retVal = clGetExtensionFunctionAddress("clEnqueueMemFillINTEL");
EXPECT_EQ(retVal, reinterpret_cast<void *>(clEnqueueMemFillINTEL));
}
TEST_F(clGetExtensionFunctionAddressTests, GivenClEnqueueMemcpyINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) {
auto retVal = clGetExtensionFunctionAddress("clEnqueueMemcpyINTEL");
EXPECT_EQ(retVal, reinterpret_cast<void *>(clEnqueueMemcpyINTEL));

View File

@@ -493,6 +493,48 @@ TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemsetINTELisCalledWithProperParam
clMemFreeINTEL(mockContext.get(), unfiedMemoryDeviceAllocation);
}
TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemFillINTELisCalledWithoutIncorrectCommandQueueThenInvaliQueueErrorIsReturned) {
cl_int setValue = 12u;
auto retVal = clEnqueueMemFillINTEL(0, nullptr, &setValue, 0u, 0u, 0u, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retVal);
}
TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemFillINTELisCalledWithProperParametersThenParametersArePassedCorrectly) {
auto mockContext = std::make_unique<MockContext>();
cl_int retVal = CL_SUCCESS;
auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL(mockContext.get(), mockContext->getDevice(0u), nullptr, 400, 0, &retVal);
struct MockedCommandQueue : public CommandQueue {
cl_int enqueueSVMMemFill(void *svmPtr,
const void *pattern,
size_t patternSize,
size_t size,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event) override {
EXPECT_EQ(12, *reinterpret_cast<const char *>(pattern));
EXPECT_EQ(expectedDstPtr, svmPtr);
EXPECT_EQ(400u, size);
EXPECT_EQ(4u, patternSize);
EXPECT_EQ(0u, numEventsInWaitList);
EXPECT_EQ(nullptr, eventWaitList);
EXPECT_EQ(nullptr, event);
return CL_SUCCESS;
}
void *expectedDstPtr = nullptr;
};
MockedCommandQueue queue;
queue.expectedDstPtr = unfiedMemoryDeviceAllocation;
cl_int setValue = 12u;
retVal = clEnqueueMemFillINTEL(&queue, unfiedMemoryDeviceAllocation, &setValue, sizeof(setValue), 400u, 0, nullptr, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
clMemFreeINTEL(mockContext.get(), unfiedMemoryDeviceAllocation);
}
TEST(clUnifiedSharedMemoryTests, whenClEnqueueMemcpyINTELisCalledWithWrongQueueThenInvalidQueueErrorIsReturned) {
auto retVal = clEnqueueMemcpyINTEL(0, 0, nullptr, nullptr, 0, 0, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retVal);
@@ -628,3 +670,18 @@ TEST_F(clUnifiedSharedMemoryEventTests, whenClEnqueueMemsetINTELIsCalledWithEven
EXPECT_EQ(expectedCmd, actualCmd);
clMemFreeINTEL(this->context, unfiedMemorySharedAllocation);
}
TEST_F(clUnifiedSharedMemoryEventTests, whenClEnqueueMemFillINTELIsCalledWithEventThenProperCmdTypeIsSet) {
cl_int retVal = CL_SUCCESS;
auto unfiedMemorySharedAllocation = clSharedMemAllocINTEL(this->context, this->context->getDevice(0u), nullptr, 400, 0, &retVal);
cl_int setValue = 12u;
retVal = clEnqueueMemFillINTEL(this->pCmdQ, unfiedMemorySharedAllocation, &setValue, sizeof(setValue), 400u, 0, nullptr, &event);
EXPECT_EQ(CL_SUCCESS, retVal);
constexpr cl_command_type expectedCmd = CL_COMMAND_MEMFILL_INTEL;
cl_command_type actualCmd = castToObjectOrAbort<Event>(event)->getCommandType();
EXPECT_EQ(expectedCmd, actualCmd);
clMemFreeINTEL(this->context, unfiedMemorySharedAllocation);
}