@@ -716,14 +716,14 @@ HWTEST_F(EnqueueHandlerTest, givenKernelUsingSyncBufferWhenEnqueuingKernelThenSs
716
716
}
717
717
718
718
struct EnqueueHandlerTestBasic : public ::testing::Test {
719
- template <typename FamilyType>
720
- std::unique_ptr<MockCommandQueueHw<FamilyType> > setupFixtureAndCreateMockCommandQueue () {
719
+ template <typename MockCmdQueueType, typename FamilyType>
720
+ std::unique_ptr<MockCmdQueueType > setupFixtureAndCreateMockCommandQueue () {
721
721
auto executionEnvironment = platform ()->peekExecutionEnvironment ();
722
722
723
723
device = std::make_unique<MockClDevice>(MockDevice::createWithExecutionEnvironment<MockDevice>(nullptr , executionEnvironment, 0u ));
724
724
context = std::make_unique<MockContext>(device.get ());
725
725
726
- auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType> >(context.get (), device.get (), nullptr );
726
+ auto mockCmdQ = std::make_unique<MockCmdQueueType >(context.get (), device.get (), nullptr );
727
727
728
728
auto &ultCsr = static_cast <UltCommandStreamReceiver<FamilyType> &>(mockCmdQ->getGpgpuCommandStreamReceiver ());
729
729
ultCsr.taskCount = initialTaskCount;
@@ -741,7 +741,7 @@ struct EnqueueHandlerTestBasic : public ::testing::Test {
741
741
};
742
742
743
743
HWTEST_F (EnqueueHandlerTestBasic, givenEnqueueHandlerWhenCommandIsBlokingThenCompletionStampTaskCountIsPassedToWaitForTaskCountAndCleanAllocationListAsRequiredTaskCount) {
744
- auto mockCmdQ = setupFixtureAndCreateMockCommandQueue<FamilyType>();
744
+ auto mockCmdQ = setupFixtureAndCreateMockCommandQueue<MockCommandQueueHw<FamilyType>, FamilyType>();
745
745
MockKernelWithInternals kernelInternals (*device, context.get ());
746
746
Kernel *kernel = kernelInternals.mockKernel ;
747
747
MockMultiDispatchInfo multiDispatchInfo (device.get (), kernel);
@@ -757,7 +757,7 @@ HWTEST_F(EnqueueHandlerTestBasic, givenEnqueueHandlerWhenCommandIsBlokingThenCom
757
757
}
758
758
759
759
HWTEST_F (EnqueueHandlerTestBasic, givenBlockedEnqueueHandlerWhenCommandIsBlokingThenCompletionStampTaskCountIsPassedToWaitForTaskCountAndCleanAllocationListAsRequiredTaskCount) {
760
- auto mockCmdQ = setupFixtureAndCreateMockCommandQueue<FamilyType>();
760
+ auto mockCmdQ = setupFixtureAndCreateMockCommandQueue<MockCommandQueueHw<FamilyType>, FamilyType>();
761
761
762
762
MockKernelWithInternals kernelInternals (*device, context.get ());
763
763
Kernel *kernel = kernelInternals.mockKernel ;
@@ -783,3 +783,93 @@ HWTEST_F(EnqueueHandlerTestBasic, givenBlockedEnqueueHandlerWhenCommandIsBloking
783
783
784
784
t0.join ();
785
785
}
786
+ template <typename FamilyType>
787
+ class MockCommandQueueFailEnqueue : public MockCommandQueueHw <FamilyType> {
788
+ public:
789
+ MockCommandQueueFailEnqueue (Context *context,
790
+ ClDevice *device,
791
+ cl_queue_properties *properties) : MockCommandQueueHw<FamilyType>(context, device, properties) {
792
+ mockTagAllocator = std::make_unique<MockTagAllocator<>>(0 , device->getDevice ().getMemoryManager ());
793
+ this ->timestampPacketContainer = std::make_unique<TimestampPacketContainer>();
794
+ this ->deferredTimestampPackets = std::make_unique<TimestampPacketContainer>();
795
+ }
796
+ CompletionStamp enqueueNonBlocked (Surface **surfacesForResidency,
797
+ size_t surfaceCount,
798
+ LinearStream &commandStream,
799
+ size_t commandStreamStart,
800
+ bool &blocking,
801
+ bool clearDependenciesForSubCapture,
802
+ const MultiDispatchInfo &multiDispatchInfo,
803
+ const EnqueueProperties &enqueueProperties,
804
+ TimestampPacketDependencies ×tampPacketDependencies,
805
+ EventsRequest &eventsRequest,
806
+ EventBuilder &eventBuilder,
807
+ TaskCountType taskLevel,
808
+ PrintfHandler *printfHandler,
809
+ bool relaxedOrderingEnabled,
810
+ uint32_t commandType) override {
811
+ this ->timestampPacketContainer ->add (mockTagAllocator->getTag ());
812
+ CompletionStamp stamp{};
813
+ stamp.taskCount = taskCountToReturn;
814
+ return stamp;
815
+ }
816
+ TaskCountType taskCountToReturn = 0 ;
817
+ std::unique_ptr<MockTagAllocator<>> mockTagAllocator;
818
+ };
819
+ HWTEST_F (EnqueueHandlerTestBasic, givenEnqueueHandlerWhenEnqueueFailedThenTimestampPacketContainerIsEmpty) {
820
+ auto mockCmdQ = setupFixtureAndCreateMockCommandQueue<MockCommandQueueFailEnqueue<FamilyType>, FamilyType>();
821
+
822
+ MockKernelWithInternals kernelInternals (*device, context.get ());
823
+ Kernel *kernel = kernelInternals.mockKernel ;
824
+ MockMultiDispatchInfo multiDispatchInfo (device.get (), kernel);
825
+ mockCmdQ->taskCountToReturn = CompletionStamp::gpuHang;
826
+ mockCmdQ->template enqueueHandler <CL_COMMAND_BARRIER>(nullptr ,
827
+ 0 ,
828
+ true ,
829
+ multiDispatchInfo,
830
+ 0 ,
831
+ nullptr ,
832
+ nullptr );
833
+ EXPECT_TRUE (mockCmdQ->timestampPacketContainer ->peekNodes ().empty ());
834
+ TimestampPacketContainer release;
835
+ mockCmdQ->deferredTimestampPackets ->swapNodes (release);
836
+ }
837
+
838
+ HWTEST_F (EnqueueHandlerTestBasic, givenEnqueueHandlerWhenEnqueueSucceedsThenTimestampPacketContainerIsNotEmpty) {
839
+ auto mockCmdQ = setupFixtureAndCreateMockCommandQueue<MockCommandQueueFailEnqueue<FamilyType>, FamilyType>();
840
+
841
+ MockKernelWithInternals kernelInternals (*device, context.get ());
842
+ Kernel *kernel = kernelInternals.mockKernel ;
843
+ MockMultiDispatchInfo multiDispatchInfo (device.get (), kernel);
844
+ mockCmdQ->taskCountToReturn = 100 ;
845
+ mockCmdQ->template enqueueHandler <CL_COMMAND_BARRIER>(nullptr ,
846
+ 0 ,
847
+ true ,
848
+ multiDispatchInfo,
849
+ 0 ,
850
+ nullptr ,
851
+ nullptr );
852
+ EXPECT_FALSE (mockCmdQ->timestampPacketContainer ->peekNodes ().empty ());
853
+ TimestampPacketContainer release;
854
+ mockCmdQ->timestampPacketContainer ->swapNodes (release);
855
+ }
856
+
857
+ HWTEST_F (EnqueueHandlerTestBasic, givenEnqueueHandlerWhenEnqueueFailedButThereIsNoDeferredContainerThenTimestampPacketContainerIsNotEmpty) {
858
+ auto mockCmdQ = setupFixtureAndCreateMockCommandQueue<MockCommandQueueFailEnqueue<FamilyType>, FamilyType>();
859
+
860
+ MockKernelWithInternals kernelInternals (*device, context.get ());
861
+ Kernel *kernel = kernelInternals.mockKernel ;
862
+ MockMultiDispatchInfo multiDispatchInfo (device.get (), kernel);
863
+ mockCmdQ->taskCountToReturn = CompletionStamp::gpuHang;
864
+ mockCmdQ->deferredTimestampPackets .reset ();
865
+ mockCmdQ->template enqueueHandler <CL_COMMAND_BARRIER>(nullptr ,
866
+ 0 ,
867
+ true ,
868
+ multiDispatchInfo,
869
+ 0 ,
870
+ nullptr ,
871
+ nullptr );
872
+ EXPECT_FALSE (mockCmdQ->timestampPacketContainer ->peekNodes ().empty ());
873
+ TimestampPacketContainer release;
874
+ mockCmdQ->timestampPacketContainer ->swapNodes (release);
875
+ }
0 commit comments