4444#include < memory>
4545
4646namespace L0 {
47+ #include " level_zero/core/source/kernel/patch_with_implicit_surface.inl"
4748
4849KernelImmutableData::KernelImmutableData (L0::Device *l0device) : device(l0device) {}
4950
@@ -57,39 +58,6 @@ KernelImmutableData::~KernelImmutableData() {
5758 dynamicStateHeapTemplate.reset ();
5859}
5960
60- inline void patchWithImplicitSurface (ArrayRef<uint8_t > crossThreadData, ArrayRef<uint8_t > surfaceStateHeap,
61- uintptr_t ptrToPatchInCrossThreadData, NEO::GraphicsAllocation &allocation,
62- const NEO::ArgDescPointer &ptr, const NEO::Device &device, bool useGlobalAtomics,
63- bool implicitScaling) {
64- if (false == crossThreadData.empty ()) {
65- NEO::patchPointer (crossThreadData, ptr, ptrToPatchInCrossThreadData);
66- }
67-
68- if ((false == surfaceStateHeap.empty ()) && (NEO::isValidOffset (ptr.bindful ))) {
69- auto surfaceState = surfaceStateHeap.begin () + ptr.bindful ;
70- auto addressToPatch = allocation.getGpuAddress ();
71- size_t sizeToPatch = allocation.getUnderlyingBufferSize ();
72-
73- auto &hwInfo = device.getHardwareInfo ();
74- auto &hwHelper = NEO::HwHelper::get (hwInfo.platform .eRenderCoreFamily );
75- auto isDebuggerActive = device.isDebuggerActive () || device.getDebugger () != nullptr ;
76- NEO::EncodeSurfaceStateArgs args;
77- args.outMemory = surfaceState;
78- args.size = sizeToPatch;
79- args.graphicsAddress = addressToPatch;
80- args.gmmHelper = device.getGmmHelper ();
81- args.allocation = &allocation;
82- args.useGlobalAtomics = useGlobalAtomics;
83- args.numAvailableDevices = device.getNumGenericSubDevices ();
84- args.areMultipleSubDevicesInContext = args.numAvailableDevices > 1 ;
85- args.mocs = hwHelper.getMocsIndex (*args.gmmHelper , true , false ) << 1 ;
86- args.implicitScaling = implicitScaling;
87- args.isDebuggerActive = isDebuggerActive;
88-
89- hwHelper.encodeBufferSurfaceState (args);
90- }
91- }
92-
9361void KernelImmutableData::initialize (NEO::KernelInfo *kernelInfo, Device *device,
9462 uint32_t computeUnitsUsedForSratch,
9563 NEO::GraphicsAllocation *globalConstBuffer,
@@ -120,7 +88,7 @@ void KernelImmutableData::initialize(NEO::KernelInfo *kernelInfo, Device *device
12088
12189 this ->crossThreadDataSize = this ->kernelDescriptor ->kernelAttributes .crossThreadDataSize ;
12290
123- ArrayRef<uint8_t > crossThredDataArrayRef ;
91+ ArrayRef<uint8_t > crossThreadDataArrayRef ;
12492 if (crossThreadDataSize != 0 ) {
12593 crossThreadDataTemplate.reset (new uint8_t [crossThreadDataSize]);
12694
@@ -131,9 +99,9 @@ void KernelImmutableData::initialize(NEO::KernelInfo *kernelInfo, Device *device
13199 memset (crossThreadDataTemplate.get (), 0x00 , crossThreadDataSize);
132100 }
133101
134- crossThredDataArrayRef = ArrayRef<uint8_t >(this ->crossThreadDataTemplate .get (), this ->crossThreadDataSize );
102+ crossThreadDataArrayRef = ArrayRef<uint8_t >(this ->crossThreadDataTemplate .get (), this ->crossThreadDataSize );
135103
136- NEO::patchNonPointer<uint32_t >(crossThredDataArrayRef ,
104+ NEO::patchNonPointer<uint32_t >(crossThreadDataArrayRef ,
137105 kernelDescriptor->payloadMappings .implicitArgs .simdSize , kernelDescriptor->kernelAttributes .simdSize );
138106 }
139107
@@ -158,7 +126,7 @@ void KernelImmutableData::initialize(NEO::KernelInfo *kernelInfo, Device *device
158126 if (NEO::isValidOffset (kernelDescriptor->payloadMappings .implicitArgs .globalConstantsSurfaceAddress .stateless )) {
159127 UNRECOVERABLE_IF (nullptr == globalConstBuffer);
160128
161- patchWithImplicitSurface (crossThredDataArrayRef , surfaceStateHeapArrayRef,
129+ patchWithImplicitSurface (crossThreadDataArrayRef , surfaceStateHeapArrayRef,
162130 static_cast <uintptr_t >(globalConstBuffer->getGpuAddressToPatch ()),
163131 *globalConstBuffer, kernelDescriptor->payloadMappings .implicitArgs .globalConstantsSurfaceAddress ,
164132 *neoDevice, kernelDescriptor->kernelAttributes .flags .useGlobalAtomics , deviceImp->isImplicitScalingCapable ());
@@ -170,7 +138,7 @@ void KernelImmutableData::initialize(NEO::KernelInfo *kernelInfo, Device *device
170138 if (NEO::isValidOffset (kernelDescriptor->payloadMappings .implicitArgs .globalVariablesSurfaceAddress .stateless )) {
171139 UNRECOVERABLE_IF (globalVarBuffer == nullptr );
172140
173- patchWithImplicitSurface (crossThredDataArrayRef , surfaceStateHeapArrayRef,
141+ patchWithImplicitSurface (crossThreadDataArrayRef , surfaceStateHeapArrayRef,
174142 static_cast <uintptr_t >(globalVarBuffer->getGpuAddressToPatch ()),
175143 *globalVarBuffer, kernelDescriptor->payloadMappings .implicitArgs .globalVariablesSurfaceAddress ,
176144 *neoDevice, kernelDescriptor->kernelAttributes .flags .useGlobalAtomics , deviceImp->isImplicitScalingCapable ());
@@ -785,10 +753,10 @@ void KernelImp::patchCrossthreadDataWithPrivateAllocation(NEO::GraphicsAllocatio
785753 auto &kernelAttributes = kernelImmData->getDescriptor ().kernelAttributes ;
786754 auto device = module ->getDevice ();
787755
788- ArrayRef<uint8_t > crossThredDataArrayRef = ArrayRef<uint8_t >(this ->crossThreadData .get (), this ->crossThreadDataSize );
756+ ArrayRef<uint8_t > crossThreadDataArrayRef = ArrayRef<uint8_t >(this ->crossThreadData .get (), this ->crossThreadDataSize );
789757 ArrayRef<uint8_t > surfaceStateHeapArrayRef = ArrayRef<uint8_t >(this ->surfaceStateHeapData .get (), this ->surfaceStateHeapDataSize );
790758
791- patchWithImplicitSurface (crossThredDataArrayRef , surfaceStateHeapArrayRef,
759+ patchWithImplicitSurface (crossThreadDataArrayRef , surfaceStateHeapArrayRef,
792760 static_cast <uintptr_t >(privateAllocation->getGpuAddressToPatch ()),
793761 *privateAllocation, kernelImmData->getDescriptor ().payloadMappings .implicitArgs .privateMemoryAddress ,
794762 *device->getNEODevice (), kernelAttributes.flags .useGlobalAtomics , device->isImplicitScalingCapable ());
0 commit comments