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:
parent
a988607cc6
commit
06941a51af
|
@ -114,6 +114,7 @@ typedef cl_uint cl_execution_info_intel;
|
|||
|
||||
/* cl_command_type */
|
||||
#define CL_COMMAND_MEMSET_INTEL 0x4204
|
||||
#define CL_COMMAND_MEMFILL_INTEL 0x4204
|
||||
#define CL_COMMAND_MEMCPY_INTEL 0x4205
|
||||
#define CL_COMMAND_MIGRATEMEM_INTEL 0x4206
|
||||
#define CL_COMMAND_MEMADVISE_INTEL 0x4207
|
||||
|
|
|
@ -3590,6 +3590,32 @@ cl_int clEnqueueMemsetINTEL(
|
|||
return retVal;
|
||||
}
|
||||
|
||||
cl_int clEnqueueMemFillINTEL(
|
||||
cl_command_queue commandQueue,
|
||||
void *dstPtr,
|
||||
const void *pattern,
|
||||
size_t pattern_size,
|
||||
size_t size,
|
||||
cl_uint numEventsInWaitList,
|
||||
const cl_event *eventWaitList,
|
||||
cl_event *event) {
|
||||
|
||||
auto retVal = clEnqueueSVMMemFill(commandQueue,
|
||||
dstPtr,
|
||||
pattern,
|
||||
pattern_size,
|
||||
size,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
if (retVal == CL_SUCCESS && event) {
|
||||
auto pEvent = castToObjectOrAbort<Event>(*event);
|
||||
pEvent->setCmdType(CL_COMMAND_MEMFILL_INTEL);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
cl_int clEnqueueMemcpyINTEL(
|
||||
cl_command_queue commandQueue,
|
||||
cl_bool blocking,
|
||||
|
@ -3869,6 +3895,7 @@ void *CL_API_CALL clGetExtensionFunctionAddress(const char *funcName) {
|
|||
RETURN_FUNC_PTR_IF_EXIST(clGetMemAllocInfoINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clSetKernelArgMemPointerINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemsetINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemFillINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemcpyINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clEnqueueMigrateMemINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clEnqueueMemAdviseINTEL);
|
||||
|
|
|
@ -973,6 +973,16 @@ cl_int clEnqueueMemsetINTEL(
|
|||
const cl_event *eventWaitList,
|
||||
cl_event *event);
|
||||
|
||||
cl_int clEnqueueMemFillINTEL(
|
||||
cl_command_queue command_queue,
|
||||
void *dst_ptr,
|
||||
const void *pattern,
|
||||
size_t pattern_size,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event *event_wait_list,
|
||||
cl_event *event);
|
||||
|
||||
cl_int clEnqueueMemcpyINTEL(
|
||||
cl_command_queue commandQueue,
|
||||
cl_bool blocking,
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue