diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 628e5812ba..c3f5aab5a3 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -56,9 +56,6 @@ CommandQueue *CommandQueue::create(Context *context, return funcCreate(context, device, properties, internalUsage); } -CommandQueue::CommandQueue() : CommandQueue(nullptr, nullptr, 0) { -} - CommandQueue::CommandQueue(Context *context, ClDevice *device, const cl_queue_properties *properties) : context(context), device(device) { if (context) { diff --git a/opencl/source/command_queue/command_queue.h b/opencl/source/command_queue/command_queue.h index 1a2cf88ee4..9283714a20 100644 --- a/opencl/source/command_queue/command_queue.h +++ b/opencl/source/command_queue/command_queue.h @@ -64,7 +64,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> { bool internalUsage, cl_int &errcodeRet); - CommandQueue(); + CommandQueue() = delete; CommandQueue(Context *context, ClDevice *device, const cl_queue_properties *properties); @@ -75,44 +75,19 @@ class CommandQueue : public BaseObject<_cl_command_queue> { ~CommandQueue() override; // API entry points - virtual cl_int - enqueueCopyImage(Image *srcImage, Image *dstImage, const size_t srcOrigin[3], - const size_t dstOrigin[3], const size_t region[3], - cl_uint numEventsInWaitList, const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueCopyImage(Image *srcImage, Image *dstImage, const size_t srcOrigin[3], const size_t dstOrigin[3], + const size_t region[3], cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueFillImage(Image *image, const void *fillColor, - const size_t *origin, const size_t *region, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueFillImage(Image *image, const void *fillColor, const size_t *origin, const size_t *region, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueFillBuffer(Buffer *buffer, const void *pattern, - size_t patternSize, size_t offset, - size_t size, cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueFillBuffer(Buffer *buffer, const void *pattern, size_t patternSize, size_t offset, + size_t size, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueKernel(cl_kernel kernel, cl_uint workDim, - const size_t *globalWorkOffset, - const size_t *globalWorkSize, - const size_t *localWorkSize, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueKernel(cl_kernel kernel, cl_uint workDim, const size_t *globalWorkOffset, const size_t *globalWorkSize, + const size_t *localWorkSize, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueBarrierWithWaitList(cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueBarrierWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; MOCKABLE_VIRTUAL void *enqueueMapBuffer(Buffer *buffer, cl_bool blockingMap, cl_map_flags mapFlags, size_t offset, @@ -129,166 +104,74 @@ class CommandQueue : public BaseObject<_cl_command_queue> { MOCKABLE_VIRTUAL cl_int enqueueUnmapMemObject(MemObj *memObj, void *mappedPtr, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event); - virtual cl_int enqueueSVMMap(cl_bool blockingMap, cl_map_flags mapFlags, - void *svmPtr, size_t size, - cl_uint numEventsInWaitList, const cl_event *eventWaitList, - cl_event *event, bool externalAppCall) { - return CL_SUCCESS; - } + virtual cl_int enqueueSVMMap(cl_bool blockingMap, cl_map_flags mapFlags, void *svmPtr, size_t size, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event, bool externalAppCall) = 0; - virtual cl_int enqueueSVMUnmap(void *svmPtr, - cl_uint numEventsInWaitList, const cl_event *eventWaitList, - cl_event *event, bool externalAppCall) { - return CL_SUCCESS; - } + virtual cl_int enqueueSVMUnmap(void *svmPtr, cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event, bool externalAppCall) = 0; - virtual cl_int enqueueSVMFree(cl_uint numSvmPointers, - void *svmPointers[], + virtual cl_int enqueueSVMFree(cl_uint numSvmPointers, void *svmPointers[], void(CL_CALLBACK *pfnFreeFunc)(cl_command_queue queue, cl_uint numSvmPointers, void *svmPointers[], void *userData), - void *userData, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + void *userData, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueSVMMemcpy(cl_bool blockingCopy, - void *dstPtr, - const void *srcPtr, - size_t size, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueSVMMemcpy(cl_bool blockingCopy, void *dstPtr, const void *srcPtr, size_t size, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueSVMMemFill(void *svmPtr, - const void *pattern, - size_t patternSize, - size_t size, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueSVMMemFill(void *svmPtr, const void *pattern, size_t patternSize, + size_t size, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueMarkerWithWaitList(cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueMarkerWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueMigrateMemObjects(cl_uint numMemObjects, - const cl_mem *memObjects, - cl_mem_migration_flags flags, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueMigrateMemObjects(cl_uint numMemObjects, const cl_mem *memObjects, cl_mem_migration_flags flags, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueSVMMigrateMem(cl_uint numSvmPointers, - const void **svmPointers, - const size_t *sizes, - const cl_mem_migration_flags flags, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueSVMMigrateMem(cl_uint numSvmPointers, const void **svmPointers, const size_t *sizes, + const cl_mem_migration_flags flags, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueCopyBuffer(Buffer *srcBuffer, Buffer *dstBuffer, - size_t srcOffset, size_t dstOffset, - size_t size, cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueCopyBuffer(Buffer *srcBuffer, Buffer *dstBuffer, size_t srcOffset, size_t dstOffset, + size_t size, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueReadBuffer(Buffer *buffer, cl_bool blockingRead, - size_t offset, size_t size, void *ptr, - GraphicsAllocation *mapAllocation, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueReadBuffer(Buffer *buffer, cl_bool blockingRead, size_t offset, size_t size, void *ptr, + GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueReadImage(Image *srcImage, cl_bool blockingRead, - const size_t *origin, const size_t *region, - size_t rowPitch, size_t slicePitch, void *ptr, - GraphicsAllocation *mapAllocation, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueReadImage(Image *srcImage, cl_bool blockingRead, const size_t *origin, const size_t *region, + size_t rowPitch, size_t slicePitch, void *ptr, GraphicsAllocation *mapAllocation, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueWriteBuffer(Buffer *buffer, cl_bool blockingWrite, - size_t offset, size_t cb, const void *ptr, - GraphicsAllocation *mapAllocation, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueWriteBuffer(Buffer *buffer, cl_bool blockingWrite, size_t offset, size_t cb, + const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueWriteImage(Image *dstImage, cl_bool blockingWrite, - const size_t *origin, const size_t *region, - size_t inputRowPitch, size_t inputSlicePitch, - const void *ptr, GraphicsAllocation *mapAllocation, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueWriteImage(Image *dstImage, cl_bool blockingWrite, const size_t *origin, + const size_t *region, size_t inputRowPitch, size_t inputSlicePitch, + const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int - enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, - const size_t *srcOrigin, const size_t *dstOrigin, - const size_t *region, size_t srcRowPitch, - size_t srcSlicePitch, size_t dstRowPitch, - size_t dstSlicePitch, cl_uint numEventsInWaitList, - const cl_event *eventWaitList, cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin, + const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueWriteBufferRect( - Buffer *buffer, cl_bool blockingWrite, const size_t *bufferOrigin, - const size_t *hostOrigin, const size_t *region, size_t bufferRowPitch, - size_t bufferSlicePitch, size_t hostRowPitch, size_t hostSlicePitch, - const void *ptr, cl_uint numEventsInWaitList, - const cl_event *eventWaitList, cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueWriteBufferRect(Buffer *buffer, cl_bool blockingWrite, const size_t *bufferOrigin, + const size_t *hostOrigin, const size_t *region, size_t bufferRowPitch, + size_t bufferSlicePitch, size_t hostRowPitch, size_t hostSlicePitch, + const void *ptr, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int enqueueReadBufferRect( - Buffer *buffer, cl_bool blockingRead, const size_t *bufferOrigin, - const size_t *hostOrigin, const size_t *region, size_t bufferRowPitch, - size_t bufferSlicePitch, size_t hostRowPitch, size_t hostSlicePitch, - void *ptr, cl_uint numEventsInWaitList, - const cl_event *eventWaitList, cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueReadBufferRect(Buffer *buffer, cl_bool blockingRead, const size_t *bufferOrigin, + const size_t *hostOrigin, const size_t *region, size_t bufferRowPitch, + size_t bufferSlicePitch, size_t hostRowPitch, size_t hostSlicePitch, + void *ptr, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int - enqueueCopyBufferToImage(Buffer *srcBuffer, Image *dstImage, size_t srcOffset, - const size_t *dstOrigin, const size_t *region, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueCopyBufferToImage(Buffer *srcBuffer, Image *dstImage, size_t srcOffset, + const size_t *dstOrigin, const size_t *region, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int - enqueueCopyImageToBuffer(Image *srcImage, Buffer *dstBuffer, - const size_t *srcOrigin, const size_t *region, - size_t dstOffset, cl_uint numEventsInWaitList, - const cl_event *eventWaitList, cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueCopyImageToBuffer(Image *srcImage, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *region, + size_t dstOffset, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; cl_int enqueueAcquireSharedObjects(cl_uint numObjects, const cl_mem *memObjects, @@ -306,22 +189,14 @@ class CommandQueue : public BaseObject<_cl_command_queue> { MOCKABLE_VIRTUAL void *cpuDataTransferHandler(TransferProperties &transferProperties, EventsRequest &eventsRequest, cl_int &retVal); - virtual cl_int enqueueResourceBarrier(BarrierCommand *resourceBarrier, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int enqueueResourceBarrier(BarrierCommand *resourceBarrier, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int finish() { return CL_SUCCESS; } - virtual cl_int enqueueInitDispatchGlobals(DispatchGlobalsArgs *dispatchGlobalsArgs, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) { - return CL_SUCCESS; - } + virtual cl_int finish() = 0; + virtual cl_int enqueueInitDispatchGlobals(DispatchGlobalsArgs *dispatchGlobalsArgs, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) = 0; - virtual cl_int flush() { return CL_SUCCESS; } + virtual cl_int flush() = 0; MOCKABLE_VIRTUAL void updateFromCompletionStamp(const CompletionStamp &completionStamp); diff --git a/opencl/test/unit_test/api/cl_api_tests.cpp b/opencl/test/unit_test/api/cl_api_tests.cpp index cb4595da1e..8c7448f342 100644 --- a/opencl/test/unit_test/api/cl_api_tests.cpp +++ b/opencl/test/unit_test/api/cl_api_tests.cpp @@ -7,6 +7,7 @@ #include "cl_api_tests.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "opencl/test/unit_test/mocks/mock_context.h" #include "opencl/test/unit_test/mocks/mock_device.h" @@ -23,7 +24,7 @@ void api_fixture_using_aligned_memory_manager::SetUp() { EXPECT_EQ(CL_SUCCESS, retVal); Context *ctxPtr = reinterpret_cast(context); - commandQueue = new CommandQueue(context, device, 0); + commandQueue = new MockCommandQueue(context, device, 0); program = new MockProgram(*device->getExecutionEnvironment(), ctxPtr, false, &device->getDevice()); Program *prgPtr = reinterpret_cast(program); diff --git a/opencl/test/unit_test/api/cl_api_tests.h b/opencl/test/unit_test/api/cl_api_tests.h index 687235e353..694f37712e 100644 --- a/opencl/test/unit_test/api/cl_api_tests.h +++ b/opencl/test/unit_test/api/cl_api_tests.h @@ -15,6 +15,7 @@ #include "opencl/test/unit_test/fixtures/platform_fixture.h" #include "opencl/test/unit_test/helpers/ult_limits.h" #include "opencl/test/unit_test/helpers/variable_backup.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "opencl/test/unit_test/mocks/mock_kernel.h" #include "test.h" @@ -48,7 +49,7 @@ struct ApiFixture : PlatformFixture { pContext = Context::create(nullptr, ClDeviceVector(&testedClDevice, 1), nullptr, nullptr, retVal); EXPECT_EQ(retVal, CL_SUCCESS); - pCommandQueue = new CommandQueue(pContext, pDevice, nullptr); + pCommandQueue = new MockCommandQueue(pContext, pDevice, nullptr); pProgram = new MockProgram(*pDevice->getExecutionEnvironment(), pContext, false, &pDevice->getDevice()); diff --git a/opencl/test/unit_test/api/cl_get_event_profiling_info_tests.inl b/opencl/test/unit_test/api/cl_get_event_profiling_info_tests.inl index 27c6785381..26a44126c8 100644 --- a/opencl/test/unit_test/api/cl_get_event_profiling_info_tests.inl +++ b/opencl/test/unit_test/api/cl_get_event_profiling_info_tests.inl @@ -262,7 +262,7 @@ class clEventProfilingWithPerfCountersTests : public DeviceInstrumentationFixtur cl_int retVal = CL_SUCCESS; context = std::unique_ptr(Context::create(nullptr, ClDeviceVector(&deviceId, 1), nullptr, nullptr, retVal)); - commandQueue = std::make_unique(context.get(), device.get(), nullptr); + commandQueue = std::make_unique(context.get(), device.get(), nullptr); event = std::make_unique(commandQueue.get(), 0, 0, 0); event->setStatus(CL_COMPLETE); commandQueue->getPerfCounters()->getApiReport(0, nullptr, ¶m_value_size, true); diff --git a/opencl/test/unit_test/api/cl_unified_shared_memory_tests.inl b/opencl/test/unit_test/api/cl_unified_shared_memory_tests.inl index 8ba9c41906..9514d6b080 100644 --- a/opencl/test/unit_test/api/cl_unified_shared_memory_tests.inl +++ b/opencl/test/unit_test/api/cl_unified_shared_memory_tests.inl @@ -585,7 +585,7 @@ TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemsetINTELisCalledWithProperParam auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL(mockContext.get(), mockContext->getDevice(0u), nullptr, 400, 0, &retVal); - struct MockedCommandQueue : public CommandQueue { + struct MockedCommandQueue : public MockCommandQueue { cl_int enqueueSVMMemFill(void *svmPtr, const void *pattern, size_t patternSize, @@ -627,7 +627,7 @@ TEST(clUnifiedSharedMemoryTests, whenclEnqueueMemFillINTELisCalledWithProperPara auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL(mockContext.get(), mockContext->getDevice(0u), nullptr, 400, 0, &retVal); - struct MockedCommandQueue : public CommandQueue { + struct MockedCommandQueue : public MockCommandQueue { cl_int enqueueSVMMemFill(void *svmPtr, const void *pattern, size_t patternSize, @@ -669,7 +669,7 @@ TEST(clUnifiedSharedMemoryTests, givenTwoUnifiedMemoryAllocationsWhenTheyAreCopi auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL(mockContext.get(), mockContext->getDevice(0u), nullptr, 400, 0, &retVal); auto unfiedMemorySharedAllocation = clSharedMemAllocINTEL(mockContext.get(), mockContext->getDevice(0u), nullptr, 400, 0, &retVal); - struct MockedCommandQueue : public CommandQueue { + struct MockedCommandQueue : public MockCommandQueue { cl_int enqueueSVMMemcpy(cl_bool blockingCopy, void *dstPtr, const void *srcPtr, @@ -705,7 +705,7 @@ TEST(clUnifiedSharedMemoryTests, whenClEnqueueMigrateMemINTELisCalledWithWrongQu } TEST(clUnifiedSharedMemoryTests, whenClEnqueueMigrateMemINTELisCalledWithProperParametersThenSuccessIsReturned) { - CommandQueue cmdQ; + MockCommandQueue cmdQ; void *unifiedMemoryAlloc = reinterpret_cast(0x1234); auto retVal = clEnqueueMigrateMemINTEL(&cmdQ, unifiedMemoryAlloc, 10, 0, 0, nullptr, nullptr); @@ -718,7 +718,7 @@ TEST(clUnifiedSharedMemoryTests, whenClEnqueueMemAdviseINTELisCalledWithWrongQue } TEST(clUnifiedSharedMemoryTests, whenClEnqueueMemAdviseINTELisCalledWithProperParametersThenSuccessIsReturned) { - CommandQueue cmdQ; + MockCommandQueue cmdQ; void *unifiedMemoryAlloc = reinterpret_cast(0x1234); auto retVal = clEnqueueMemAdviseINTEL(&cmdQ, unifiedMemoryAlloc, 10, 0, 0, nullptr, nullptr); diff --git a/opencl/test/unit_test/command_queue/command_queue_fixture.cpp b/opencl/test/unit_test/command_queue/command_queue_fixture.cpp index 42b31b70ab..4c28ef699c 100644 --- a/opencl/test/unit_test/command_queue/command_queue_fixture.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_fixture.cpp @@ -11,6 +11,7 @@ #include "opencl/source/command_queue/command_queue_hw.h" #include "opencl/source/context/context.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "opencl/test/unit_test/mocks/mock_device.h" #include "gtest/gtest.h" @@ -86,7 +87,7 @@ CommandQueue *CommandQueueFixture::createCommandQueue( ClDevice *device, cl_command_queue_properties properties) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, properties, 0}; - return new CommandQueue( + return new MockCommandQueue( context, device, props); diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index f4d594cc54..ceaac8060b 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -114,7 +114,7 @@ INSTANTIATE_TEST_CASE_P(CommandQueue, ::testing::ValuesIn(AllCommandQueueProperties)); TEST(CommandQueue, WhenConstructingCommandQueueThenTaskLevelAndTaskCountAreZero) { - CommandQueue cmdQ(nullptr, nullptr, 0); + MockCommandQueue cmdQ(nullptr, nullptr, 0); EXPECT_EQ(0u, cmdQ.taskLevel); EXPECT_EQ(0u, cmdQ.taskCount); } @@ -147,7 +147,7 @@ TEST_F(GetTagTest, GivenSetHwTagWhenGettingHwTagThenCorrectTagIsReturned) { TEST_F(GetTagTest, GivenInitialValueWhenGettingHwTagThenCorrectTagIsReturned) { MockContext context; - CommandQueue commandQueue(&context, pClDevice, 0); + MockCommandQueue commandQueue(&context, pClDevice, 0); EXPECT_EQ(initialHardwareTag, commandQueue.getHwTag()); } @@ -155,7 +155,7 @@ TEST_F(GetTagTest, GivenInitialValueWhenGettingHwTagThenCorrectTagIsReturned) { TEST(CommandQueue, GivenUpdatedCompletionStampWhenGettingCompletionStampThenUpdatedValueIsReturned) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); CompletionStamp cs = { cmdQ.taskCount + 100, @@ -171,7 +171,7 @@ TEST(CommandQueue, GivenUpdatedCompletionStampWhenGettingCompletionStampThenUpda TEST(CommandQueue, givenTimeStampWithTaskCountNotReadyStatusWhenupdateFromCompletionStampIsBeingCalledThenQueueTaskCountIsNotUpdated) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); cmdQ.taskCount = 1u; @@ -187,7 +187,7 @@ TEST(CommandQueue, GivenOOQwhenUpdateFromCompletionStampWithTrueIsCalledThenTask MockContext context; const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0}; - CommandQueue cmdQ(&context, nullptr, props); + MockCommandQueue cmdQ(&context, nullptr, props); auto oldTL = cmdQ.taskLevel; CompletionStamp cs = { @@ -204,7 +204,7 @@ TEST(CommandQueue, GivenOOQwhenUpdateFromCompletionStampWithTrueIsCalledThenTask TEST(CommandQueue, givenDeviceWhenCreatingCommandQueueThenPickCsrFromDefaultEngine) { auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); - CommandQueue cmdQ(nullptr, mockDevice.get(), 0); + MockCommandQueue cmdQ(nullptr, mockDevice.get(), 0); auto defaultCsr = mockDevice->getDefaultEngine().commandStreamReceiver; EXPECT_EQ(defaultCsr, &cmdQ.getGpgpuCommandStreamReceiver()); @@ -214,7 +214,7 @@ TEST(CommandQueue, givenDeviceNotSupportingBlitOperationsWhenQueueIsCreatedThenD HardwareInfo hwInfo = *platformDevices[0]; hwInfo.capabilityTable.blitterOperationsSupported = false; auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); - CommandQueue cmdQ(nullptr, mockDevice.get(), 0); + MockCommandQueue cmdQ(nullptr, mockDevice.get(), 0); EXPECT_EQ(nullptr, cmdQ.getBcsCommandStreamReceiver()); } @@ -242,7 +242,7 @@ HWTEST_F(CommandQueueWithSubDevicesTest, givenDeviceWithSubDevicesSupportingBlit } auto bcsEngine = subDevice->getEngine(aub_stream::EngineType::ENGINE_BCS, false); - CommandQueue cmdQ(nullptr, device.get(), 0); + MockCommandQueue cmdQ(nullptr, device.get(), 0); EXPECT_NE(nullptr, cmdQ.getBcsCommandStreamReceiver()); EXPECT_EQ(bcsEngine.commandStreamReceiver, cmdQ.getBcsCommandStreamReceiver()); @@ -252,7 +252,7 @@ HWTEST_F(CommandQueueWithSubDevicesTest, givenDeviceWithSubDevicesSupportingBlit TEST(CommandQueue, givenCmdQueueBlockedByReadyVirtualEventWhenUnblockingThenUpdateFlushTaskFromEvent) { auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto context = new MockContext; - auto cmdQ = new CommandQueue(context, mockDevice.get(), 0); + auto cmdQ = new MockCommandQueue(context, mockDevice.get(), 0); auto userEvent = new Event(cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0); userEvent->setStatus(CL_COMPLETE); userEvent->flushStamp->setStamp(5); @@ -272,7 +272,7 @@ TEST(CommandQueue, givenCmdQueueBlockedByReadyVirtualEventWhenUnblockingThenUpda TEST(CommandQueue, givenCmdQueueBlockedByAbortedVirtualEventWhenUnblockingThenUpdateFlushTaskFromEvent) { auto context = new MockContext; auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - auto cmdQ = new CommandQueue(context, mockDevice.get(), 0); + auto cmdQ = new MockCommandQueue(context, mockDevice.get(), 0); auto userEvent = new Event(cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0); userEvent->setStatus(-1); @@ -309,7 +309,7 @@ HWTEST_F(CommandQueueCommandStreamTest, givenCommandQueueThatWaitsOnAbortedUserE MockContext context; auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); - CommandQueue cmdQ(&context, mockDevice.get(), 0); + MockCommandQueue cmdQ(&context, mockDevice.get(), 0); auto &commandStreamReceiver = mockDevice->getUltCommandStreamReceiver(); commandStreamReceiver.taskLevel = 100u; @@ -324,7 +324,7 @@ HWTEST_F(CommandQueueCommandStreamTest, givenCommandQueueThatWaitsOnAbortedUserE TEST_F(CommandQueueCommandStreamTest, GivenValidCommandQueueWhenGettingCommandStreamThenValidObjectIsReturned) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue commandQueue(context.get(), pClDevice, props); + MockCommandQueue commandQueue(context.get(), pClDevice, props); auto &cs = commandQueue.getCS(1024); EXPECT_NE(nullptr, &cs); @@ -332,7 +332,7 @@ TEST_F(CommandQueueCommandStreamTest, GivenValidCommandQueueWhenGettingCommandSt TEST_F(CommandQueueCommandStreamTest, GivenValidCommandStreamWhenGettingGraphicsAllocationThenMaxAvailableSpaceAndUnderlyingBufferSizeAreCorrect) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue commandQueue(context.get(), pClDevice, props); + MockCommandQueue commandQueue(context.get(), pClDevice, props); size_t minSizeRequested = 20; auto &cs = commandQueue.getCS(minSizeRequested); @@ -349,7 +349,7 @@ TEST_F(CommandQueueCommandStreamTest, GivenValidCommandStreamWhenGettingGraphics TEST_F(CommandQueueCommandStreamTest, GivenRequiredSizeWhenGettingCommandStreamThenMaxAvailableSpaceIsEqualOrGreaterThanRequiredSize) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue commandQueue(context.get(), pClDevice, props); + MockCommandQueue commandQueue(context.get(), pClDevice, props); size_t requiredSize = 16384; const auto &commandStream = commandQueue.getCS(requiredSize); @@ -359,7 +359,7 @@ TEST_F(CommandQueueCommandStreamTest, GivenRequiredSizeWhenGettingCommandStreamT TEST_F(CommandQueueCommandStreamTest, WhenGettingCommandStreamWithNewSizeThenMaxAvailableSpaceIsEqualOrGreaterThanNewSize) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue commandQueue(context.get(), pClDevice, props); + MockCommandQueue commandQueue(context.get(), pClDevice, props); auto &commandStreamInitial = commandQueue.getCS(1024); size_t requiredSize = commandStreamInitial.getMaxAvailableSpace() + 42; @@ -371,7 +371,7 @@ TEST_F(CommandQueueCommandStreamTest, WhenGettingCommandStreamWithNewSizeThenMax TEST_F(CommandQueueCommandStreamTest, givenCommandStreamReceiverWithReusableAllocationsWhenAskedForCommandStreamThenReturnsAllocationFromReusablePool) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); auto memoryManager = pDevice->getMemoryManager(); size_t requiredSize = alignUp(100 + CSRequirements::minCommandQueueCommandStreamSize + CSRequirements::csOverfetchSize, MemoryConstants::pageSize64k); @@ -390,7 +390,7 @@ TEST_F(CommandQueueCommandStreamTest, givenCommandStreamReceiverWithReusableAllo } TEST_F(CommandQueueCommandStreamTest, givenCommandQueueWhenItIsDestroyedThenCommandStreamIsPutOnTheReusabeList) { - auto cmdQ = new CommandQueue(context.get(), pClDevice, 0); + auto cmdQ = new MockCommandQueue(context.get(), pClDevice, 0); const auto &commandStream = cmdQ->getCS(100); auto graphicsAllocation = commandStream.getGraphicsAllocation(); EXPECT_TRUE(pDevice->getDefaultEngine().commandStreamReceiver->getAllocationsForReuse().peekIsEmpty()); @@ -403,7 +403,7 @@ TEST_F(CommandQueueCommandStreamTest, givenCommandQueueWhenItIsDestroyedThenComm TEST_F(CommandQueueCommandStreamTest, WhenAskedForNewCommandStreamThenOldHeapIsStoredForReuse) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); EXPECT_TRUE(pDevice->getDefaultEngine().commandStreamReceiver->getAllocationsForReuse().peekIsEmpty()); @@ -422,7 +422,7 @@ TEST_F(CommandQueueCommandStreamTest, WhenAskedForNewCommandStreamThenOldHeapIsS TEST_F(CommandQueueCommandStreamTest, givenCommandQueueWhenGetCSIsCalledThenCommandStreamAllocationTypeShouldBeSetToCommandBuffer) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); const auto &commandStream = cmdQ.getCS(100); auto commandStreamAllocation = commandStream.getGraphicsAllocation(); @@ -482,7 +482,7 @@ struct CommandQueueIndirectHeapTest : public CommandQueueMemoryDevice, TEST_P(CommandQueueIndirectHeapTest, WhenGettingIndirectHeapThenValidObjectIsReturned) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), 8192); EXPECT_NE(nullptr, &indirectHeap); @@ -490,7 +490,7 @@ TEST_P(CommandQueueIndirectHeapTest, WhenGettingIndirectHeapThenValidObjectIsRet TEST_P(CommandQueueIndirectHeapTest, givenIndirectObjectHeapWhenItIsQueriedForInternalAllocationThenTrueIsReturned) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), 8192); if (this->GetParam() == IndirectHeap::INDIRECT_OBJECT) { @@ -502,7 +502,7 @@ TEST_P(CommandQueueIndirectHeapTest, givenIndirectObjectHeapWhenItIsQueriedForIn HWTEST_P(CommandQueueIndirectHeapTest, GivenIndirectHeapWhenGettingAvailableSpaceThenCorrectSizeIsReturned) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), sizeof(uint32_t)); if (this->GetParam() == IndirectHeap::SURFACE_STATE) { @@ -515,7 +515,7 @@ HWTEST_P(CommandQueueIndirectHeapTest, GivenIndirectHeapWhenGettingAvailableSpac TEST_P(CommandQueueIndirectHeapTest, GivenRequiredSizeWhenGettingIndirectHeapThenIndirectHeapHasRequiredSize) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); size_t requiredSize = 16384; const auto &indirectHeap = cmdQ.getIndirectHeap(this->GetParam(), requiredSize); @@ -525,7 +525,7 @@ TEST_P(CommandQueueIndirectHeapTest, GivenRequiredSizeWhenGettingIndirectHeapThe TEST_P(CommandQueueIndirectHeapTest, WhenGettingIndirectHeapWithNewSizeThenMaxAvailableSpaceIsEqualOrGreaterThanNewSize) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); auto &indirectHeapInitial = cmdQ.getIndirectHeap(this->GetParam(), 10); size_t requiredSize = indirectHeapInitial.getMaxAvailableSpace() + 42; @@ -543,7 +543,7 @@ TEST_P(CommandQueueIndirectHeapTest, WhenGettingIndirectHeapWithNewSizeThenMaxAv TEST_P(CommandQueueIndirectHeapTest, WhenGettingIndirectHeapThenSizeIsAlignedToCacheLine) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); size_t minHeapSize = 64 * KB; auto &indirectHeapInitial = cmdQ.getIndirectHeap(this->GetParam(), 2 * minHeapSize + 1); @@ -560,7 +560,7 @@ TEST_P(CommandQueueIndirectHeapTest, WhenGettingIndirectHeapThenSizeIsAlignedToC TEST_P(CommandQueueIndirectHeapTest, givenCommandStreamReceiverWithReusableAllocationsWhenAskedForHeapAllocationThenAllocationFromReusablePoolIsReturned) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); auto memoryManager = pDevice->getMemoryManager(); @@ -600,7 +600,7 @@ TEST_P(CommandQueueIndirectHeapTest, givenCommandStreamReceiverWithReusableAlloc HWTEST_P(CommandQueueIndirectHeapTest, WhenAskedForNewHeapThenOldHeapIsStoredForReuse) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); EXPECT_TRUE(commandStreamReceiver.getAllocationsForReuse().peekIsEmpty()); @@ -645,7 +645,7 @@ TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithoutHeapAllocationWhenA } TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWithResourceCachingActiveWhenQueueISDestroyedThenIndirectHeapIsNotOnReuseList) { - auto cmdQ = new CommandQueue(context.get(), pClDevice, 0); + auto cmdQ = new MockCommandQueue(context.get(), pClDevice, 0); cmdQ->getIndirectHeap(this->GetParam(), 100); EXPECT_TRUE(pDevice->getDefaultEngine().commandStreamReceiver->getAllocationsForReuse().peekIsEmpty()); @@ -709,7 +709,7 @@ TEST_P(CommandQueueIndirectHeapTest, GivenCommandQueueWithHeapWhenGraphicAllocat TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetIndirectHeapIsCalledThenIndirectHeapAllocationTypeShouldBeSetToInternalHeapForIohAndLinearStreamForOthers) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); auto heapType = this->GetParam(); @@ -726,7 +726,7 @@ TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetIndirectHeapIsCalle TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetHeapMemoryIsCalledThenHeapIsCreated) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); IndirectHeap *indirectHeap = nullptr; cmdQ.allocateHeapMemory(this->GetParam(), 100, indirectHeap); @@ -739,7 +739,7 @@ TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetHeapMemoryIsCalledT TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetHeapMemoryIsCalledWithAlreadyAllocatedHeapThenGraphicsAllocationIsCreated) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - CommandQueue cmdQ(context.get(), pClDevice, props); + MockCommandQueue cmdQ(context.get(), pClDevice, props); IndirectHeap heap(nullptr, size_t{100}); @@ -763,13 +763,13 @@ using CommandQueueTests = ::testing::Test; HWTEST_F(CommandQueueTests, givenMultipleCommandQueuesWhenMarkerIsEmittedThenGraphicsAllocationIsReused) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); MockContext context(device.get()); - std::unique_ptr commandQ(new CommandQueue(&context, device.get(), 0)); + std::unique_ptr commandQ(new MockCommandQueue(&context, device.get(), 0)); *device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 0; commandQ->enqueueMarkerWithWaitList(0, nullptr, nullptr); commandQ->enqueueMarkerWithWaitList(0, nullptr, nullptr); auto commandStreamGraphicsAllocation = commandQ->getCS(0).getGraphicsAllocation(); - commandQ.reset(new CommandQueue(&context, device.get(), 0)); + commandQ.reset(new MockCommandQueue(&context, device.get(), 0)); commandQ->enqueueMarkerWithWaitList(0, nullptr, nullptr); commandQ->enqueueMarkerWithWaitList(0, nullptr, nullptr); auto commandStreamGraphicsAllocation2 = commandQ->getCS(0).getGraphicsAllocation(); @@ -829,7 +829,7 @@ HWTEST_F(WaitForQueueCompletionTests, whenFinishIsCalledThenCallWaitWithoutQuick TEST(CommandQueue, givenEnqueueAcquireSharedObjectsWhenNoObjectsThenReturnSuccess) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); cl_uint numObjects = 0; cl_mem *memObjects = nullptr; @@ -847,7 +847,7 @@ class MockSharingHandler : public SharingHandler { TEST(CommandQueue, givenEnqueuesForSharedObjectsWithImageWhenUsingSharingHandlerThenReturnSuccess) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); MockSharingHandler *mockSharingHandler = new MockSharingHandler; auto image = std::unique_ptr(ImageHelper::create(&context)); @@ -867,7 +867,7 @@ TEST(CommandQueue, givenEnqueuesForSharedObjectsWithImageWhenUsingSharingHandler TEST(CommandQueue, givenEnqueuesForSharedObjectsWithImageWhenUsingSharingHandlerWithEventThenReturnSuccess) { auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); MockContext context; - CommandQueue cmdQ(&context, mockDevice.get(), 0); + MockCommandQueue cmdQ(&context, mockDevice.get(), 0); MockSharingHandler *mockSharingHandler = new MockSharingHandler; auto image = std::unique_ptr(ImageHelper::create(&context)); @@ -894,7 +894,7 @@ TEST(CommandQueue, givenEnqueuesForSharedObjectsWithImageWhenUsingSharingHandler TEST(CommandQueue, givenEnqueueAcquireSharedObjectsWhenIncorrectArgumentsThenReturnProperError) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); cl_uint numObjects = 1; cl_mem *memObjects = nullptr; @@ -934,7 +934,7 @@ TEST(CommandQueue, givenEnqueueAcquireSharedObjectsWhenIncorrectArgumentsThenRet TEST(CommandQueue, givenEnqueueReleaseSharedObjectsWhenNoObjectsThenReturnSuccess) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); cl_uint numObjects = 0; cl_mem *memObjects = nullptr; @@ -945,7 +945,7 @@ TEST(CommandQueue, givenEnqueueReleaseSharedObjectsWhenNoObjectsThenReturnSucces TEST(CommandQueue, givenEnqueueReleaseSharedObjectsWhenIncorrectArgumentsThenReturnProperError) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); cl_uint numObjects = 1; cl_mem *memObjects = nullptr; @@ -990,7 +990,7 @@ TEST(CommandQueue, givenEnqueueAcquireSharedObjectsCallWhenAcquireFailsThenCorre } }; MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); auto buffer = std::unique_ptr(BufferHelper<>::create(&context)); MockSharingHandler *handler = new MockSharingHandler; @@ -1006,7 +1006,7 @@ HWTEST_F(CommandQueueCommandStreamTest, givenDebugKernelWhenSetupDebugSurfaceIsC MockProgram program(*pDevice->getExecutionEnvironment()); program.enableKernelDebug(); std::unique_ptr kernel(MockKernel::create(*pDevice, &program)); - CommandQueue cmdQ(context.get(), pClDevice, 0); + MockCommandQueue cmdQ(context.get(), pClDevice, 0); kernel->setSshLocal(nullptr, sizeof(RENDER_SURFACE_STATE) + kernel->getAllocatedKernelInfo()->patchInfo.pAllocateSystemThreadSurface->Offset); kernel->getAllocatedKernelInfo()->usesSsh = true; @@ -1025,7 +1025,7 @@ HWTEST_F(CommandQueueCommandStreamTest, givenCsrWithDebugSurfaceAllocatedWhenSet MockProgram program(*pDevice->getExecutionEnvironment()); program.enableKernelDebug(); std::unique_ptr kernel(MockKernel::create(*pDevice, &program)); - CommandQueue cmdQ(context.get(), pClDevice, 0); + MockCommandQueue cmdQ(context.get(), pClDevice, 0); kernel->setSshLocal(nullptr, sizeof(RENDER_SURFACE_STATE) + kernel->getAllocatedKernelInfo()->patchInfo.pAllocateSystemThreadSurface->Offset); kernel->getAllocatedKernelInfo()->usesSsh = true; @@ -1069,7 +1069,7 @@ TEST(CommandQueuePropertiesTests, whenGetEngineIsCalledThenQueueEngineIsReturned TEST(CommandQueue, GivenCommandQueueWhenEnqueueResourceBarrierCalledThenSuccessReturned) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); cl_int result = cmdQ.enqueueResourceBarrier( nullptr, @@ -1081,7 +1081,7 @@ TEST(CommandQueue, GivenCommandQueueWhenEnqueueResourceBarrierCalledThenSuccessR TEST(CommandQueue, GivenCommandQueueWhenCheckingIfIsCacheFlushCommandCalledThenFalseReturned) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); bool isCommandCacheFlush = cmdQ.isCacheFlushCommand(0u); EXPECT_FALSE(isCommandCacheFlush); @@ -1089,7 +1089,7 @@ TEST(CommandQueue, GivenCommandQueueWhenCheckingIfIsCacheFlushCommandCalledThenF TEST(CommandQueue, GivenCommandQueueWhenEnqueueInitDispatchGlobalsCalledThenSuccessReturned) { MockContext context; - CommandQueue cmdQ(&context, nullptr, 0); + MockCommandQueue cmdQ(&context, nullptr, 0); cl_int result = cmdQ.enqueueInitDispatchGlobals( nullptr, diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp index 1fc6a51db0..900761029a 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -1524,7 +1524,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelWhenItIsUnblocke pDevice->resetCommandStreamReceiver(csr); uint32_t numGrfRequired = 666u; - auto pCmdQ = std::make_unique(&mockContext, pClDevice, nullptr); + auto pCmdQ = std::make_unique(&mockContext, pClDevice, nullptr); auto mockProgram = std::make_unique(*pDevice->getExecutionEnvironment(), &mockContext, false, pDevice); std::unique_ptr pKernel(MockKernel::create(*pDevice, mockProgram.get(), numGrfRequired)); diff --git a/opencl/test/unit_test/context/context_tests.cpp b/opencl/test/unit_test/context/context_tests.cpp index 3e8a0cf324..a07b7c5b0e 100644 --- a/opencl/test/unit_test/context/context_tests.cpp +++ b/opencl/test/unit_test/context/context_tests.cpp @@ -14,6 +14,7 @@ #include "opencl/source/sharings/sharing.h" #include "opencl/test/unit_test/fixtures/platform_fixture.h" #include "opencl/test/unit_test/helpers/variable_backup.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "opencl/test/unit_test/mocks/mock_context.h" #include "opencl/test/unit_test/mocks/mock_deferred_deleter.h" #include "opencl/test/unit_test/mocks/mock_device.h" @@ -114,7 +115,7 @@ TEST_F(ContextTest, WhenSettingSpecialQueueThenQueueIsAvailable) { auto specialQ = context.getSpecialQueue(); EXPECT_EQ(specialQ, nullptr); - auto cmdQ = new CommandQueue(&context, (ClDevice *)devices[0], 0); + auto cmdQ = new MockCommandQueue(&context, (ClDevice *)devices[0], 0); context.setSpecialQueue(cmdQ); specialQ = context.getSpecialQueue(); EXPECT_NE(specialQ, nullptr); @@ -132,13 +133,13 @@ TEST_F(ContextTest, givenCmdQueueWithoutContextWhenBeingCreatedNextDeletedThenCo MockContext context((ClDevice *)devices[0]); EXPECT_EQ(1, context.getRefInternalCount()); - auto cmdQ1 = new CommandQueue(); + auto cmdQ1 = new MockCommandQueue(); EXPECT_EQ(1, context.getRefInternalCount()); delete cmdQ1; EXPECT_EQ(1, context.getRefInternalCount()); - auto cmdQ2 = new CommandQueue(nullptr, (ClDevice *)devices[0], 0); + auto cmdQ2 = new MockCommandQueue(nullptr, (ClDevice *)devices[0], 0); EXPECT_EQ(1, context.getRefInternalCount()); delete cmdQ2; @@ -167,7 +168,7 @@ TEST_F(ContextTest, givenCmdQueueWithContextWhenBeingCreatedNextDeletedThenConte MockContext context((ClDevice *)devices[0]); EXPECT_EQ(1, context.getRefInternalCount()); - auto cmdQ = new CommandQueue(&context, (ClDevice *)devices[0], 0); + auto cmdQ = new MockCommandQueue(&context, (ClDevice *)devices[0], 0); EXPECT_EQ(2, context.getRefInternalCount()); delete cmdQ; @@ -227,7 +228,7 @@ TEST_F(ContextTest, givenSpecialCmdQueueWithContextWhenBeingCreatedNextAutoDelet MockContext context((ClDevice *)devices[0], true); EXPECT_EQ(1, context.getRefInternalCount()); - auto cmdQ = new CommandQueue(&context, (ClDevice *)devices[0], 0); + auto cmdQ = new MockCommandQueue(&context, (ClDevice *)devices[0], 0); context.overrideSpecialQueueAndDecrementRefCount(cmdQ); EXPECT_EQ(1, context.getRefInternalCount()); @@ -238,7 +239,7 @@ TEST_F(ContextTest, givenSpecialCmdQueueWithContextWhenBeingCreatedNextDeletedTh MockContext context((ClDevice *)devices[0], true); EXPECT_EQ(1, context.getRefInternalCount()); - auto cmdQ = new CommandQueue(&context, (ClDevice *)devices[0], 0); + auto cmdQ = new MockCommandQueue(&context, (ClDevice *)devices[0], 0); context.overrideSpecialQueueAndDecrementRefCount(cmdQ); EXPECT_EQ(1, context.getRefInternalCount()); diff --git a/opencl/test/unit_test/d3d_sharing/d3d_tests_part2.cpp b/opencl/test/unit_test/d3d_sharing/d3d_tests_part2.cpp index d934533d65..168e95f93f 100644 --- a/opencl/test/unit_test/d3d_sharing/d3d_tests_part2.cpp +++ b/opencl/test/unit_test/d3d_sharing/d3d_tests_part2.cpp @@ -33,9 +33,9 @@ TYPED_TEST_P(D3DTests, givenSharedResourceBufferAndInteropUserSyncEnabledWhenRel .Times(1) .WillOnce(SetArgPointee<0>(this->mockSharingFcns->mockBufferDesc)); - class MockCmdQ : public CommandQueue { + class MockCmdQ : public MockCommandQueue { public: - MockCmdQ(Context *context, ClDevice *device, const cl_queue_properties *properties) : CommandQueue(context, device, properties){}; + MockCmdQ(Context *context, ClDevice *device, const cl_queue_properties *properties) : MockCommandQueue(context, device, properties){}; cl_int finish() override { finishCalled++; return CL_SUCCESS; @@ -61,9 +61,9 @@ TYPED_TEST_P(D3DTests, givenSharedResourceBufferAndInteropUserSyncEnabledWhenRel TYPED_TEST_P(D3DTests, givenNonSharedResourceBufferAndInteropUserSyncDisabledWhenReleaseIsCalledThenDoExplicitFinishTwice) { this->context->setInteropUserSyncEnabled(false); - class MockCmdQ : public CommandQueue { + class MockCmdQ : public MockCommandQueue { public: - MockCmdQ(Context *context, ClDevice *device, const cl_queue_properties *properties) : CommandQueue(context, device, properties){}; + MockCmdQ(Context *context, ClDevice *device, const cl_queue_properties *properties) : MockCommandQueue(context, device, properties){}; cl_int finish() override { finishCalled++; return CL_SUCCESS; @@ -94,9 +94,9 @@ TYPED_TEST_P(D3DTests, givenSharedResourceBufferAndInteropUserSyncDisabledWhenRe .Times(1) .WillOnce(SetArgPointee<0>(this->mockSharingFcns->mockBufferDesc)); - class MockCmdQ : public CommandQueue { + class MockCmdQ : public MockCommandQueue { public: - MockCmdQ(Context *context, ClDevice *device, const cl_queue_properties *properties) : CommandQueue(context, device, properties){}; + MockCmdQ(Context *context, ClDevice *device, const cl_queue_properties *properties) : MockCommandQueue(context, device, properties){}; cl_int finish() override { finishCalled++; return CL_SUCCESS; @@ -122,9 +122,9 @@ TYPED_TEST_P(D3DTests, givenSharedResourceBufferAndInteropUserSyncDisabledWhenRe TYPED_TEST_P(D3DTests, givenNonSharedResourceBufferAndInteropUserSyncEnabledWhenReleaseIsCalledThenDoExplicitFinishOnce) { this->context->setInteropUserSyncEnabled(true); - class MockCmdQ : public CommandQueue { + class MockCmdQ : public MockCommandQueue { public: - MockCmdQ(Context *context, ClDevice *device, const cl_queue_properties *properties) : CommandQueue(context, device, properties){}; + MockCmdQ(Context *context, ClDevice *device, const cl_queue_properties *properties) : MockCommandQueue(context, device, properties){}; cl_int finish() override { finishCalled++; return CL_SUCCESS; diff --git a/opencl/test/unit_test/device_queue/device_queue_tests.cpp b/opencl/test/unit_test/device_queue/device_queue_tests.cpp index f6dae07c12..271d4a2af9 100644 --- a/opencl/test/unit_test/device_queue/device_queue_tests.cpp +++ b/opencl/test/unit_test/device_queue/device_queue_tests.cpp @@ -320,7 +320,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueTest, dispatchScheduler) { DeviceQueue devQueue; MockContext context; MockProgram program(*device->getExecutionEnvironment()); - CommandQueue cmdQ(nullptr, nullptr, 0); + MockCommandQueue cmdQ(nullptr, nullptr, 0); KernelInfo info; MockSchedulerKernel *kernel = new MockSchedulerKernel(&program, info, *device); LinearStream cmdStream; diff --git a/opencl/test/unit_test/event/event_builder_tests.cpp b/opencl/test/unit_test/event/event_builder_tests.cpp index 5b667a878a..7c37601c15 100644 --- a/opencl/test/unit_test/event/event_builder_tests.cpp +++ b/opencl/test/unit_test/event/event_builder_tests.cpp @@ -78,7 +78,7 @@ TEST(EventBuilder, givenVirtualEventWithCommandThenFinalizeAddChild) { }; auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); - CommandQueue cmdQ(nullptr, device.get(), nullptr); + MockCommandQueue cmdQ(nullptr, device.get(), nullptr); MockKernelWithInternals kernel(*device); IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr; @@ -127,7 +127,7 @@ TEST(EventBuilder, givenVirtualEventWithSubmittedCommandAsParentThenFinalizeNotA }; auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); - CommandQueue cmdQ(nullptr, device.get(), nullptr); + MockCommandQueue cmdQ(nullptr, device.get(), nullptr); MockKernelWithInternals kernel(*device); IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr; diff --git a/opencl/test/unit_test/event/event_tests.cpp b/opencl/test/unit_test/event/event_tests.cpp index 827b2d226a..128f16d158 100644 --- a/opencl/test/unit_test/event/event_tests.cpp +++ b/opencl/test/unit_test/event/event_tests.cpp @@ -111,7 +111,7 @@ TEST(Event, WhenGettingTaskCountThenCorrectValueIsReturned) { TEST(Event, WhenGettingEventInfoThenCqIsReturned) { auto mockDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto ctx = std::unique_ptr(new MockContext()); - auto cmdQ = std::unique_ptr(new MockCommandQueue(ctx.get(), mockDevice.get(), 0)); + auto cmdQ = std::unique_ptr(new MockCommandQueue(ctx.get(), mockDevice.get(), 0)); Event *event = new Event(cmdQ.get(), CL_COMMAND_NDRANGE_KERNEL, 1, 5); cl_event clEvent = event; cl_command_queue cmdQResult = nullptr; @@ -457,7 +457,7 @@ class SurfaceMock : public Surface { }; TEST_F(InternalsEventTest, GivenSubmitCommandFalseWhenSubmittingCommandsThenRefApiCountAndRefInternalGetHandledCorrectly) { - CommandQueue cmdQ(mockContext, pClDevice, nullptr); + MockCommandQueue cmdQ(mockContext, pClDevice, nullptr); MockEvent event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({pDevice->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER})); @@ -509,7 +509,7 @@ TEST_F(InternalsEventTest, GivenSubmitCommandFalseWhenSubmittingCommandsThenRefA } TEST_F(InternalsEventTest, GivenSubmitCommandTrueWhenSubmittingCommandsThenRefApiCountAndRefInternalGetHandledCorrectly) { - CommandQueue cmdQ(mockContext, pClDevice, nullptr); + MockCommandQueue cmdQ(mockContext, pClDevice, nullptr); MockEvent event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({pDevice->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER})); @@ -596,7 +596,7 @@ TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOut } TEST_F(InternalsEventTest, GivenMapOperationWhenSubmittingCommandsThenTaskLevelIsIncremented) { - auto pCmdQ = make_releaseable(mockContext, pClDevice, nullptr); + auto pCmdQ = make_releaseable(mockContext, pClDevice, nullptr); MockEvent event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto &csr = pCmdQ->getGpgpuCommandStreamReceiver(); @@ -617,7 +617,7 @@ TEST_F(InternalsEventTest, GivenMapOperationWhenSubmittingCommandsThenTaskLevelI } TEST_F(InternalsEventTest, GivenMapOperationNonZeroCopyBufferWhenSubmittingCommandsThenTaskLevelIsIncremented) { - auto pCmdQ = make_releaseable(mockContext, pClDevice, nullptr); + auto pCmdQ = make_releaseable(mockContext, pClDevice, nullptr); MockEvent event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto &csr = pCmdQ->getGpgpuCommandStreamReceiver(); @@ -682,7 +682,7 @@ class InternalsEventProfilingTest : public InternalsEventTest, TEST_P(InternalsEventProfilingTest, GivenProfilingWhenEventCreatedThenProfilingSet) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - std::unique_ptr pCmdQ(new CommandQueue(mockContext, pClDevice, props)); + std::unique_ptr pCmdQ(new MockCommandQueue(mockContext, pClDevice, props)); std::unique_ptr> event(new MockEvent(pCmdQ.get(), GetParam(), 0, 0)); EXPECT_TRUE(event.get()->isProfilingEnabled()); @@ -694,7 +694,7 @@ INSTANTIATE_TEST_CASE_P(InternalsEventProfilingTest, TEST_F(InternalsEventTest, GivenProfilingWhenUserEventCreatedThenProfilingNotSet) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - std::unique_ptr pCmdQ(new CommandQueue(mockContext, pClDevice, props)); + std::unique_ptr pCmdQ(new MockCommandQueue(mockContext, pClDevice, props)); std::unique_ptr> event(new MockEvent(pCmdQ.get(), CL_COMMAND_USER, 0, 0)); EXPECT_FALSE(event.get()->isProfilingEnabled()); @@ -702,7 +702,7 @@ TEST_F(InternalsEventTest, GivenProfilingWhenUserEventCreatedThenProfilingNotSet TEST_F(InternalsEventTest, GivenProfilingWHENMapOperationTHENTimesSet) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - CommandQueue *pCmdQ = new CommandQueue(mockContext, pClDevice, props); + MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props); MockEvent *event = new MockEvent(pCmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0); @@ -729,7 +729,7 @@ TEST_F(InternalsEventTest, GivenProfilingWHENMapOperationTHENTimesSet) { TEST_F(InternalsEventTest, GivenUnMapOperationWhenSubmittingCommandsThenTaskLevelIsIncremented) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - auto pCmdQ = make_releaseable(mockContext, pClDevice, props); + auto pCmdQ = make_releaseable(mockContext, pClDevice, props); MockEvent event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto &csr = pCmdQ->getGpgpuCommandStreamReceiver(); @@ -751,7 +751,7 @@ TEST_F(InternalsEventTest, GivenUnMapOperationWhenSubmittingCommandsThenTaskLeve TEST_F(InternalsEventTest, givenBlockedMapCommandWhenSubmitIsCalledItReleasesMemObjectReference) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - auto pCmdQ = std::make_unique(mockContext, pClDevice, props); + auto pCmdQ = std::make_unique(mockContext, pClDevice, props); MockEvent event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto buffer = new UnalignedBuffer; @@ -770,7 +770,7 @@ TEST_F(InternalsEventTest, givenBlockedMapCommandWhenSubmitIsCalledItReleasesMem } TEST_F(InternalsEventTest, GivenUnMapOperationNonZeroCopyBufferWhenSubmittingCommandsThenTaskLevelIsIncremented) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - auto pCmdQ = std::make_unique(mockContext, pClDevice, props); + auto pCmdQ = std::make_unique(mockContext, pClDevice, props); MockEvent event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto &csr = pCmdQ->getGpgpuCommandStreamReceiver(); @@ -792,7 +792,7 @@ TEST_F(InternalsEventTest, GivenUnMapOperationNonZeroCopyBufferWhenSubmittingCom HWTEST_F(InternalsEventTest, givenCpuProfilingPathWhenEnqueuedMarkerThenDontUseTimeStampNode) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - CommandQueue *pCmdQ = new CommandQueue(mockContext, pClDevice, props); + MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props); MockEvent *event = new MockEvent(pCmdQ, CL_COMMAND_MARKER, 0, 0); event->setCPUProfilingPath(true); @@ -830,7 +830,7 @@ struct InternalsEventWithPerfCountersTest }; HWTEST_F(InternalsEventWithPerfCountersTest, givenCpuProfilingPerfCountersPathWhenEnqueuedMarkerThenDontUseTimeStampNodePerfCounterNode) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - CommandQueue *pCmdQ = new CommandQueue(mockContext, pClDevice, props); + MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props); bool ret = false; ret = pCmdQ->setPerfCountersEnabled(); EXPECT_TRUE(ret); @@ -856,7 +856,7 @@ HWTEST_F(InternalsEventWithPerfCountersTest, givenCpuProfilingPerfCountersPathWh HWTEST_F(InternalsEventWithPerfCountersTest, givenCpuProfilingPerfCountersPathWhenEnqueuedMarkerThenUseTimeStampNodePerfCounterNode) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - CommandQueue *pCmdQ = new CommandQueue(mockContext, pClDevice, props); + MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props); pCmdQ->setPerfCountersEnabled(); MockEvent *event = new MockEvent(pCmdQ, CL_COMMAND_MARKER, 0, 0); event->setCPUProfilingPath(true); @@ -883,7 +883,7 @@ HWTEST_F(InternalsEventWithPerfCountersTest, givenCpuProfilingPerfCountersPathWh TEST_F(InternalsEventWithPerfCountersTest, GivenPerfCountersEnabledWhenEventIsCreatedThenProfilingEnabledAndPerfCountersEnabledAreTrue) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - CommandQueue *pCmdQ = new CommandQueue(mockContext, pClDevice, props); + MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props); pCmdQ->setPerfCountersEnabled(); Event *ev = new Event(pCmdQ, CL_COMMAND_COPY_BUFFER, 3, 0); EXPECT_TRUE(ev->isProfilingEnabled()); @@ -978,7 +978,7 @@ HWTEST_F(InternalsEventTest, GivenBufferWithoutZeroCopyOnCommandMapOrUnmapFlushe pDevice->resetCommandStreamReceiver(csr); const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0}; - auto pCmdQ = make_releaseable(mockContext, pClDevice, props); + auto pCmdQ = make_releaseable(mockContext, pClDevice, props); MockNonZeroCopyBuff buffer(executionStamp); @@ -1169,7 +1169,7 @@ TEST_F(EventTest, GivenProfilingDisabledWhenEventIsCreatedThenPerfCountersAreDis TEST_F(InternalsEventTest, GivenOnlyProfilingEnabledWhenEventIsCreatedThenPerfCountersAreDisabled) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - CommandQueue *pCmdQ = new CommandQueue(mockContext, pClDevice, props); + MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props); Event *ev = new Event(pCmdQ, CL_COMMAND_COPY_BUFFER, 3, 0); EXPECT_TRUE(ev->isProfilingEnabled()); @@ -1245,7 +1245,7 @@ TEST_F(EventTest, givenOutEventWhenBlockingEnqueueHandledOnCpuThenUpdateTaskCoun TEST_F(EventTest, givenCmdQueueWithProfilingWhenIsCpuProfilingIsCalledThenTrueIsReturned) { const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0}; - std::unique_ptr pCmdQ(new CommandQueue(&mockContext, pClDevice, props)); + std::unique_ptr pCmdQ(new MockCommandQueue(&mockContext, pClDevice, props)); MockEvent ev(pCmdQ.get(), CL_COMMAND_MAP_IMAGE, CompletionStamp::levelNotReady, CompletionStamp::levelNotReady); bool cpuProfiling = ev.isCPUProfilingPath() != 0; @@ -1433,7 +1433,7 @@ HWTEST_F(EventTest, givenNonQuickKmdSleepRequestWhenWaitIsCalledThenPassRequestT } HWTEST_F(InternalsEventTest, givenCommandWhenSubmitCalledThenUpdateFlushStamp) { - auto pCmdQ = std::unique_ptr(new CommandQueue(mockContext, pClDevice, 0)); + auto pCmdQ = std::unique_ptr(new MockCommandQueue(mockContext, pClDevice, 0)); MockEvent *event = new MockEvent(pCmdQ.get(), CL_COMMAND_MARKER, 0, 0); auto &csr = pDevice->getUltCommandStreamReceiver(); csr.flushStamp->setStamp(5); @@ -1447,7 +1447,7 @@ HWTEST_F(InternalsEventTest, givenCommandWhenSubmitCalledThenUpdateFlushStamp) { } HWTEST_F(InternalsEventTest, givenAbortedCommandWhenSubmitCalledThenDontUpdateFlushStamp) { - auto pCmdQ = std::unique_ptr(new CommandQueue(mockContext, pClDevice, 0)); + auto pCmdQ = std::unique_ptr(new MockCommandQueue(mockContext, pClDevice, 0)); MockEvent *event = new MockEvent(pCmdQ.get(), CL_COMMAND_MARKER, 0, 0); auto &csr = pDevice->getUltCommandStreamReceiver(); csr.flushStamp->setStamp(5); diff --git a/opencl/test/unit_test/event/event_tracker_tests.cpp b/opencl/test/unit_test/event/event_tracker_tests.cpp index d816176898..f446629d4a 100644 --- a/opencl/test/unit_test/event/event_tracker_tests.cpp +++ b/opencl/test/unit_test/event/event_tracker_tests.cpp @@ -10,6 +10,7 @@ #include "opencl/source/event/event.h" #include "opencl/source/event/event_tracker.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "event_fixture.h" @@ -78,7 +79,7 @@ TEST(EventsTracker, whenCallLabelFunctionWhenEventIsNotInMapThenGetStringWithout } TEST(EventsTracker, whenCallLabelFunctionThenGetStringWithProperCmdqId) { - CommandQueue cmdq; + MockCommandQueue cmdq; std::string expect = "cq" + std::to_string(reinterpret_cast(&cmdq)); @@ -86,7 +87,7 @@ TEST(EventsTracker, whenCallLabelFunctionThenGetStringWithProperCmdqId) { } TEST(EventsTracker, givenNullptrCmdqThenNotDumping) { - CommandQueue *cmdq_ptr = nullptr; + MockCommandQueue *cmdq_ptr = nullptr; std::stringstream stream; std::set dumped; @@ -97,7 +98,7 @@ TEST(EventsTracker, givenNullptrCmdqThenNotDumping) { } TEST(EventsTracker, givenAlreadyDumpedCmdqThenNotDumping) { - CommandQueue cmdq; + MockCommandQueue cmdq; std::stringstream stream; std::set dumped; @@ -109,7 +110,7 @@ TEST(EventsTracker, givenAlreadyDumpedCmdqThenNotDumping) { } TEST(EventsTracker, givenCmqdWithTaskCountAndLevelNotReadyThenDumpingCmdqWithNotReadyLabels) { - CommandQueue cmdq; + MockCommandQueue cmdq; cmdq.taskCount = CompletionStamp::levelNotReady; cmdq.taskLevel = CompletionStamp::levelNotReady; @@ -125,7 +126,7 @@ TEST(EventsTracker, givenCmqdWithTaskCountAndLevelNotReadyThenDumpingCmdqWithNot } TEST(EventsTracker, whenCallDumpQueueThenDumpingCmdqWithProperCountTaskAndLevelValues) { - CommandQueue cmdq; + MockCommandQueue cmdq; cmdq.taskCount = 3; cmdq.taskLevel = 1; @@ -228,7 +229,7 @@ TEST(EventsTracker, givenEventAndUserEventThenDumpingNodeWithProperLabels) { TEST(EventsTracker, givenCmdqAndItsVirtualEventThenDumpingWithProperLabels) { MockContext ctx; - CommandQueue cmdq; + MockCommandQueue cmdq; VirtualEvent vEvent(&cmdq, &ctx); vEvent.setCurrentCmdQVirtualEvent(true); vEvent.updateTaskCount(1); @@ -391,7 +392,7 @@ TEST(EventsTracker, givenAlreadyDumpedEventThenNotDumpingGraph) { TEST(EventsTracker, givenCmdqAndItsVirtualEventThenDumpingProperGraph) { MockContext ctx; - CommandQueue cmdq; + MockCommandQueue cmdq; VirtualEvent vEvent(&cmdq, &ctx); vEvent.setCurrentCmdQVirtualEvent(true); vEvent.updateTaskCount(1); diff --git a/opencl/test/unit_test/helpers/base_object_tests.cpp b/opencl/test/unit_test/helpers/base_object_tests.cpp index b1cdd5b8da..33f9804cbb 100644 --- a/opencl/test/unit_test/helpers/base_object_tests.cpp +++ b/opencl/test/unit_test/helpers/base_object_tests.cpp @@ -21,6 +21,7 @@ #include "opencl/test/unit_test/fixtures/device_fixture.h" #include "opencl/test/unit_test/fixtures/image_fixture.h" #include "opencl/test/unit_test/mocks/mock_buffer.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "opencl/test/unit_test/mocks/mock_platform.h" #include "gmock/gmock.h" @@ -99,7 +100,7 @@ typedef ::testing::Types< //Kernel, //Sampler //others... - CommandQueue, + MockCommandQueue, DeviceQueue> BaseObjectTypes; @@ -109,7 +110,7 @@ typedef ::testing::Types< Context, Program, Buffer, - CommandQueue, + MockCommandQueue, DeviceQueue> BaseObjectTypesForCastInvalidMagicTest; diff --git a/opencl/test/unit_test/helpers/base_object_tests_mt.cpp b/opencl/test/unit_test/helpers/base_object_tests_mt.cpp index 80ddc27087..e72c55b7a7 100644 --- a/opencl/test/unit_test/helpers/base_object_tests_mt.cpp +++ b/opencl/test/unit_test/helpers/base_object_tests_mt.cpp @@ -8,13 +8,14 @@ #include "opencl/source/accelerators/intel_accelerator.h" #include "opencl/source/command_queue/command_queue.h" #include "opencl/source/platform/platform.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "gtest/gtest.h" namespace NEO { TEST(BaseObjectTestsMt, givenObjectOwnershipForEachThreadWhenIncrementingNonAtomicValueThenNoDataRacesAreExpected) { - CommandQueue *object = new CommandQueue; + MockCommandQueue *object = new MockCommandQueue; object->takeOwnership(); uint32_t counter = 0; const uint32_t loopCount = 50; diff --git a/opencl/test/unit_test/helpers/task_information_tests.cpp b/opencl/test/unit_test/helpers/task_information_tests.cpp index 6ccf2c4891..566681bdfd 100644 --- a/opencl/test/unit_test/helpers/task_information_tests.cpp +++ b/opencl/test/unit_test/helpers/task_information_tests.cpp @@ -98,7 +98,7 @@ TEST(CommandTest, givenWaitlistRequestWhenCommandComputeKernelIsCreatedThenMakeL }; auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); - CommandQueue cmdQ(nullptr, device.get(), nullptr); + MockCommandQueue cmdQ(nullptr, device.get(), nullptr); MockKernelWithInternals kernel(*device); IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr; @@ -130,7 +130,7 @@ TEST(CommandTest, givenWaitlistRequestWhenCommandComputeKernelIsCreatedThenMakeL TEST(KernelOperationDestruction, givenKernelOperationWhenItIsDestructedThenAllAllocationsAreStoredInInternalStorageForReuse) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); - CommandQueue cmdQ(nullptr, device.get(), nullptr); + MockCommandQueue cmdQ(nullptr, device.get(), nullptr); InternalAllocationStorage &allocationStorage = *device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(); auto &allocationsForReuse = allocationStorage.getAllocationsForReuse(); diff --git a/opencl/test/unit_test/mem_obj/pipe_tests.cpp b/opencl/test/unit_test/mem_obj/pipe_tests.cpp index 568b3628d2..a55f67f1d4 100644 --- a/opencl/test/unit_test/mem_obj/pipe_tests.cpp +++ b/opencl/test/unit_test/mem_obj/pipe_tests.cpp @@ -10,6 +10,7 @@ #include "opencl/test/unit_test/fixtures/device_fixture.h" #include "opencl/test/unit_test/fixtures/memory_management_fixture.h" #include "opencl/test/unit_test/fixtures/multi_root_device_fixture.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "opencl/test/unit_test/mocks/mock_context.h" #include "test.h" @@ -90,7 +91,7 @@ TEST_F(PipeTest, givenPipeWhenEnqueueWriteForUnmapIsCalledThenReturnError) { ASSERT_NE(nullptr, pipe); EXPECT_EQ(CL_SUCCESS, errCode); - CommandQueue cmdQ; + MockCommandQueue cmdQ; errCode = clEnqueueUnmapMemObject(&cmdQ, pipe.get(), nullptr, 0, nullptr, nullptr); EXPECT_EQ(CL_INVALID_MEM_OBJECT, errCode); } @@ -126,4 +127,4 @@ TEST_F(MultiRootDeviceTests, pipeGraphicsAllocationHasCorrectRootDeviceIndex) { auto graphicsAllocation = pipe->getGraphicsAllocation(); ASSERT_NE(nullptr, graphicsAllocation); EXPECT_EQ(expectedRootDeviceIndex, graphicsAllocation->getRootDeviceIndex()); -} \ No newline at end of file +} diff --git a/opencl/test/unit_test/memory_manager/cpu_page_fault_manager_memory_sync_tests.cpp b/opencl/test/unit_test/memory_manager/cpu_page_fault_manager_memory_sync_tests.cpp index 7e1bf093ee..69e84115f5 100644 --- a/opencl/test/unit_test/memory_manager/cpu_page_fault_manager_memory_sync_tests.cpp +++ b/opencl/test/unit_test/memory_manager/cpu_page_fault_manager_memory_sync_tests.cpp @@ -8,12 +8,13 @@ #include "shared/test/unit_test/page_fault_manager/cpu_page_fault_manager_tests_fixture.h" #include "opencl/source/command_queue/command_queue.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "gtest/gtest.h" using namespace NEO; -struct CommandQueueMock : public CommandQueue { +struct CommandQueueMock : public MockCommandQueue { cl_int enqueueSVMUnmap(void *svmPtr, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event, bool externalAppCall) override { diff --git a/opencl/test/unit_test/mocks/mock_command_queue.h b/opencl/test/unit_test/mocks/mock_command_queue.h index 221f1ce395..e54e9e99fd 100644 --- a/opencl/test/unit_test/mocks/mock_command_queue.h +++ b/opencl/test/unit_test/mocks/mock_command_queue.h @@ -64,6 +64,109 @@ class MockCommandQueue : public CommandQueue { return CommandQueue::waitUntilComplete(taskCountToWait, flushStampToWait, useQuickKmdSleep); } + cl_int enqueueCopyImage(Image *srcImage, Image *dstImage, const size_t srcOrigin[3], + const size_t dstOrigin[3], const size_t region[3], + cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueFillImage(Image *image, const void *fillColor, + const size_t *origin, const size_t *region, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueFillBuffer(Buffer *buffer, const void *pattern, + size_t patternSize, size_t offset, + size_t size, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueKernel(cl_kernel kernel, cl_uint workDim, const size_t *globalWorkOffset, + const size_t *globalWorkSize, const size_t *localWorkSize, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueBarrierWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueSVMMap(cl_bool blockingMap, cl_map_flags mapFlags, void *svmPtr, size_t size, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event, bool externalAppCall) override { return CL_SUCCESS; } + + cl_int enqueueSVMUnmap(void *svmPtr, cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event, bool externalAppCall) override { return CL_SUCCESS; } + + cl_int enqueueSVMFree(cl_uint numSvmPointers, void *svmPointers[], + void(CL_CALLBACK *pfnFreeFunc)(cl_command_queue queue, + cl_uint numSvmPointers, + void *svmPointers[], + void *userData), + void *userData, cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueSVMMemcpy(cl_bool blockingCopy, void *dstPtr, const void *srcPtr, size_t size, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + 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 { return CL_SUCCESS; } + + cl_int enqueueMarkerWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueMigrateMemObjects(cl_uint numMemObjects, const cl_mem *memObjects, cl_mem_migration_flags flags, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueSVMMigrateMem(cl_uint numSvmPointers, const void **svmPointers, const size_t *sizes, const cl_mem_migration_flags flags, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueCopyBuffer(Buffer *srcBuffer, Buffer *dstBuffer, size_t srcOffset, size_t dstOffset, + size_t size, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueReadBuffer(Buffer *buffer, cl_bool blockingRead, size_t offset, size_t size, void *ptr, + GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueReadImage(Image *srcImage, cl_bool blockingRead, const size_t *origin, const size_t *region, + size_t rowPitch, size_t slicePitch, void *ptr, + GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueWriteImage(Image *dstImage, cl_bool blockingWrite, const size_t *origin, const size_t *region, + size_t inputRowPitch, size_t inputSlicePitch, const void *ptr, GraphicsAllocation *mapAllocation, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin, + const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch, + size_t dstSlicePitch, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueWriteBufferRect(Buffer *buffer, cl_bool blockingWrite, const size_t *bufferOrigin, + const size_t *hostOrigin, const size_t *region, size_t bufferRowPitch, + size_t bufferSlicePitch, size_t hostRowPitch, size_t hostSlicePitch, + const void *ptr, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueReadBufferRect(Buffer *buffer, cl_bool blockingRead, const size_t *bufferOrigin, + const size_t *hostOrigin, const size_t *region, size_t bufferRowPitch, + size_t bufferSlicePitch, size_t hostRowPitch, size_t hostSlicePitch, + void *ptr, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueCopyBufferToImage(Buffer *srcBuffer, Image *dstImage, size_t srcOffset, + const size_t *dstOrigin, const size_t *region, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueCopyImageToBuffer(Image *srcImage, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *region, + size_t dstOffset, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int enqueueResourceBarrier(BarrierCommand *resourceBarrier, cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event) override { return CL_SUCCESS; } + + cl_int finish() override { return CL_SUCCESS; } + + cl_int enqueueInitDispatchGlobals(DispatchGlobalsArgs *dispatchGlobalsArgs, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + + cl_int flush() override { return CL_SUCCESS; } + bool releaseIndirectHeapCalled = false; cl_int writeBufferRetValue = CL_SUCCESS; diff --git a/opencl/test/unit_test/sharings/va/va_base_object_tests.cpp b/opencl/test/unit_test/sharings/va/va_base_object_tests.cpp index 57b85278ff..fa16c6ed31 100644 --- a/opencl/test/unit_test/sharings/va/va_base_object_tests.cpp +++ b/opencl/test/unit_test/sharings/va/va_base_object_tests.cpp @@ -10,6 +10,7 @@ #include "opencl/source/device_queue/device_queue.h" #include "opencl/source/helpers/base_object.h" #include "opencl/source/sharings/sharing_factory.h" +#include "opencl/test/unit_test/mocks/mock_command_queue.h" #include "opencl/test/unit_test/mocks/mock_platform.h" #include "gtest/gtest.h" @@ -33,7 +34,7 @@ typedef ::testing::Types< //Kernel, //Sampler //others... - CommandQueue, + MockCommandQueue, DeviceQueue> BaseObjectTypes;