Removing dependent commandQueue kernels

Signed-off-by: Andrzej Koska <andrzej.koska@intel.com>
Related-To: NEO-6212
This commit is contained in:
Andrzej Koska
2021-08-31 15:44:43 +00:00
committed by Compute-Runtime-Automation
parent 34ad95ae12
commit bd9457262e
4 changed files with 62 additions and 1 deletions

View File

@ -125,6 +125,7 @@ CommandQueue::~CommandQueue() {
if (context && !isSpecialCommandQueue) {
context->decRefInternal();
}
gtpinRemoveCommandQueue(this);
}
CommandStreamReceiver &CommandQueue::getGpgpuCommandStreamReceiver() const {

View File

@ -265,4 +265,18 @@ void gtpinSetIgcInit(void *pIgcInitPtr) {
pIgcInit = static_cast<igc_init_t *>(pIgcInitPtr);
}
void gtpinRemoveCommandQueue(void *pCmdQueue) {
if (isGTPinInitialized) {
std::unique_lock<GTPinLockType> lock{kernelExecQueueLock};
size_t n = 0;
while (n < kernelExecQueue.size()) {
if (kernelExecQueue[n].pCommandQueue == pCmdQueue) {
kernelExecQueue.erase(kernelExecQueue.begin() + n);
} else {
n++;
}
}
}
}
} // namespace NEO

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -27,4 +27,5 @@ void gtpinNotifyPlatformShutdown();
inline bool gtpinIsGTPinInitialized() { return isGTPinInitialized; }
void *gtpinGetIgcInit();
void gtpinSetIgcInit(void *pIgcInitPtr);
void gtpinRemoveCommandQueue(void *pCmdQueue);
} // namespace NEO

View File

@ -2830,4 +2830,49 @@ HWTEST_F(GTPinTestsWithLocalMemory, givenGtPinCanUseSharedAllocationWhenGtpinNot
mockGAHandle.reset();
allocDataHandle.reset();
}
TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenGtpinRemoveCommandQueueIsCalledThenAllKernelsFromCmdQueueAreRemoved) {
gtpinCallbacks.onContextCreate = OnContextCreate;
gtpinCallbacks.onContextDestroy = OnContextDestroy;
gtpinCallbacks.onKernelCreate = OnKernelCreate;
gtpinCallbacks.onKernelSubmit = OnKernelSubmit;
gtpinCallbacks.onCommandBufferCreate = OnCommandBufferCreate;
gtpinCallbacks.onCommandBufferComplete = OnCommandBufferComplete;
retFromGtPin = GTPin_Init(&gtpinCallbacks, &driverServices, nullptr);
EXPECT_EQ(GTPIN_DI_SUCCESS, retFromGtPin);
kernelExecQueue.clear();
CommandQueue *cmdQ1 = reinterpret_cast<CommandQueue *>(1);
CommandQueue *cmdQ2 = reinterpret_cast<CommandQueue *>(2);
Kernel *kernel1 = reinterpret_cast<Kernel *>(1);
Kernel *kernel2 = reinterpret_cast<Kernel *>(2);
Kernel *kernel3 = reinterpret_cast<Kernel *>(3);
Kernel *kernel4 = reinterpret_cast<Kernel *>(4);
gtpinkexec_t kExec;
kExec.pKernel = kernel1;
kExec.pCommandQueue = cmdQ1;
kernelExecQueue.push_back(kExec);
kExec.pKernel = kernel2;
kExec.pCommandQueue = cmdQ1;
kernelExecQueue.push_back(kExec);
kExec.pKernel = kernel3;
kExec.pCommandQueue = cmdQ2;
kernelExecQueue.push_back(kExec);
kExec.pKernel = kernel4;
kExec.pCommandQueue = cmdQ2;
kernelExecQueue.push_back(kExec);
EXPECT_EQ(4u, kernelExecQueue.size());
gtpinRemoveCommandQueue(cmdQ1);
EXPECT_EQ(2u, kernelExecQueue.size());
gtpinRemoveCommandQueue(cmdQ2);
EXPECT_EQ(0u, kernelExecQueue.size());
}
} // namespace ULT