Aux translation [4/n]: Lock BuiltIn Kernel + refactor BuiltIns locking
Change-Id: Ic7dc9b86a4aa5f93f1c4bcdf80b9598ecdff9713 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
parent
d3d8b6f905
commit
a5950500a3
|
@ -224,20 +224,6 @@ Program *BuiltIns::createBuiltInProgram(
|
|||
return pBuiltInProgram;
|
||||
}
|
||||
|
||||
void BuiltinDispatchInfoBuilder::takeOwnership(Context *context) {
|
||||
for (auto &k : usedKernels) {
|
||||
k->takeOwnership(true);
|
||||
k->setContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
void BuiltinDispatchInfoBuilder::releaseOwnership() {
|
||||
for (auto &k : usedKernels) {
|
||||
k->setContext(nullptr);
|
||||
k->releaseOwnership();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename HWFamily>
|
||||
class BuiltInOp<HWFamily, EBuiltInOps::CopyBufferToBuffer> : public BuiltinDispatchInfoBuilder {
|
||||
public:
|
||||
|
@ -827,4 +813,24 @@ std::unique_ptr<BuiltinDispatchInfoBuilder> BuiltIns::setBuiltinDispatchInfoBuil
|
|||
return builder;
|
||||
}
|
||||
|
||||
BuiltInOwnershipWrapper::BuiltInOwnershipWrapper(BuiltinDispatchInfoBuilder &inputBuilder, Context *context) {
|
||||
takeOwnership(inputBuilder, context);
|
||||
}
|
||||
BuiltInOwnershipWrapper::~BuiltInOwnershipWrapper() {
|
||||
if (builder) {
|
||||
for (auto &kernel : builder->peekUsedKernels()) {
|
||||
kernel->setContext(nullptr);
|
||||
kernel->releaseOwnership();
|
||||
}
|
||||
}
|
||||
}
|
||||
void BuiltInOwnershipWrapper::takeOwnership(BuiltinDispatchInfoBuilder &inputBuilder, Context *context) {
|
||||
UNRECOVERABLE_IF(builder);
|
||||
builder = &inputBuilder;
|
||||
for (auto &kernel : builder->peekUsedKernels()) {
|
||||
kernel->takeOwnership(true);
|
||||
kernel->setContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
#include "runtime/built_ins/sip.h"
|
||||
#include "runtime/utilities/vec.h"
|
||||
|
||||
|
@ -238,6 +239,18 @@ class BuiltIns {
|
|||
bool enableCacheing = true;
|
||||
};
|
||||
|
||||
class BuiltInOwnershipWrapper : public NonCopyableOrMovableClass {
|
||||
public:
|
||||
BuiltInOwnershipWrapper() = default;
|
||||
BuiltInOwnershipWrapper(BuiltinDispatchInfoBuilder &inputBuilder, Context *context);
|
||||
~BuiltInOwnershipWrapper();
|
||||
|
||||
void takeOwnership(BuiltinDispatchInfoBuilder &inputBuilder, Context *context);
|
||||
|
||||
protected:
|
||||
BuiltinDispatchInfoBuilder *builder = nullptr;
|
||||
};
|
||||
|
||||
template <typename HWFamily, EBuiltInOps OpCode>
|
||||
class BuiltInOp;
|
||||
|
||||
|
|
|
@ -90,8 +90,7 @@ class BuiltinDispatchInfoBuilder {
|
|||
return true;
|
||||
}
|
||||
|
||||
void takeOwnership(Context *context);
|
||||
void releaseOwnership();
|
||||
std::vector<std::unique_ptr<Kernel>> &peekUsedKernels() { return usedKernels; }
|
||||
|
||||
protected:
|
||||
template <typename KernelNameT, typename... KernelsDescArgsT>
|
||||
|
|
|
@ -78,6 +78,7 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface *(&surfaces)[surfaceCount
|
|||
if (kernel == nullptr) {
|
||||
enqueueHandler<commandType>(surfaces, blocking, MultiDispatchInfo(), numEventsInWaitList, eventWaitList, event);
|
||||
} else {
|
||||
BuiltInOwnershipWrapper builtInLock;
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
|
||||
if (DebugManager.flags.ForceDispatchScheduler.get()) {
|
||||
|
@ -85,6 +86,8 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface *(&surfaces)[surfaceCount
|
|||
} else {
|
||||
BuffersForAuxTranslation buffersForAuxTranslation;
|
||||
if (kernel->isAuxTranslationRequired()) {
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, getContext(), getDevice());
|
||||
builtInLock.takeOwnership(builder, this->context);
|
||||
kernel->fillWithBuffersForAuxTranslation(buffersForAuxTranslation);
|
||||
dispatchAuxTranslation(multiDispatchInfo, buffersForAuxTranslation, AuxTranslationDirection::AuxToNonAux);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyBuffer(
|
|||
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
BuiltinDispatchInfoBuilder::BuiltinOpParams dc;
|
||||
dc.srcMemObj = srcBuffer;
|
||||
|
@ -70,8 +70,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyBuffer(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -50,7 +50,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyBufferRect(
|
|||
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferRect,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
MemObjSurface srcBufferSurf(srcBuffer);
|
||||
MemObjSurface dstBufferSurf(dstBuffer);
|
||||
|
@ -76,8 +76,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyBufferRect(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -50,7 +50,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyBufferToImage(
|
|||
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToImage3d,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
MemObjSurface srcBufferSurf(srcBuffer);
|
||||
MemObjSurface dstImgSurf(dstImage);
|
||||
|
@ -75,8 +75,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyBufferToImage(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -50,7 +50,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImage(
|
|||
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyImageToImage3d,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
MemObjSurface srcImgSurf(srcImage);
|
||||
MemObjSurface dstImgSurf(dstImage);
|
||||
|
@ -78,8 +78,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImage(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -50,7 +50,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImageToBuffer(
|
|||
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyImage3dToBuffer,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
MemObjSurface srcImgSurf(srcImage);
|
||||
MemObjSurface dstBufferSurf(dstBuffer);
|
||||
|
@ -75,8 +75,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImageToBuffer(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -64,7 +64,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
|
|||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::FillBuffer,
|
||||
this->getContext(), this->getDevice());
|
||||
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
BuiltinDispatchInfoBuilder::BuiltinOpParams dc;
|
||||
MemObj patternMemObj(this->context, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(),
|
||||
|
@ -89,8 +89,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
|
|||
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(patternAllocation), TEMPORARY_ALLOCATION, taskCount);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -49,7 +49,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillImage(
|
|||
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::FillImage3d,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
MemObjSurface dstImgSurf(image);
|
||||
Surface *surfaces[] = {&dstImgSurf};
|
||||
|
@ -70,8 +70,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillImage(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -94,7 +94,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBuffer(
|
|||
}
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
void *dstPtr = ptr;
|
||||
|
||||
|
@ -105,7 +105,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBuffer(
|
|||
if (size != 0) {
|
||||
bool status = createAllocationForHostSurface(hostPtrSurf);
|
||||
if (!status) {
|
||||
builder.releaseOwnership();
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
dstPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddressToPatch());
|
||||
|
@ -131,7 +130,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBuffer(
|
|||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBufferRect(
|
|||
}
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferRect,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
size_t hostPtrSize = Buffer::calculateHostPtrSize(hostOrigin, region, hostRowPitch, hostSlicePitch);
|
||||
void *dstPtr = ptr;
|
||||
|
@ -93,7 +93,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBufferRect(
|
|||
region[2] != 0) {
|
||||
bool status = createAllocationForHostSurface(hostPtrSurf);
|
||||
if (!status) {
|
||||
builder.releaseOwnership();
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
dstPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddressToPatch());
|
||||
|
@ -119,8 +118,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadBufferRect(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_BAD_INTEL, CL_ENQUEUE_READ_BUFFER_RECT_REQUIRES_COPY_DATA, static_cast<cl_mem>(buffer), ptr);
|
||||
if (!isL3Capable(ptr, hostPtrSize)) {
|
||||
|
|
|
@ -82,7 +82,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
|
|||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyImage3dToBuffer,
|
||||
this->getContext(), this->getDevice());
|
||||
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
size_t hostPtrSize = calculateHostPtrSizeForImage(const_cast<size_t *>(region), inputRowPitch, inputSlicePitch, srcImage);
|
||||
void *dstPtr = ptr;
|
||||
|
@ -96,7 +96,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
|
|||
region[2] != 0) {
|
||||
bool status = createAllocationForHostSurface(hostPtrSurf);
|
||||
if (!status) {
|
||||
builder.releaseOwnership();
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
dstPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddressToPatch());
|
||||
|
@ -122,8 +121,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
if (!isL3Capable(ptr, hostPtrSize)) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_BAD_INTEL, CL_ENQUEUE_READ_IMAGE_DOESNT_MEET_ALIGNMENT_RESTRICTIONS, ptr, hostPtrSize, MemoryConstants::pageSize, MemoryConstants::pageSize);
|
||||
|
|
|
@ -194,7 +194,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemcpy(cl_bool blockingCopy,
|
|||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer,
|
||||
this->getContext(), this->getDevice());
|
||||
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
BuiltinDispatchInfoBuilder::BuiltinOpParams operationParams;
|
||||
operationParams.srcPtr = const_cast<void *>(srcPtr);
|
||||
|
@ -217,8 +217,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemcpy(cl_bool blockingCopy,
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -264,7 +262,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
|
|||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::FillBuffer,
|
||||
this->getContext(), this->getDevice());
|
||||
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
BuiltinDispatchInfoBuilder::BuiltinOpParams operationParams;
|
||||
MemObj patternMemObj(this->context, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(),
|
||||
|
@ -290,8 +288,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
|
|||
|
||||
memoryManager->storeAllocation(std::unique_ptr<GraphicsAllocation>(patternAllocation), REUSABLE_ALLOCATION, taskCount);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
|
|||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer,
|
||||
this->getContext(), this->getDevice());
|
||||
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
void *srcPtr = const_cast<void *>(ptr);
|
||||
|
||||
|
@ -106,7 +106,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
|
|||
if (size != 0) {
|
||||
bool status = createAllocationForHostSurface(hostPtrSurf);
|
||||
if (!status) {
|
||||
builder.releaseOwnership();
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
srcPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddressToPatch());
|
||||
|
@ -131,8 +130,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
|
|||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, CL_ENQUEUE_WRITE_BUFFER_REQUIRES_COPY_DATA, static_cast<cl_mem>(buffer));
|
||||
}
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -78,7 +78,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBufferRect(
|
|||
}
|
||||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferRect,
|
||||
this->getContext(), this->getDevice());
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
size_t hostPtrSize = Buffer::calculateHostPtrSize(hostOrigin, region, hostRowPitch, hostSlicePitch);
|
||||
void *srcPtr = const_cast<void *>(ptr);
|
||||
|
@ -92,7 +92,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBufferRect(
|
|||
region[2] != 0) {
|
||||
bool status = createAllocationForHostSurface(hostPtrSurf);
|
||||
if (!status) {
|
||||
builder.releaseOwnership();
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
srcPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddressToPatch());
|
||||
|
@ -118,8 +117,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBufferRect(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, CL_ENQUEUE_WRITE_BUFFER_RECT_REQUIRES_COPY_DATA, static_cast<cl_mem>(buffer));
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
|||
auto &builder = BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToImage3d,
|
||||
this->getContext(), this->getDevice());
|
||||
|
||||
builder.takeOwnership(this->context);
|
||||
BuiltInOwnershipWrapper lock(builder, this->context);
|
||||
|
||||
size_t hostPtrSize = calculateHostPtrSizeForImage(const_cast<size_t *>(region), inputRowPitch, inputSlicePitch, dstImage);
|
||||
void *srcPtr = const_cast<void *>(ptr);
|
||||
|
@ -93,7 +93,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
|||
region[2] != 0) {
|
||||
bool status = createAllocationForHostSurface(hostPtrSurf);
|
||||
if (!status) {
|
||||
builder.releaseOwnership();
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
srcPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddressToPatch());
|
||||
|
@ -120,8 +119,6 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
|||
eventWaitList,
|
||||
event);
|
||||
|
||||
builder.releaseOwnership();
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, CL_ENQUEUE_WRITE_IMAGE_REQUIRES_COPY_DATA, static_cast<cl_mem>(dstImage));
|
||||
}
|
||||
|
|
|
@ -87,4 +87,14 @@ struct MapInfo {
|
|||
bool readOnly = false;
|
||||
uint32_t mipLevel = 0;
|
||||
};
|
||||
|
||||
class NonCopyableOrMovableClass {
|
||||
public:
|
||||
NonCopyableOrMovableClass() = default;
|
||||
NonCopyableOrMovableClass(const NonCopyableOrMovableClass &) = delete;
|
||||
NonCopyableOrMovableClass &operator=(const NonCopyableOrMovableClass &) = delete;
|
||||
|
||||
NonCopyableOrMovableClass(NonCopyableOrMovableClass &&) = delete;
|
||||
NonCopyableOrMovableClass &operator=(NonCopyableOrMovableClass &&) = delete;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "unit_tests/global_environment.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
#include "unit_tests/mocks/mock_builtins.h"
|
||||
#include "unit_tests/mocks/mock_compilers.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
|
@ -204,11 +205,6 @@ TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderCopyBufferToBuffer) {
|
|||
builtinOpsParams.size = {dst.getSize(), 0, 0};
|
||||
|
||||
ASSERT_TRUE(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));
|
||||
builder.takeOwnership(pContext);
|
||||
|
||||
for (auto &dispatchInfo : multiDispatchInfo) {
|
||||
EXPECT_TRUE(dispatchInfo.getKernel()->hasOwnership());
|
||||
}
|
||||
|
||||
size_t leftSize = reinterpret_cast<uintptr_t>(dst.getCpuAddress()) % MemoryConstants::cacheLineSize;
|
||||
if (leftSize > 0) {
|
||||
|
@ -249,11 +245,6 @@ TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderCopyBufferToBuffer) {
|
|||
i++;
|
||||
}
|
||||
|
||||
builder.releaseOwnership();
|
||||
for (auto &dispatchInfo : multiDispatchInfo) {
|
||||
EXPECT_FALSE(dispatchInfo.getKernel()->hasOwnership());
|
||||
}
|
||||
|
||||
delete srcPtr;
|
||||
delete dstPtr;
|
||||
}
|
||||
|
@ -413,6 +404,7 @@ class MockAuxBuilInOp : public BuiltInOp<Family, EBuiltInOps::AuxTranslation> {
|
|||
using BaseClass::convertToAuxKernel;
|
||||
using BaseClass::convertToNonAuxKernel;
|
||||
using BaseClass::resizeKernelInstances;
|
||||
using BaseClass::usedKernels;
|
||||
|
||||
MockAuxBuilInOp(BuiltIns &kernelsLib, Context &context, Device &device) : BaseClass(kernelsLib, context, device) {}
|
||||
};
|
||||
|
@ -447,7 +439,6 @@ HWTEST_F(BuiltInTests, givenMoreBuffersForAuxTranslationThanKernelInstancesWhenD
|
|||
|
||||
HWTEST_F(BuiltInTests, givenkAuxBuiltInWhenResizeIsCalledThenCloneAllNewInstancesFromBaseKernel) {
|
||||
MockAuxBuilInOp<FamilyType> mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
|
||||
|
||||
size_t newSize = mockAuxBuiltInOp.convertToAuxKernel.size() + 3;
|
||||
mockAuxBuiltInOp.resizeKernelInstances(newSize);
|
||||
|
||||
|
@ -462,6 +453,39 @@ HWTEST_F(BuiltInTests, givenkAuxBuiltInWhenResizeIsCalledThenCloneAllNewInstance
|
|||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenKernelWithAuxTranslationRequiredWhenEnqueueCalledThenLockOnBuiltin) {
|
||||
BuiltIns::getInstance().getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
auto mockAuxBuiltInOp = new MockAuxBuilInOp<FamilyType>(*pBuiltIns, *pContext, *pDevice);
|
||||
pBuiltIns->BuiltinOpsBuilders[static_cast<uint32_t>(EBuiltInOps::AuxTranslation)].first.reset(mockAuxBuiltInOp);
|
||||
|
||||
MockProgram mockProgram;
|
||||
auto mockBuiltinKernel = MockKernel::create(*pDevice, &mockProgram);
|
||||
mockAuxBuiltInOp->usedKernels.at(0).reset(mockBuiltinKernel);
|
||||
|
||||
MockKernelWithInternals mockKernel(*pDevice, pContext);
|
||||
MockCommandQueueHw<FamilyType> cmdQ(pContext, pDevice, nullptr);
|
||||
size_t gws[3] = {1, 0, 0};
|
||||
MockBuffer buffer;
|
||||
cl_mem clMem = &buffer;
|
||||
|
||||
buffer.getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
mockKernel.kernelInfo.kernelArgInfo.resize(1);
|
||||
mockKernel.kernelInfo.kernelArgInfo.at(0).kernelArgPatchInfoVector.resize(1);
|
||||
mockKernel.kernelInfo.kernelArgInfo.at(0).pureStatefulBufferAccess = false;
|
||||
mockKernel.mockKernel->initialize();
|
||||
mockKernel.mockKernel->setArgBuffer(0, sizeof(cl_mem *), &clMem);
|
||||
|
||||
mockKernel.mockKernel->auxTranslationRequired = false;
|
||||
cmdQ.enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(0u, mockBuiltinKernel->takeOwnershipCalls);
|
||||
EXPECT_EQ(0u, mockBuiltinKernel->releaseOwnershipCalls);
|
||||
|
||||
mockKernel.mockKernel->auxTranslationRequired = true;
|
||||
cmdQ.enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
|
||||
EXPECT_EQ(1u, mockBuiltinKernel->takeOwnershipCalls);
|
||||
EXPECT_EQ(1u, mockBuiltinKernel->releaseOwnershipCalls);
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderCopyBufferToBufferAligned) {
|
||||
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer, *pContext, *pDevice);
|
||||
|
||||
|
@ -1740,3 +1764,46 @@ TEST_F(BuiltInTests, givenDebugFlagForceUseSourceWhenArgIsAnyThenReturnBuiltinCo
|
|||
EXPECT_NE(0u, code.resource.size());
|
||||
EXPECT_EQ(pDevice, code.targetDevice);
|
||||
}
|
||||
|
||||
using BuiltInOwnershipWrapperTests = BuiltInTests;
|
||||
|
||||
HWTEST_F(BuiltInOwnershipWrapperTests, givenBuiltinWhenConstructedThenLockAndUnlockOnDestruction) {
|
||||
MockAuxBuilInOp<FamilyType> mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
|
||||
MockContext mockContext;
|
||||
|
||||
{
|
||||
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp, &mockContext);
|
||||
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->hasOwnership());
|
||||
EXPECT_EQ(&mockContext, &mockAuxBuiltInOp.baseKernel->getContext());
|
||||
}
|
||||
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->hasOwnership());
|
||||
EXPECT_EQ(pContext, &mockAuxBuiltInOp.baseKernel->getContext());
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInOwnershipWrapperTests, givenLockWithoutParametersWhenConstructingThenLockOnlyWhenRequested) {
|
||||
MockAuxBuilInOp<FamilyType> mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
|
||||
MockContext mockContext;
|
||||
|
||||
{
|
||||
BuiltInOwnershipWrapper lock;
|
||||
lock.takeOwnership(mockAuxBuiltInOp, &mockContext);
|
||||
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->hasOwnership());
|
||||
EXPECT_EQ(&mockContext, &mockAuxBuiltInOp.baseKernel->getContext());
|
||||
}
|
||||
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->hasOwnership());
|
||||
EXPECT_EQ(pContext, &mockAuxBuiltInOp.baseKernel->getContext());
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInOwnershipWrapperTests, givenLockWithAcquiredOwnershipWhenTakeOwnershipCalledThenAbort) {
|
||||
MockAuxBuilInOp<FamilyType> mockAuxBuiltInOp1(*pBuiltIns, *pContext, *pDevice);
|
||||
MockAuxBuilInOp<FamilyType> mockAuxBuiltInOp2(*pBuiltIns, *pContext, *pDevice);
|
||||
|
||||
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp1, pContext);
|
||||
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp1, pContext), std::exception);
|
||||
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp2, pContext), std::exception);
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInOwnershipWrapperTests, givenBuiltInOwnershipWrapperWhenAskedForTypeTraitsThenDisableCopyConstructorAndOperator) {
|
||||
EXPECT_FALSE(std::is_copy_constructible<BuiltInOwnershipWrapper>::value);
|
||||
EXPECT_FALSE(std::is_copy_assignable<BuiltInOwnershipWrapper>::value);
|
||||
}
|
||||
|
|
|
@ -227,9 +227,21 @@ class MockKernel : public Kernel {
|
|||
|
||||
void makeResident(CommandStreamReceiver &commandStreamReceiver) override;
|
||||
void getResidency(std::vector<Surface *> &dst) override;
|
||||
bool takeOwnership(bool lock) const override {
|
||||
auto retVal = Kernel::takeOwnership(lock);
|
||||
takeOwnershipCalls++;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void releaseOwnership() const override {
|
||||
releaseOwnershipCalls++;
|
||||
Kernel::releaseOwnership();
|
||||
}
|
||||
|
||||
uint32_t makeResidentCalls = 0;
|
||||
uint32_t getResidencyCalls = 0;
|
||||
mutable uint32_t takeOwnershipCalls = 0;
|
||||
mutable uint32_t releaseOwnershipCalls = 0;
|
||||
|
||||
bool canKernelTransformImages = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue