use release for cl-objects instead of delete

- fix for data race in events
- modification of the addition child event

Change-Id: I6ea3a413f13f13a91d37d20d8b9fad37d0ffafb9
This commit is contained in:
Kamil Diedrich 2019-02-04 13:08:47 +01:00 committed by sys_ocldev
parent 3820a5e8e5
commit e1eab521e7
29 changed files with 329 additions and 189 deletions

View File

@ -76,7 +76,6 @@ CommandQueue::CommandQueue(Context *context, Device *deviceId, const cl_queue_pr
CommandQueue::~CommandQueue() {
if (virtualEvent) {
UNRECOVERABLE_IF(this->virtualEvent->getCommandQueue() != this && this->virtualEvent->getCommandQueue() != nullptr);
virtualEvent->setCurrentCmdQVirtualEvent(false);
virtualEvent->decRefInternal();
}
@ -519,7 +518,6 @@ void CommandQueue::enqueueBlockedMapUnmapOperation(const cl_event *eventWaitList
eventBuilder->finalize();
if (this->virtualEvent) {
this->virtualEvent->setCurrentCmdQVirtualEvent(false);
this->virtualEvent->decRefInternal();
}
this->virtualEvent = eventBuilder->getEvent();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -10,6 +10,7 @@
#include "runtime/helpers/engine_control.h"
#include "runtime/helpers/task_information.h"
#include "runtime/helpers/dispatch_info.h"
#include "runtime/event/user_event.h"
#include "instrumentation.h"
#include <atomic>
#include <cstdint>
@ -341,6 +342,13 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
MOCKABLE_VIRTUAL void releaseIndirectHeap(IndirectHeap::Type heapType);
void releaseVirtualEvent() {
if (this->virtualEvent != nullptr) {
this->virtualEvent->decRefInternal();
this->virtualEvent = nullptr;
}
}
cl_command_queue_properties getCommandQueueProperties() const {
return commandQueueProperties;
}

View File

@ -659,7 +659,6 @@ void CommandQueueHw<GfxFamily>::enqueueBlocked(
eventBuilder = &internalEventBuilder;
DBG_LOG(EventsDebugEnable, "enqueueBlocked", "new virtualEvent", eventBuilder->getEvent());
}
eventBuilder->getEvent()->setCurrentCmdQVirtualEvent(true);
//update queue taskCount
taskCount = eventBuilder->getEvent()->getCompletionStamp();
@ -720,7 +719,6 @@ void CommandQueueHw<GfxFamily>::enqueueBlocked(
eventBuilder->finalize();
if (this->virtualEvent) {
this->virtualEvent->setCurrentCmdQVirtualEvent(false);
this->virtualEvent->decRefInternal();
}

View File

@ -416,11 +416,6 @@ void Event::unblockEventsBlockedByThis(int32_t transitionStatus) {
childEvent->unblockEventBy(*this, taskLevelToPropagate, transitionStatus);
if (childEvent->getCommandQueue() && childEvent->isCurrentCmdQVirtualEvent()) {
// Check virtual event state and delete it if possible.
childEvent->getCommandQueue()->isQueueBlocked();
}
childEvent->decRefInternal();
auto next = childEventRef->next;
delete childEventRef;

View File

@ -203,6 +203,10 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
}
}
bool peekIsCmdSubmitted() {
return submittedCmd != nullptr;
}
//commands blocked by user event depencies
bool isReadyForSubmission();
@ -217,6 +221,10 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
return (CL_COMMAND_USER == cmdType);
}
bool isEventWithoutCommand() {
return eventWithoutCommand;
}
Context *getContext() {
return ctx;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -53,7 +53,8 @@ void EventBuilder::finalize() {
//do not add as child if:
//parent has no parents and is not blocked
if (!(parent->peekIsBlocked() == false && parent->taskLevel != Event::eventNotReady)) {
if (!(parent->peekIsBlocked() == false && parent->taskLevel != Event::eventNotReady) ||
(!parent->isEventWithoutCommand() && !parent->peekIsCmdSubmitted())) {
parent->addChild(*this->event);
}
}

View File

@ -11,6 +11,16 @@
#include "runtime/helpers/get_info.h"
namespace OCLRT {
inline void releaseVirtualEvent(CommandQueue &commandQueue) {
if (commandQueue.getRefApiCount() == 1) {
commandQueue.releaseVirtualEvent();
}
}
inline void releaseVirtualEvent(DeviceQueue &commandQueue) {
}
template <typename QueueType>
void retainQueue(cl_command_queue commandQueue, cl_int &retVal) {
using BaseType = typename QueueType::BaseType;
@ -26,6 +36,7 @@ void releaseQueue(cl_command_queue commandQueue, cl_int &retVal) {
using BaseType = typename QueueType::BaseType;
auto queue = castToObject<QueueType>(static_cast<BaseType *>(commandQueue));
if (queue) {
releaseVirtualEvent(*queue);
queue->release();
retVal = CL_SUCCESS;
}

View File

@ -11,6 +11,7 @@
#include "unit_tests/fixtures/buffer_fixture.h"
#include "unit_tests/fixtures/context_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/utilities/base_object_utils.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/unit_test_helper.h"
#include "unit_tests/mocks/mock_buffer.h"
@ -361,6 +362,7 @@ HWTEST_F(CommandQueueHwTest, GivenNotCompleteUserEventPassedToEnqueueWhenEventIs
mockCSR->getMemoryManager()->freeGraphicsMemory(privateSurface);
mockCSR->getMemoryManager()->freeGraphicsMemory(printfSurface);
mockCSR->getMemoryManager()->freeGraphicsMemory(constantSurface);
pCmdQ->isQueueBlocked();
}
typedef CommandQueueHwTest BlockedCommandQueueTest;
@ -387,6 +389,8 @@ HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWhenBlockedCommandIsBeingSubm
EXPECT_EQ(0u, ioh.getUsed());
EXPECT_EQ(0u, dsh.getUsed());
EXPECT_EQ(defaultSshUse, ssh.getUsed());
pCmdQ->isQueueBlocked();
}
HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWithUsedHeapsWhenBlockedCommandIsBeingSubmittedThenQueueHeapsAreNotUsed) {
@ -417,6 +421,8 @@ HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWithUsedHeapsWhenBlockedComma
EXPECT_EQ(spaceToUse, ioh.getUsed());
EXPECT_EQ(spaceToUse, dsh.getUsed());
EXPECT_EQ(sshSpaceUse, ssh.getUsed());
pCmdQ->isQueueBlocked();
}
HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWhichHasSomeUnusedHeapsWhenBlockedCommandIsBeingSubmittedThenThoseHeapsAreBeingUsed) {
@ -443,6 +449,8 @@ HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWhichHasSomeUnusedHeapsWhenBl
EXPECT_EQ(iohBase, ioh.getCpuBase());
EXPECT_EQ(dshBase, dsh.getCpuBase());
EXPECT_EQ(sshBase, ssh.getCpuBase());
pCmdQ->isQueueBlocked();
}
HWTEST_F(BlockedCommandQueueTest, givenEnqueueBlockedByUserEventWhenItIsEnqueuedThenKernelReferenceCountIsIncreased) {
@ -459,6 +467,7 @@ HWTEST_F(BlockedCommandQueueTest, givenEnqueueBlockedByUserEventWhenItIsEnqueued
pCmdQ->enqueueKernel(mockKernel, 1, &offset, &size, &size, 1, &blockedEvent, nullptr);
EXPECT_EQ(currentRefCount + 1, mockKernel->getRefInternalCount());
userEvent.setStatus(CL_COMPLETE);
pCmdQ->isQueueBlocked();
EXPECT_EQ(currentRefCount, mockKernel->getRefInternalCount());
}
@ -490,7 +499,7 @@ HWTEST_F(CommandQueueHwRefCountTest, givenBlockedCmdQWhenNewBlockedEnqueueReplac
userEvent.setStatus(CL_COMPLETE);
// UserEvent is set to complete and event tree is unblocked, queue has only 1 refference to itself after this operation
EXPECT_EQ(1, mockCmdQ->getRefInternalCount());
EXPECT_EQ(2, mockCmdQ->getRefInternalCount());
//this call will release the queue
releaseQueue<CommandQueue>(mockCmdQ, retVal);
@ -530,12 +539,13 @@ HWTEST_F(CommandQueueHwRefCountTest, givenBlockedCmdQWithOutputEventAsVirtualEve
// unblocking deletes 2 virtualEvents
userEvent.setStatus(CL_COMPLETE);
EXPECT_EQ(2, mockCmdQ->getRefInternalCount());
EXPECT_EQ(3, mockCmdQ->getRefInternalCount());
auto pEventOut = castToObject<Event>(eventOut);
pEventOut->release();
// releasing output event decrements refCount
EXPECT_EQ(1, mockCmdQ->getRefInternalCount());
EXPECT_EQ(2, mockCmdQ->getRefInternalCount());
mockCmdQ->isQueueBlocked();
releaseQueue<CommandQueue>(mockCmdQ, retVal);
}
@ -575,13 +585,16 @@ HWTEST_F(CommandQueueHwRefCountTest, givenSeriesOfBlockedEnqueuesWhenEveryEventI
userEvent->setStatus(CL_COMPLETE);
userEvent->release();
// releasing UserEvent doesn't change the refCount
EXPECT_EQ(2, mockCmdQ->getRefInternalCount());
EXPECT_EQ(3, mockCmdQ->getRefInternalCount());
auto pEventOut = castToObject<Event>(eventOut);
pEventOut->release();
// releasing output event decrements refCount
EXPECT_EQ(2, mockCmdQ->getRefInternalCount());
mockCmdQ->isQueueBlocked();
EXPECT_EQ(1, mockCmdQ->getRefInternalCount());
releaseQueue<CommandQueue>(mockCmdQ, retVal);
@ -622,7 +635,7 @@ HWTEST_F(CommandQueueHwRefCountTest, givenSeriesOfBlockedEnqueuesWhenCmdQIsRelea
userEvent->release();
// releasing UserEvent doesn't change the queue refCount
EXPECT_EQ(2, mockCmdQ->getRefInternalCount());
EXPECT_EQ(3, mockCmdQ->getRefInternalCount());
releaseQueue<CommandQueue>(mockCmdQ, retVal);
@ -963,6 +976,7 @@ HWTEST_F(CommandQueueHwTest, givenWalkerSplitEnqueueNDRangeWhenBlockedThenKernel
EXPECT_EQ(1u, mockKernel->getResidencyCalls);
userEvent.setStatus(CL_COMPLETE);
pCmdQ->isQueueBlocked();
}
HWTEST_F(CommandQueueHwTest, givenKernelSplitEnqueueReadBufferWhenBlockedThenEnqueueSurfacesMakeResidentIsCalledOnce) {
@ -972,7 +986,7 @@ HWTEST_F(CommandQueueHwTest, givenKernelSplitEnqueueReadBufferWhenBlockedThenEnq
csr.timestampPacketWriteEnabled = false;
BufferDefaults::context = context;
std::unique_ptr<Buffer> buffer(BufferHelper<>::create());
auto buffer = clUniquePtr(BufferHelper<>::create());
GraphicsAllocation *bufferAllocation = buffer->getGraphicsAllocation();
char array[3 * MemoryConstants::cacheLineSize];
char *ptr = &array[MemoryConstants::cacheLineSize];
@ -995,4 +1009,6 @@ HWTEST_F(CommandQueueHwTest, givenKernelSplitEnqueueReadBufferWhenBlockedThenEnq
}
EXPECT_EQ(expected, it->second);
}
pCmdQ->isQueueBlocked();
}

View File

@ -200,54 +200,11 @@ HWTEST_F(EnqueueHandlerTest, enqueueBlockedSetsVirtualEventAsCurrentCmdQVirtualE
ASSERT_NE(nullptr, mockCmdQ->virtualEvent);
EXPECT_TRUE(mockCmdQ->virtualEvent->isCurrentCmdQVirtualEvent());
mockCmdQ->virtualEvent->setStatus(CL_COMPLETE);
mockCmdQ->isQueueBlocked();
mockCmdQ->release();
}
HWTEST_F(EnqueueHandlerTest, enqueueBlockedUnsetsCurrentCmdQVirtualEventForPreviousVirtualEvent) {
UserEvent userEvent;
cl_event clUserEvent = &userEvent;
MockKernelWithInternals kernelInternals(*pDevice, context);
Kernel *kernel = kernelInternals.mockKernel;
MockMultiDispatchInfo multiDispatchInfo(kernel);
auto mockCmdQ = new MockCommandQueueHw<FamilyType>(context, pDevice, 0);
// put queue into initial blocked state with userEvent
bool blocking = false;
mockCmdQ->template enqueueHandler<CL_COMMAND_NDRANGE_KERNEL>(nullptr,
0,
blocking,
multiDispatchInfo,
1,
&clUserEvent,
nullptr);
ASSERT_NE(nullptr, mockCmdQ->virtualEvent);
Event *previousVirtualEvent = mockCmdQ->virtualEvent;
mockCmdQ->template enqueueHandler<CL_COMMAND_NDRANGE_KERNEL>(nullptr,
0,
blocking,
multiDispatchInfo,
0,
nullptr,
nullptr);
EXPECT_FALSE(previousVirtualEvent->isCurrentCmdQVirtualEvent());
EXPECT_TRUE(mockCmdQ->virtualEvent->isCurrentCmdQVirtualEvent());
mockCmdQ->release();
}
HWTEST_F(EnqueueHandlerTest, enqueueWithOutputEventRegistersEvent) {
MockKernelWithInternals kernelInternals(*pDevice, context);
Kernel *kernel = kernelInternals.mockKernel;

View File

@ -643,6 +643,7 @@ HWTEST_P(EnqueueKernelPrintfTest, GivenKernelWithPrintfBlockedByEventWhenEventUn
std::string output = testing::internal::GetCapturedStdout();
EXPECT_STREQ("test", output.c_str());
pCmdQ->releaseVirtualEvent();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -18,6 +18,7 @@
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/utilities/base_object_utils.h"
#include "test.h"
using namespace OCLRT;
@ -99,6 +100,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMapBlockedOnEvent_Success) {
nullptr // cl_event *event
);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EnqueueSvmTest, enqueueSVMUnmap_InvalidValue) {
@ -132,6 +134,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMUnmapBlockedOnEvent_Success) {
nullptr // cl_event *event
);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EnqueueSvmTest, enqueueSVMFreeWithoutCallback_Success) {
@ -232,6 +235,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMFreeBlockedOnEvent_Success) {
nullptr // cl_event *event
);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_InvalidValueDstPtrIsNull) {
@ -315,6 +319,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlockedOnEvent_Success) {
);
EXPECT_EQ(CL_SUCCESS, retVal);
context->getSVMAllocsManager()->freeSVMAlloc(pSrcSVM);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyCoherent_Success) {
@ -349,6 +354,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpyCoherentBlockedOnEvent_Success) {
);
EXPECT_EQ(CL_SUCCESS, retVal);
context->getSVMAllocsManager()->freeSVMAlloc(pSrcSVM);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EnqueueSvmTest, enqueueSVMMemFill_InvalidValue) {
@ -397,6 +403,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemFillBlockedOnEvent_Success) {
nullptr // cL_event *event
);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EnqueueSvmTest, enqueueSVMMemFillDoubleToReuseAllocation_Success) {
@ -480,10 +487,10 @@ TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSur
GraphicsAllocation *pSvmAlloc = context->getSVMAllocsManager()->getSVMAlloc(ptrSVM);
EXPECT_NE(nullptr, ptrSVM);
std::unique_ptr<Program> program(Program::create("FillBufferBytes", context, *pDevice, true, &retVal));
auto program = clUniquePtr(Program::create("FillBufferBytes", context, *pDevice, true, &retVal));
cl_device_id device = pDevice;
program->build(1, &device, nullptr, nullptr, nullptr, false);
std::unique_ptr<Kernel> kernel(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
auto kernel = clUniquePtr(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
std::vector<Surface *> allSurfaces;
kernel->getResidency(allSurfaces);
@ -513,6 +520,7 @@ TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSur
delete surface;
EXPECT_EQ(1u, kernel->getKernelSvmGfxAllocations().size());
pCmdQ->releaseVirtualEvent();
}
TEST_F(EnqueueSvmTest, concurentMapAccess) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -8,10 +8,14 @@
#include "runtime/event/event_builder.h"
#include "runtime/event/user_event.h"
#include "runtime/utilities/arrayref.h"
#include "runtime/helpers/task_information.h"
#include "runtime/memory_manager/internal_allocation_storage.h"
#include "unit_tests/mocks/mock_event.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_command_queue.h"
#include "unit_tests/mocks/mock_csr.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "gtest/gtest.h"
@ -64,6 +68,101 @@ TEST(EventBuilder, whenCreatingNewEventForwardsArgumentsToEventConstructor) {
finalizedEvent->release();
}
TEST(EventBuilder, givenVirtualEvenWhenVirtualEventWithCommandIsAddedThenFinilizeAddChild) {
using UniqueIH = std::unique_ptr<IndirectHeap>;
class MockCommandComputeKernel : public CommandComputeKernel {
public:
using CommandComputeKernel::eventsWaitlist;
MockCommandComputeKernel(CommandQueue &commandQueue, KernelOperation *kernelResources, std::vector<Surface *> &surfaces, Kernel *kernel)
: CommandComputeKernel(commandQueue, std::unique_ptr<KernelOperation>(kernelResources), surfaces, false, false, false, nullptr, PreemptionMode::Disabled, kernel, 0) {}
};
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
CommandQueue cmdQ(nullptr, device.get(), nullptr);
MockKernelWithInternals kernel(*device);
IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr;
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1);
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2);
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3);
auto cmdStream = new LinearStream(alignedMalloc(1, 1), 1);
std::vector<Surface *> surfaces;
auto kernelOperation = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(ih1), UniqueIH(ih2), UniqueIH(ih3),
*device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage());
std::unique_ptr<MockCommandComputeKernel> command = std::make_unique<MockCommandComputeKernel>(cmdQ, kernelOperation, surfaces, kernel);
VirtualEvent virtualEvent;
virtualEvent.setCommand(std::move(command));
EventBuilder eventBuilder;
EXPECT_EQ(nullptr, eventBuilder.getEvent());
constexpr int constrParam1 = 7;
constexpr float constrParam2 = 13.0f;
eventBuilder.create<SmallEventBuilderEventMock>(constrParam1, constrParam2);
Event *peekedEvent = eventBuilder.getEvent();
ASSERT_NE(nullptr, peekedEvent);
virtualEvent.taskLevel = CL_SUBMITTED;
eventBuilder.addParentEvent(&virtualEvent);
eventBuilder.finalize();
peekedEvent->release();
}
TEST(EventBuilder, givenVirtualEvenWhenVirtualEventWithSubmittedCommandIsAddedThenFinilizeNotChild) {
class MockVirtualEvent : public VirtualEvent {
public:
using VirtualEvent::eventWithoutCommand;
using VirtualEvent::submittedCmd;
};
using UniqueIH = std::unique_ptr<IndirectHeap>;
class MockCommandComputeKernel : public CommandComputeKernel {
public:
using CommandComputeKernel::eventsWaitlist;
MockCommandComputeKernel(CommandQueue &commandQueue, KernelOperation *kernelResources, std::vector<Surface *> &surfaces, Kernel *kernel)
: CommandComputeKernel(commandQueue, std::unique_ptr<KernelOperation>(kernelResources), surfaces, false, false, false, nullptr, PreemptionMode::Disabled, kernel, 0) {}
};
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
CommandQueue cmdQ(nullptr, device.get(), nullptr);
MockKernelWithInternals kernel(*device);
IndirectHeap *ih1 = nullptr, *ih2 = nullptr, *ih3 = nullptr;
cmdQ.allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 1, ih1);
cmdQ.allocateHeapMemory(IndirectHeap::INDIRECT_OBJECT, 1, ih2);
cmdQ.allocateHeapMemory(IndirectHeap::SURFACE_STATE, 1, ih3);
auto cmdStream = new LinearStream(alignedMalloc(1, 1), 1);
std::vector<Surface *> surfaces;
auto kernelOperation = new KernelOperation(std::unique_ptr<LinearStream>(cmdStream), UniqueIH(ih1), UniqueIH(ih2), UniqueIH(ih3),
*device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage());
std::unique_ptr<MockCommandComputeKernel> command = std::make_unique<MockCommandComputeKernel>(cmdQ, kernelOperation, surfaces, kernel);
MockVirtualEvent virtualEvent;
virtualEvent.eventWithoutCommand = false;
virtualEvent.submittedCmd.exchange(command.release());
EventBuilder eventBuilder;
EXPECT_EQ(nullptr, eventBuilder.getEvent());
constexpr int constrParam1 = 7;
constexpr float constrParam2 = 13.0f;
eventBuilder.create<SmallEventBuilderEventMock>(constrParam1, constrParam2);
Event *peekedEvent = eventBuilder.getEvent();
ASSERT_NE(nullptr, peekedEvent);
virtualEvent.taskLevel = CL_SUBMITTED;
eventBuilder.addParentEvent(&virtualEvent);
eventBuilder.finalize();
peekedEvent->release();
}
TEST(EventBuilder, whenDestroyingEventBuilderImplicitFinalizeIscalled) {
SmallEventBuilderEventMock *ev = nullptr;
auto parentEvent = new UserEvent;

View File

@ -156,21 +156,6 @@ TEST(Event, givenCommandQueueWhenEventIsCreatedWithoutCommandQueueThenCommandQue
EXPECT_EQ(intitialRefCount, finalRefCount);
}
TEST(Event, currentCmdQVirtualEventSetToFalseInCtor) {
Event *event = new Event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 4, 10);
EXPECT_FALSE(event->isCurrentCmdQVirtualEvent());
delete event;
}
TEST(Event, setCurrentCmdQVirtualEven) {
Event *event = new Event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 4, 10);
event->setCurrentCmdQVirtualEvent(true);
EXPECT_TRUE(event->isCurrentCmdQVirtualEvent());
delete event;
}
TEST(Event, waitForEventsFlushesAllQueues) {
class MockCommandQueueWithFlushCheck : public MockCommandQueue {
public:

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -10,6 +10,7 @@
#include "unit_tests/fixtures/hello_world_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/mocks/mock_event.h"
#include "unit_tests/utilities/base_object_utils.h"
#include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/os_interface/os_context.h"
@ -195,6 +196,7 @@ TEST_F(EventTests, blockedUserEventPassedToEnqueueNdRangeWithoutReturnEventIsNot
EXPECT_EQ(taskCountAfter, taskCount);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, blockedUserEventPassedToEnqueueNdRangeWithReturnEventIsNotSubmittedToCSR) {
@ -238,6 +240,8 @@ TEST_F(EventTests, blockedUserEventPassedToEnqueueNdRangeWithReturnEventIsNotSub
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, userEventInjectsCountOnReturnEventAndCreatesConnection) {
@ -265,6 +269,7 @@ TEST_F(EventTests, userEventInjectsCountOnReturnEventAndCreatesConnection) {
auto retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, givenNormalEventThatHasParentUserEventWhenUserEventIsUnblockedThenChildEventIsCompleteIfGpuCompletedProcessing) {
@ -319,6 +324,7 @@ TEST_F(EventTests, twoUserEventInjectsCountOnReturnEventAndCreatesConnection) {
auto retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, twoUserEventInjectsCountOnNDR1whichIsPropagatedToNDR2viaVirtualEvent) {
@ -428,6 +434,7 @@ TEST_F(EventTests, userEventStatusPropagatedToNormalEvent) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
HWTEST_F(EventTests, userEventObtainsProperTaskLevelAfterSignaling) {
@ -474,6 +481,7 @@ TEST_F(EventTests, normalEventsBasingOnUserEventHasProperTaskLevel) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, waitForEventThatWaitsOnSignaledUserEvent) {
@ -499,6 +507,7 @@ TEST_F(EventTests, waitForEventThatWaitsOnSignaledUserEvent) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, waitForAbortedUserEventReturnsFailure) {
@ -544,6 +553,7 @@ TEST_F(EventTests, enqueueWithAbortedUserEventDoesntFlushToCSR) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, childEventDestructorDoesntProcessBlockedCommandsWhenParentEventWasAborted) {
@ -584,6 +594,7 @@ TEST_F(EventTests, childEventDestructorDoesntProcessBlockedCommandsWhenParentEve
taskCountAfter = csr.peekTaskCount();
EXPECT_EQ(taskCount, taskCountAfter);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, waitForEventDependingOnAbortedUserEventReturnsFailure) {
@ -607,6 +618,7 @@ TEST_F(EventTests, waitForEventDependingOnAbortedUserEventReturnsFailure) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, waitForEventDependingOnAbortedUserEventReturnsFailureTwoInputEvents) {
@ -630,6 +642,7 @@ TEST_F(EventTests, waitForEventDependingOnAbortedUserEventReturnsFailureTwoInput
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, finishReturnsSuccessAfterQueueIsAborted) {
@ -653,6 +666,7 @@ TEST_F(EventTests, finishReturnsSuccessAfterQueueIsAborted) {
retVal = clFinish(pCmdQ);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, userEventRecordsDependantPacket) {
@ -666,6 +680,8 @@ TEST_F(EventTests, userEventRecordsDependantPacket) {
//virtual event should register for this command packet
ASSERT_NE(nullptr, pCmdQ->virtualEvent);
EXPECT_NE(nullptr, pCmdQ->virtualEvent->peekCommand());
EXPECT_FALSE(pCmdQ->virtualEvent->peekIsCmdSubmitted());
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, userEventDependantCommandPacketContainsValidCommandStream) {
@ -680,6 +696,7 @@ TEST_F(EventTests, userEventDependantCommandPacketContainsValidCommandStream) {
ASSERT_NE(nullptr, pCmdQ->virtualEvent);
auto cmd = static_cast<CommandComputeKernel *>(pCmdQ->virtualEvent->peekCommand());
EXPECT_NE(0u, cmd->getCommandStream()->getUsed());
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, unblockingEventSendsBlockedPackets) {
@ -709,6 +726,7 @@ TEST_F(EventTests, unblockingEventSendsBlockedPackets) {
uEvent.setStatus(0);
EXPECT_EQ(csr.peekTaskLevel(), 1u);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, virtualEventObtainedFromReturnedEventCannotBeReleasedByIsQueueBlocked) {
@ -734,6 +752,7 @@ TEST_F(EventTests, virtualEventObtainedFromReturnedEventCannotBeReleasedByIsQueu
EXPECT_EQ(nullptr, pCmdQ->virtualEvent);
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, userEventsDoesntChangeCommandStreamWhileEnqueueButDoesAfterSignaling) {
@ -766,6 +785,7 @@ TEST_F(EventTests, userEventsDoesntChangeCommandStreamWhileEnqueueButDoesAfterSi
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, givenUserEventThatHasCallbackAndBlockQueueWhenQueueIsQueriedForBlockedThenCallBackIsCalled) {
@ -845,6 +865,7 @@ TEST_F(EventTests, CallBackAfterEnqueue) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, CallBackAfterEnqueueWithoutWait) {
@ -873,6 +894,7 @@ TEST_F(EventTests, CallBackAfterEnqueueWithoutWait) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, enqueueReadImageBlockedOnUserEvent) {
@ -880,7 +902,7 @@ TEST_F(EventTests, enqueueReadImageBlockedOnUserEvent) {
UserEvent userEvent(this->context);
cl_event events[] = {&userEvent};
auto image = std::unique_ptr<Image>(Image2dHelper<>::create(pContext));
auto image = clUniquePtr(Image2dHelper<>::create(this->context));
ASSERT_NE(nullptr, image);
auto retVal = EnqueueReadImageHelper<>::enqueueReadImage(pCmdQ,
@ -904,6 +926,7 @@ TEST_F(EventTests, enqueueReadImageBlockedOnUserEvent) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, waitForEventsDestroysTemporaryAllocations) {
@ -998,6 +1021,7 @@ TEST_F(EventTests, WhenCalbackWasRegisteredOnCallbackExecutionPassesCorrectExecu
EXPECT_EQ(CL_COMPLETE, completeClbExecStatus);
clReleaseEvent(retEvent);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, eventOnQueryReturnsCorrentNumberOfBlockerEvents) {
@ -1037,6 +1061,7 @@ TEST_F(EventTests, eventOnQueryReturnsCorrentNumberOfBlockerEvents) {
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, blockedUserEventPassedToEnqueueNdRangeDoesntRetainCommandQueue) {
@ -1066,6 +1091,7 @@ TEST_F(EventTests, blockedUserEventPassedToEnqueueNdRangeDoesntRetainCommandQueu
retVal = clReleaseEvent(userEvent);
ASSERT_EQ(CL_SUCCESS, retVal);
pCmdQ->isQueueBlocked();
// VirtualEvent should be freed, so refCount should equal initial value
EXPECT_EQ(intitialRefCount, pCmdQ->getRefInternalCount());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -58,6 +58,7 @@ TEST_F(EventTests, eventCreatedFromUserEventsThatIsNotSignaledDoesntFlushToCSR)
retVal = clReleaseEvent(retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, givenUserEventBlockingEnqueueWithBlockingFlagWhenUserEventIsCompletedAfterBlockedPathIsChosenThenBlockingFlagDoesNotCauseStall) {
@ -79,6 +80,7 @@ TEST_F(EventTests, givenUserEventBlockingEnqueueWithBlockingFlagWhenUserEventIsC
t.join();
}
pCmdQ->releaseVirtualEvent();
}
TEST_F(EventTests, givenUserEventBlockingEnqueueWithBlockingFlagWhenUserEventIsCompletedAfterUpdateFromCompletionStampThenBlockingFlagDoesNotCauseStall) {
@ -106,4 +108,5 @@ TEST_F(EventTests, givenUserEventBlockingEnqueueWithBlockingFlagWhenUserEventIsC
auto retVal = pCmdQ->enqueueReadBuffer(srcBuffer.get(), CL_TRUE, 0, srcBuffer->getSize(), dst.get(), sizeOfWaitList, eventWaitList, nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
t.join();
pCmdQ->releaseVirtualEvent();
}

View File

@ -139,6 +139,7 @@ HWTEST_P(ParentKernelEnqueueTest, GivenBlocksWithPrivateMemoryWhenEnqueueKernelT
EXPECT_FALSE(csr.isMadeResident(privateAllocation));
uEvent.setStatus(CL_COMPLETE);
EXPECT_TRUE(csr.isMadeResident(privateAllocation));
pCmdQ->releaseVirtualEvent();
}
}
@ -199,6 +200,7 @@ HWTEST_P(ParentKernelEnqueueTest, GivenParentKernelWithBlocksWhenEnqueueKernelTh
for (auto blockId = 0u; blockId < blockCount; blockId++) {
EXPECT_TRUE(csr.isMadeResident(blockKernelManager->getBlockKernelInfo(blockId)->getGraphicsAllocation()));
}
pCmdQ->releaseVirtualEvent();
}
}
@ -337,6 +339,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, ParentKernelEnqueueTest, givenBlockedQueueWhenParent
pCmdQ->enqueueKernel(pKernel, 1, globalOffsets, workItems, workItems, 1, &eventBlocking, nullptr);
EXPECT_FALSE(mockDevQueue.isEMCriticalSectionFree());
pCmdQ->releaseVirtualEvent();
}
}
@ -500,6 +503,7 @@ HWTEST_F(ParentKernelEnqueueFixture, GivenParentKernelWhenEnqueuedToBlockedQueue
pCmdQ->enqueueKernel(parentKernel, 1, offset, gws, gws, 1, &eventBlocking, nullptr);
EXPECT_TRUE(pDevQueueHw->isEMCriticalSectionFree());
pCmdQ->releaseVirtualEvent();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -24,7 +24,8 @@ void ContextFixture::SetUp(cl_uint numDevices, cl_device_id *pDeviceList) {
}
void ContextFixture::TearDown() {
delete pContext;
pContext = nullptr;
if (pContext != nullptr) {
pContext->release();
}
}
} // namespace OCLRT

View File

@ -25,6 +25,7 @@ void DeviceFixture::SetUpImpl(const OCLRT::HardwareInfo *hardwareInfo) {
void DeviceFixture::TearDown() {
delete pDevice;
pDevice = nullptr;
}
MockDevice *DeviceFixture::createWithUsDeviceId(unsigned short usDeviceId) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -80,7 +80,7 @@ class ExecutionModelSchedulerTest : public DeviceFixture,
}
void TearDown() override {
delete parentKernel;
parentKernel->release();
DeviceQueueFixture::TearDown();
CommandQueueHwFixture::TearDown();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -65,17 +65,22 @@ class ExecutionModelKernelFixture : public ProgramFromBinaryTest,
}
void TearDown() override {
delete pKernel;
if (pKernel != nullptr) {
pKernel->release();
}
std::string temp;
temp.assign(pPlatform->getDevice(0)->getDeviceInfo().clVersion);
if (temp.find("OpenCL 1.2") != std::string::npos) {
delete pDevice;
pDevice = nullptr;
}
ProgramFromBinaryTest::TearDown();
PlatformFixture::TearDown();
if (temp.find("OpenCL 1.2") != std::string::npos) {
if (pDevice != nullptr) {
delete pDevice;
pDevice = nullptr;
}
}
}
Kernel *pKernel;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -98,8 +98,8 @@ struct HelloWorldFixture : public FixtureFactory::IndirectHeapFixture,
virtual void TearDown() {
pCmdQ->flush();
delete srcBuffer;
delete destBuffer;
srcBuffer->release();
destBuffer->release();
KernelFixture::TearDown();
IndirectHeapFixture::TearDown();

View File

@ -1,23 +1,8 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* SPDX-License-Identifier: MIT
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
@ -101,8 +86,7 @@ struct HelloWorldKernelFixture : public ProgramFixture {
virtual void TearDown() {
delete pKernelName;
delete pTestFilename;
delete pKernel;
pKernel = nullptr;
pKernel->release();
pContext->release();
ProgramFixture::TearDown();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -78,8 +78,7 @@ struct MediaKernelFixture : public HelloWorldFixture<FactoryType>,
}
void TearDown() override {
delete pVmeKernel;
pVmeKernel = nullptr;
pVmeKernel->release();
HardwareParse::TearDown();
Parent::TearDown();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -72,8 +72,7 @@ class ProgramFixture {
void Cleanup() {
if (pProgram != nullptr) {
delete pProgram;
pProgram = nullptr;
pProgram->release();
}
if (knownSource != nullptr) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -15,7 +15,6 @@ void ProgramFixture::CreateProgramFromBinary(cl_context context,
const std::string &binaryFileName,
cl_int &retVal,
const std::string &options) {
Cleanup();
retVal = CL_SUCCESS;
std::string testFile;

View File

@ -18,6 +18,7 @@
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/mocks/mock_mdi.h"
#include "unit_tests/mocks/mock_memory_manager.h"
#include "unit_tests/utilities/base_object_utils.h"
#include "gmock/gmock.h"
#include "test.h"
@ -84,9 +85,14 @@ struct TimestampPacketTests : public TimestampPacketSimpleTests {
void SetUp() override {
executionEnvironment.incRefInternal();
device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
context = std::make_unique<MockContext>(device.get());
kernel = std::make_unique<MockKernelWithInternals>(*device, context.get());
mockCmdQ = std::make_unique<MockCommandQueue>(context.get(), device.get(), nullptr);
context = new MockContext(device.get());
kernel = std::make_unique<MockKernelWithInternals>(*device, context);
mockCmdQ = new MockCommandQueue(context, device.get(), nullptr);
}
void TearDown() override {
mockCmdQ->release();
context->release();
}
template <typename MI_SEMAPHORE_WAIT>
@ -118,9 +124,9 @@ struct TimestampPacketTests : public TimestampPacketSimpleTests {
ExecutionEnvironment executionEnvironment;
std::unique_ptr<MockDevice> device;
std::unique_ptr<MockContext> context;
MockContext *context;
std::unique_ptr<MockKernelWithInternals> kernel;
std::unique_ptr<MockCommandQueue> mockCmdQ;
MockCommandQueue *mockCmdQ;
};
TEST_F(TimestampPacketSimpleTests, whenEndTagIsNotOneThenCanBeReleased) {
@ -349,7 +355,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingThe
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment.memoryManager.get());
csr.timestampPacketAllocator.reset(mockTagAllocator);
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
cl_event event1, event2;
@ -395,7 +401,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingThe
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
cmdQ->enqueueKernel(kernel->mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(1u, cmdQ->timestampPacketContainer->peekNodes().size());
@ -441,7 +447,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingThe
MockContext context2(device2.get());
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(&context2, device2.get(), nullptr);
const cl_uint eventsOnWaitlist = 6;
@ -493,11 +499,11 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFr
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
// Create second (LOW_PRIORITY) queue on the same device
cl_queue_properties props[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0};
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), props);
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), props);
cmdQ2->getUltCommandStreamReceiver().timestampPacketWriteEnabled = true;
const cl_uint eventsOnWaitlist = 6;
@ -549,10 +555,10 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingBlo
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
device2->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
MockContext context2(device2.get());
auto context2 = new MockContext(device2.get());
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(&context2, device2.get(), nullptr);
auto cmdQ1 = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, device.get(), nullptr));
auto cmdQ2 = new MockCommandQueueHw<FamilyType>(context2, device2.get(), nullptr);
MockTimestampPacketContainer timestamp0(*device->getCommandStreamReceiver().getTimestampPacketAllocator(), 1);
MockTimestampPacketContainer timestamp1(*device->getCommandStreamReceiver().getTimestampPacketAllocator(), 1);
@ -560,7 +566,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingBlo
UserEvent userEvent;
Event event0(cmdQ1.get(), 0, 0, 0);
event0.addTimestampPacketNodes(timestamp0);
Event event1(cmdQ2.get(), 0, 0, 0);
Event event1(cmdQ2, 0, 0, 0);
event1.addTimestampPacketNodes(timestamp1);
cl_event waitlist[] = {&userEvent, &event0, &event1};
@ -568,6 +574,8 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingBlo
auto &cmdStream = device->getUltCommandStreamReceiver<FamilyType>().commandStream;
EXPECT_EQ(0u, cmdStream.getUsed());
userEvent.setStatus(CL_COMPLETE);
cmdQ1->isQueueBlocked();
cmdQ2->isQueueBlocked();
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(cmdStream, 0);
@ -581,6 +589,9 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingBlo
EXPECT_EQ(nullptr, genCmdCast<MI_SEMAPHORE_WAIT *>(*it));
it++;
}
cmdQ2->release();
context2->release();
}
HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFromOneDeviceWhenEnqueueingBlockedThenProgramSemaphoresOnCsrStreamOnFlush) {
@ -589,11 +600,11 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFr
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ1 = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, device.get(), nullptr));
// Create second (LOW_PRIORITY) queue on the same device
cl_queue_properties props[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0};
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), props);
auto cmdQ2 = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, device.get(), props));
cmdQ2->getUltCommandStreamReceiver().timestampPacketWriteEnabled = true;
MockTimestampPacketContainer timestamp0(*device->getCommandStreamReceiver().getTimestampPacketAllocator(), 1);
@ -623,6 +634,9 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFr
EXPECT_EQ(nullptr, genCmdCast<MI_SEMAPHORE_WAIT *>(*it));
it++;
}
cmdQ2->isQueueBlocked();
cmdQ1->isQueueBlocked();
}
HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenDispatchingThenProgramSemaphoresForWaitlist) {
@ -647,11 +661,11 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenDispatchingTh
UserEvent event1;
UserEvent event2;
Event event3(mockCmdQ.get(), 0, 0, 0);
Event event3(mockCmdQ, 0, 0, 0);
event3.addTimestampPacketNodes(timestamp3);
Event event4(&mockCmdQ2, 0, 0, 0);
event4.addTimestampPacketNodes(timestamp4);
Event event5(mockCmdQ.get(), 0, 0, 0);
Event event5(mockCmdQ, 0, 0, 0);
event5.addTimestampPacketNodes(timestamp5);
Event event6(&mockCmdQ2, 0, 0, 0);
event6.addTimestampPacketNodes(timestamp6);
@ -714,7 +728,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFr
// Create second (LOW_PRIORITY) queue on the same device
cl_queue_properties props[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0};
auto mockCmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), props);
auto mockCmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), props);
mockCmdQ2->getUltCommandStreamReceiver().timestampPacketWriteEnabled = true;
auto &cmdStream = mockCmdQ->getCS(0);
@ -727,11 +741,11 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFr
UserEvent event1;
UserEvent event2;
Event event3(mockCmdQ.get(), 0, 0, 0);
Event event3(mockCmdQ, 0, 0, 0);
event3.addTimestampPacketNodes(timestamp3);
Event event4(mockCmdQ2.get(), 0, 0, 0);
event4.addTimestampPacketNodes(timestamp4);
Event event5(mockCmdQ.get(), 0, 0, 0);
Event event5(mockCmdQ, 0, 0, 0);
event5.addTimestampPacketNodes(timestamp5);
Event event6(mockCmdQ2.get(), 0, 0, 0);
event6.addTimestampPacketNodes(timestamp6);
@ -791,7 +805,7 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingNonBlockedT
csr.timestampPacketAllocator.reset(mockTagAllocator);
csr.timestampPacketWriteEnabled = true;
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
TimestampPacketContainer previousNodes;
cmdQ->obtainNewTimestampPacketNodes(1, previousNodes);
auto firstNode = cmdQ->timestampPacketContainer->peekNodes().at(0);
@ -813,7 +827,7 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingBlockedThen
csr.timestampPacketAllocator.reset(mockTagAllocator);
csr.timestampPacketWriteEnabled = true;
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, device.get(), nullptr));
TimestampPacketContainer previousNodes;
cmdQ->obtainNewTimestampPacketNodes(1, previousNodes);
auto firstNode = cmdQ->timestampPacketContainer->peekNodes().at(0);
@ -830,12 +844,13 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingBlockedThen
EXPECT_FALSE(csr.isMadeResident(firstNode->getGraphicsAllocation()));
userEvent.setStatus(CL_COMPLETE);
EXPECT_TRUE(csr.isMadeResident(firstNode->getGraphicsAllocation()));
cmdQ->isQueueBlocked();
}
HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingThenDontKeepDependencyOnPreviousNodeIfItsReady) {
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
MockCommandQueueHw<FamilyType> cmdQ(context, device.get(), nullptr);
TimestampPacketContainer previousNodes;
cmdQ.obtainNewTimestampPacketNodes(1, previousNodes);
auto firstNode = cmdQ.timestampPacketContainer->peekNodes().at(0);
@ -866,7 +881,7 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingThenKeepDep
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
MockTimestampPacketContainer firstNode(*device->getCommandStreamReceiver().getTimestampPacketAllocator(), 0);
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
MockCommandQueueHw<FamilyType> cmdQ(context, device.get(), nullptr);
TimestampPacketContainer previousNodes;
cmdQ.obtainNewTimestampPacketNodes(2, previousNodes);
firstNode.add(cmdQ.timestampPacketContainer->peekNodes().at(0));
@ -899,7 +914,7 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingToOoqThenDo
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
cl_queue_properties properties[] = {CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0};
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), properties);
MockCommandQueueHw<FamilyType> cmdQ(context, device.get(), properties);
TimestampPacketContainer previousNodes;
cmdQ.obtainNewTimestampPacketNodes(1, previousNodes);
@ -932,7 +947,7 @@ HWTEST_F(TimestampPacketTests, givenEventsWaitlistFromDifferentDevicesWhenEnqueu
device2->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
MockContext context2(device2.get());
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(&context2, device2.get(), nullptr);
MockTimestampPacketContainer node1(*ultCsr.getTimestampPacketAllocator(), 0);
@ -964,11 +979,11 @@ HWTEST_F(TimestampPacketTests, givenEventsWaitlistFromDifferentCSRsWhenEnqueuein
ultCsr.timestampPacketWriteEnabled = true;
ultCsr.storeMakeResidentAllocations = true;
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ1 = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
// Create second (LOW_PRIORITY) queue on the same device
cl_queue_properties props[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0};
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), props);
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), props);
cmdQ2->getUltCommandStreamReceiver().timestampPacketWriteEnabled = true;
MockTimestampPacketContainer node1(*ultCsr.getTimestampPacketAllocator(), 0);
@ -998,8 +1013,8 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWhenEnqueueingNonBlockedThenM
csr.timestampPacketWriteEnabled = true;
csr.storeMakeResidentAllocations = true;
MockKernelWithInternals mockKernel(*device, context.get());
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
MockKernelWithInternals mockKernel(*device, context);
MockCommandQueueHw<FamilyType> cmdQ(context, device.get(), nullptr);
cmdQ.enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
auto timestampPacketNode = cmdQ.timestampPacketContainer->peekNodes().at(0);
@ -1010,28 +1025,31 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWhenEnqueueingNonBlockedThenM
HWTEST_F(TimestampPacketTests, givenTimestampPacketWhenEnqueueingBlockedThenMakeItResidentOnSubmit) {
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketWriteEnabled = true;
MockKernelWithInternals mockKernel(*device, context.get());
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
MockKernelWithInternals mockKernel(*device, context);
auto cmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, device.get(), nullptr));
csr.storeMakeResidentAllocations = true;
UserEvent userEvent;
cl_event clEvent = &userEvent;
cmdQ.enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 1, &clEvent, nullptr);
auto timestampPacketNode = cmdQ.timestampPacketContainer->peekNodes().at(0);
cmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 1, &clEvent, nullptr);
auto timestampPacketNode = cmdQ->timestampPacketContainer->peekNodes().at(0);
EXPECT_FALSE(csr.isMadeResident(timestampPacketNode->getGraphicsAllocation()));
userEvent.setStatus(CL_COMPLETE);
EXPECT_TRUE(csr.isMadeResident(timestampPacketNode->getGraphicsAllocation()));
cmdQ->isQueueBlocked();
}
HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingBlockedThenVirtualEventIncrementsRefInternalAndDecrementsAfterCompleteEvent) {
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketWriteEnabled = true;
MockKernelWithInternals mockKernelWithInternals(*device, context.get());
MockKernelWithInternals mockKernelWithInternals(*device, context);
auto mockKernel = mockKernelWithInternals.mockKernel;
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context.get(), device.get(), nullptr);
auto cmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, device.get(), nullptr));
UserEvent userEvent;
cl_event waitlist = &userEvent;
@ -1040,6 +1058,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingBlo
cmdQ->enqueueKernel(mockKernel, 1, nullptr, gws, nullptr, 1, &waitlist, nullptr);
EXPECT_EQ(internalCount + 1, userEvent.getRefInternalCount());
userEvent.setStatus(CL_COMPLETE);
cmdQ->isQueueBlocked();
EXPECT_EQ(internalCount, mockKernel->getRefInternalCount());
}
@ -1057,32 +1076,32 @@ TEST_F(TimestampPacketTests, givenDispatchSizeWhenAskingForNewTimestampsThenObta
HWTEST_F(TimestampPacketTests, givenWaitlistAndOutputEventWhenEnqueueingWithoutKernelThenInheritTimestampPacketsWithoutSubmitting) {
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
auto cmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, device.get(), nullptr));
MockKernelWithInternals mockKernel(*device, context.get());
cmdQ.enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr); // obtain first TimestampPacket
MockKernelWithInternals mockKernel(*device, context);
cmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr); // obtain first TimestampPacket
TimestampPacketContainer cmdQNodes;
cmdQNodes.assignAndIncrementNodesRefCounts(*cmdQ.timestampPacketContainer);
cmdQNodes.assignAndIncrementNodesRefCounts(*cmdQ->timestampPacketContainer);
MockTimestampPacketContainer node1(*device->getCommandStreamReceiver().getTimestampPacketAllocator(), 1);
MockTimestampPacketContainer node2(*device->getCommandStreamReceiver().getTimestampPacketAllocator(), 1);
Event event0(&cmdQ, 0, 0, 0);
Event event0(cmdQ.get(), 0, 0, 0);
event0.addTimestampPacketNodes(node1);
Event event1(&cmdQ, 0, 0, 0);
Event event1(cmdQ.get(), 0, 0, 0);
event1.addTimestampPacketNodes(node2);
UserEvent userEvent;
cl_event waitlist[] = {&event0, &event1, &userEvent};
cl_event clOutEvent;
cmdQ.enqueueMarkerWithWaitList(3, waitlist, &clOutEvent);
cmdQ->enqueueMarkerWithWaitList(3, waitlist, &clOutEvent);
auto outEvent = castToObject<Event>(clOutEvent);
EXPECT_EQ(cmdQ.timestampPacketContainer->peekNodes().at(0), cmdQNodes.peekNodes().at(0)); // no new nodes obtained
EXPECT_EQ(1u, cmdQ.timestampPacketContainer->peekNodes().size());
EXPECT_EQ(cmdQ->timestampPacketContainer->peekNodes().at(0), cmdQNodes.peekNodes().at(0)); // no new nodes obtained
EXPECT_EQ(1u, cmdQ->timestampPacketContainer->peekNodes().size());
auto &eventsNodes = outEvent->getTimestampPacketNodes()->peekNodes();
EXPECT_EQ(3u, eventsNodes.size());
@ -1091,16 +1110,18 @@ HWTEST_F(TimestampPacketTests, givenWaitlistAndOutputEventWhenEnqueueingWithoutK
EXPECT_EQ(event1.getTimestampPacketNodes()->peekNodes().at(0), eventsNodes.at(2));
clReleaseEvent(clOutEvent);
userEvent.setStatus(CL_COMPLETE);
cmdQ->isQueueBlocked();
}
HWTEST_F(TimestampPacketTests, givenEmptyWaitlistAndNoOutputEventWhenEnqueueingMarkerThenDoNothing) {
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketWriteEnabled = true;
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
auto cmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, device.get(), nullptr));
cmdQ.enqueueMarkerWithWaitList(0, nullptr, nullptr);
EXPECT_EQ(0u, cmdQ.timestampPacketContainer->peekNodes().size());
cmdQ->enqueueMarkerWithWaitList(0, nullptr, nullptr);
EXPECT_EQ(0u, cmdQ->timestampPacketContainer->peekNodes().size());
EXPECT_FALSE(csr.stallingPipeControlOnNextFlushRequired);
}
@ -1110,9 +1131,9 @@ HWTEST_F(TimestampPacketTests, whenEnqueueingBarrierThenRequestPipeControlOnCsrF
EXPECT_FALSE(csr.stallingPipeControlOnNextFlushRequired);
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
MockCommandQueueHw<FamilyType> cmdQ(context, device.get(), nullptr);
MockKernelWithInternals mockKernel(*device, context.get());
MockKernelWithInternals mockKernel(*device, context);
cmdQ.enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr); // obtain first TimestampPacket
TimestampPacketContainer cmdQNodes;
@ -1132,7 +1153,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteDisabledWhenEnqueueingBa
EXPECT_FALSE(csr.stallingPipeControlOnNextFlushRequired);
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
MockCommandQueueHw<FamilyType> cmdQ(context, device.get(), nullptr);
cmdQ.enqueueBarrierWithWaitList(0, nullptr, nullptr);
@ -1144,7 +1165,7 @@ HWTEST_F(TimestampPacketTests, givenBlockedQueueWhenEnqueueingBarrierThenRequest
csr.timestampPacketWriteEnabled = true;
EXPECT_FALSE(csr.stallingPipeControlOnNextFlushRequired);
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
MockCommandQueueHw<FamilyType> cmdQ(context, device.get(), nullptr);
UserEvent userEvent;
cl_event waitlist[] = {&userEvent};
@ -1173,9 +1194,9 @@ HWTEST_F(TimestampPacketTests, givenPipeControlRequestWhenFlushingThenProgramPip
csr.stallingPipeControlOnNextFlushRequired = true;
csr.timestampPacketWriteEnabled = true;
MockCommandQueueHw<FamilyType> cmdQ(context.get(), device.get(), nullptr);
MockCommandQueueHw<FamilyType> cmdQ(context, device.get(), nullptr);
MockKernelWithInternals mockKernel(*device, context.get());
MockKernelWithInternals mockKernel(*device, context);
cmdQ.enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
EXPECT_FALSE(csr.stallingPipeControlOnNextFlushRequired);

View File

@ -34,7 +34,8 @@ struct ProfilingTests : public CommandEnqueueFixture,
public ::testing::Test {
void SetUp() override {
CommandEnqueueFixture::SetUp(CL_QUEUE_PROFILING_ENABLE);
program = std::make_unique<MockProgram>(*pDevice->getExecutionEnvironment());
program = ReleaseableObjectPtr<MockProgram>(new MockProgram(*pDevice->getExecutionEnvironment()));
memset(&kernelHeader, 0, sizeof(kernelHeader));
kernelHeader.KernelHeapSize = sizeof(kernelIsa);
@ -63,7 +64,7 @@ struct ProfilingTests : public CommandEnqueueFixture,
CommandEnqueueFixture::TearDown();
}
std::unique_ptr<MockProgram> program;
ReleaseableObjectPtr<MockProgram> program;
SKernelBinaryHeaderCommon kernelHeader = {};
SPatchDataParameterStream dataParameterStream = {};
@ -295,6 +296,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, ProfilingTests, GIVENCommandQueueBlockedWithProfilin
clReleaseEvent(event);
((UserEvent *)ue)->release();
pCmdQ->isQueueBlocked();
}
/*
@ -354,6 +356,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, ProfilingTests, GIVENCommandQueueBlockedWithProfilin
EXPECT_EQ(itorAfterMI, cmdList.end());
clReleaseEvent(event);
((UserEvent *)ue)->release();
pCmdQ->isQueueBlocked();
}
HWTEST_F(ProfilingTests, givenNonKernelEnqueueWhenNonBlockedEnqueueThenSetCpuPath) {
@ -794,6 +797,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, ProfilingWithPerfCountersTests, GIVENCommandQueueBlo
clReleaseEvent(event);
((UserEvent *)ue)->release();
pCmdQ->isQueueBlocked();
pCmdQ->setPerfCountersEnabled(false, UINT32_MAX);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -8,6 +8,7 @@
#include "unit_tests/fixtures/scenario_test_fixture.h"
#include "unit_tests/mocks/mock_command_queue.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "unit_tests/utilities/base_object_utils.h"
#include "runtime/event/user_event.h"
#include "runtime/helpers/options.h"
@ -21,8 +22,8 @@ typedef ScenarioTest BarrierScenarioTest;
HWTEST_F(BarrierScenarioTest, givenBlockedEnqueueBarrierOnOOQWhenUserEventIsUnblockedThenNextEnqueuesAreNotBlocked) {
cl_command_queue clCommandQ = nullptr;
cl_queue_properties properties[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0};
auto mockCmdQ = new MockCommandQueueHw<FamilyType>(context, pPlatform->getDevice(0), properties);
clCommandQ = mockCmdQ;
auto mockCmdQ = clUniquePtr(new MockCommandQueueHw<FamilyType>(context, pPlatform->getDevice(0), properties));
clCommandQ = mockCmdQ.get();
cl_kernel clKernel = kernel;
size_t offset[] = {0, 0, 0};
@ -43,6 +44,7 @@ HWTEST_F(BarrierScenarioTest, givenBlockedEnqueueBarrierOnOOQWhenUserEventIsUnbl
clSetUserEventStatus(eventBlocking, CL_COMPLETE);
userEvent->release();
mockCmdQ->isQueueBlocked();
EXPECT_NE(Event::eventNotReady, mockCmdQ->taskLevel);
EXPECT_EQ(nullptr, mockCmdQ->virtualEvent);
@ -51,6 +53,4 @@ HWTEST_F(BarrierScenarioTest, givenBlockedEnqueueBarrierOnOOQWhenUserEventIsUnbl
retVal = clFinish(clCommandQ);
EXPECT_EQ(success, retVal);
mockCmdQ->release();
}

View File

@ -11,10 +11,19 @@
namespace OCLRT {
template <typename T>
using ReleaseableObjectPtr = std::unique_ptr<T, void (*)(T *)>;
struct ReleaseObject {
void operator()(T *t) {
if (t != nullptr) {
t->release();
}
}
};
template <typename T>
using ReleaseableObjectPtr = std::unique_ptr<T, ReleaseObject<T>>;
template <typename T>
static ReleaseableObjectPtr<T> clUniquePtr(T *object) {
return ReleaseableObjectPtr<T>{object, [](T *p) { p->release(); }};
return ReleaseableObjectPtr<T>{object};
}
} // namespace OCLRT