1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/source/kernel/kernel.h"
#include "opencl/source/program/block_kernel_manager.h"
#include "opencl/source/program/printf_handler.h"
namespace NEO {
template <bool mockable>
void Kernel::patchReflectionSurface(DeviceQueue *devQueue, PrintfHandler *printfHandler) {
void *reflectionSurface = kernelReflectionSurface->getUnderlyingBuffer();
BlockKernelManager *blockManager = program->getBlockKernelManager();
uint32_t blockCount = static_cast<uint32_t>(blockManager->getCount());
for (uint32_t i = 0; i < blockCount; i++) {
const KernelInfo *pBlockInfo = blockManager->getBlockKernelInfo(i);
// clang-format off
uint64_t defaultQueueOffset = pBlockInfo->patchInfo.pAllocateStatelessDefaultDeviceQueueSurface ?
pBlockInfo->patchInfo.pAllocateStatelessDefaultDeviceQueueSurface->DataParamOffset : ReflectionSurfaceHelper::undefinedOffset;
uint64_t eventPoolOffset = pBlockInfo->patchInfo.pAllocateStatelessEventPoolSurface ?
pBlockInfo->patchInfo.pAllocateStatelessEventPoolSurface->DataParamOffset : ReflectionSurfaceHelper::undefinedOffset;
uint64_t deviceQueueOffset = ReflectionSurfaceHelper::undefinedOffset;
uint32_t defaultQueueSize = pBlockInfo->patchInfo.pAllocateStatelessDefaultDeviceQueueSurface ?
pBlockInfo->patchInfo.pAllocateStatelessDefaultDeviceQueueSurface->DataParamSize : 0;
uint32_t eventPoolSize = pBlockInfo->patchInfo.pAllocateStatelessEventPoolSurface ?
pBlockInfo->patchInfo.pAllocateStatelessEventPoolSurface->DataParamSize : 0;
uint32_t deviceQueueSize = 0;
uint64_t printfBufferOffset = pBlockInfo->patchInfo.pAllocateStatelessPrintfSurface ?
pBlockInfo->patchInfo.pAllocateStatelessPrintfSurface->DataParamOffset : ReflectionSurfaceHelper::undefinedOffset;
uint32_t printfBufferPatchSize = pBlockInfo->patchInfo.pAllocateStatelessPrintfSurface ?
pBlockInfo->patchInfo.pAllocateStatelessPrintfSurface->DataParamSize : 0;
uint64_t printfGpuAddress = 0;
// clang-format on
uint64_t privateSurfaceOffset = ReflectionSurfaceHelper::undefinedOffset;
uint32_t privateSurfacePatchSize = 0;
uint64_t privateSurfaceGpuAddress = 0;
auto privateSurface = blockManager->getPrivateSurface(i);
UNRECOVERABLE_IF(pBlockInfo->patchInfo.pAllocateStatelessPrivateSurface != nullptr && pBlockInfo->patchInfo.pAllocateStatelessPrivateSurface->PerThreadPrivateMemorySize && privateSurface == nullptr);
if (privateSurface) {
privateSurfaceOffset = pBlockInfo->patchInfo.pAllocateStatelessPrivateSurface->DataParamOffset;
privateSurfacePatchSize = pBlockInfo->patchInfo.pAllocateStatelessPrivateSurface->DataParamSize;
privateSurfaceGpuAddress = privateSurface->getGpuAddressToPatch();
}
if (printfHandler) {
GraphicsAllocation *printfSurface = printfHandler->getSurface();
if (printfSurface)
printfGpuAddress = printfSurface->getGpuAddress();
}
for (const auto &arg : pBlockInfo->kernelArgInfo) {
if (arg.isDeviceQueue) {
deviceQueueOffset = arg.kernelArgPatchInfoVector[0].crossthreadOffset;
deviceQueueSize = arg.kernelArgPatchInfoVector[0].size;
break;
}
}
ReflectionSurfaceHelper::patchBlocksCurbe<mockable>(reflectionSurface, i,
defaultQueueOffset, defaultQueueSize, devQueue->getQueueBuffer()->getGpuAddress(),
eventPoolOffset, eventPoolSize, devQueue->getEventPoolBuffer()->getGpuAddress(),
deviceQueueOffset, deviceQueueSize, devQueue->getQueueBuffer()->getGpuAddress(),
printfBufferOffset, printfBufferPatchSize, printfGpuAddress,
privateSurfaceOffset, privateSurfacePatchSize, privateSurfaceGpuAddress);
}
ReflectionSurfaceHelper::setParentImageParams(reflectionSurface, this->kernelArguments, this->kernelInfo);
ReflectionSurfaceHelper::setParentSamplerParams(reflectionSurface, this->kernelArguments, this->kernelInfo);
}
} // namespace NEO
|