1616#include " shared/source/helpers/compiler_product_helper.h"
1717#include " shared/source/helpers/debug_helpers.h"
1818#include " shared/source/helpers/file_io.h"
19+ #include " shared/source/helpers/gfx_core_helper.h"
1920#include " shared/source/helpers/hw_info.h"
2021#include " shared/source/helpers/ptr_math.h"
2122#include " shared/source/helpers/string.h"
@@ -109,14 +110,16 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, size_
109110 exportedFunctionsKernelId = static_cast <size_t >(linkerInput->getExportedFunctionsSegmentId ());
110111 // Exported functions reside in instruction heap of one of kernels
111112 auto exportedFunctionHeapId = linkerInput->getExportedFunctionsSegmentId ();
112- buildInfos[rootDeviceIndex].exportedFunctionsSurface = kernelInfoArray[exportedFunctionHeapId]->getGraphicsAllocation ();
113+ buildInfos[rootDeviceIndex].exportedFunctionsSurface = kernelInfoArray[exportedFunctionHeapId]->getIsaGraphicsAllocation ();
114+ auto offsetInParentAllocation = kernelInfoArray[exportedFunctionHeapId]->getIsaOffsetInParentAllocation ();
115+
113116 auto &compilerProductHelper = pDevice->getCompilerProductHelper ();
114117 if (compilerProductHelper.isHeaplessModeEnabled (pDevice->getHardwareInfo ())) {
115- exportedFunctions.gpuAddress = static_cast <uintptr_t >(buildInfos[rootDeviceIndex].exportedFunctionsSurface ->getGpuAddress ());
118+ exportedFunctions.gpuAddress = static_cast <uintptr_t >(buildInfos[rootDeviceIndex].exportedFunctionsSurface ->getGpuAddress () + offsetInParentAllocation );
116119 } else {
117- exportedFunctions.gpuAddress = static_cast <uintptr_t >(buildInfos[rootDeviceIndex].exportedFunctionsSurface ->getGpuAddressToPatch ());
120+ exportedFunctions.gpuAddress = static_cast <uintptr_t >(buildInfos[rootDeviceIndex].exportedFunctionsSurface ->getGpuAddressToPatch () + offsetInParentAllocation );
118121 }
119- exportedFunctions.segmentSize = buildInfos[rootDeviceIndex]. exportedFunctionsSurface -> getUnderlyingBufferSize ();
122+ exportedFunctions.segmentSize = kernelInfoArray[exportedFunctionHeapId]-> getIsaSize ();
120123 }
121124 Linker::PatchableSegments isaSegmentsForPatching;
122125 std::vector<std::vector<char >> patchedIsaTempStorage;
@@ -128,8 +131,8 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, size_
128131 auto &kernHeapInfo = kernelInfo->heapInfo ;
129132 const char *originalIsa = reinterpret_cast <const char *>(kernHeapInfo.pKernelHeap );
130133 patchedIsaTempStorage.push_back (std::vector<char >(originalIsa, originalIsa + kernHeapInfo.kernelHeapSize ));
131- DEBUG_BREAK_IF (nullptr == kernelInfo->getGraphicsAllocation ());
132- isaSegmentsForPatching.push_back (Linker::PatchableSegment{patchedIsaTempStorage.rbegin ()->data (), static_cast <uintptr_t >(kernelInfo->getGraphicsAllocation ()->getGpuAddressToPatch ()), kernHeapInfo.kernelHeapSize });
134+ DEBUG_BREAK_IF (nullptr == kernelInfo->getIsaGraphicsAllocation ());
135+ isaSegmentsForPatching.push_back (Linker::PatchableSegment{patchedIsaTempStorage.rbegin ()->data (), static_cast <uintptr_t >(kernelInfo->getIsaGraphicsAllocation ()->getGpuAddressToPatch () + kernelInfo-> getIsaOffsetInParentAllocation ()), kernHeapInfo.kernelHeapSize });
133136 kernelDescriptors.push_back (&kernelInfo->kernelDescriptor );
134137 }
135138 }
@@ -151,16 +154,8 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, size_
151154 updateBuildLog (pDevice->getRootDeviceIndex (), error.c_str (), error.size ());
152155 return CL_INVALID_BINARY;
153156 } else if (linkerInput->getTraits ().requiresPatchingOfInstructionSegments ) {
154- for (auto kernelId = 0u ; kernelId < kernelInfoArray.size (); kernelId++) {
155- const auto &kernelInfo = kernelInfoArray[kernelId];
156- auto &kernHeapInfo = kernelInfo->heapInfo ;
157- auto segmentId = &kernelInfo - &kernelInfoArray[0 ];
158- auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment ();
159- const auto &productHelper = pDevice->getProductHelper ();
160- MemoryTransferHelper::transferMemoryToAllocation (productHelper.isBlitCopyRequiredForLocalMemory (rootDeviceEnvironment, *kernelInfo->getGraphicsAllocation ()),
161- *pDevice, kernelInfo->getGraphicsAllocation (), 0 , isaSegmentsForPatching[segmentId].hostPointer ,
162- static_cast <size_t >(kernHeapInfo.kernelHeapSize ));
163- }
157+ [[maybe_unused]] auto success = transferIsaSegmentsToAllocation (pDevice, kernelInfoArray, &isaSegmentsForPatching, rootDeviceIndex);
158+ DEBUG_BREAK_IF (!success);
164159 }
165160 DBG_LOG (PrintRelocations, NEO::constructRelocationsDebugMessage (this ->getSymbols (pDevice->getRootDeviceIndex ())));
166161 return CL_SUCCESS;
@@ -328,17 +323,9 @@ cl_int Program::processProgramInfo(ProgramInfo &src, const ClDevice &clDevice) {
328323 }
329324 buildInfos[rootDeviceIndex].kernelMiscInfoPos = src.kernelMiscInfoPos ;
330325
331- for (auto &kernelInfo : kernelInfoArray) {
332- cl_int retVal = CL_SUCCESS;
333- if (kernelInfo->heapInfo .kernelHeapSize ) {
334- retVal = kernelInfo->createKernelAllocation (clDevice.getDevice (), isBuiltIn) ? CL_SUCCESS : CL_OUT_OF_HOST_MEMORY;
335- }
336-
337- if (retVal != CL_SUCCESS) {
338- return retVal;
339- }
340-
341- kernelInfo->apply (deviceInfoConstants);
326+ if (auto retVal = setIsaGraphicsAllocations (clDevice.getDevice (), kernelInfoArray, deviceInfoConstants, rootDeviceIndex);
327+ retVal != CL_SUCCESS) {
328+ return retVal;
342329 }
343330
344331 indirectDetectionVersion = src.indirectDetectionVersion ;
@@ -383,8 +370,16 @@ Zebin::Debug::Segments Program::getZebinSegments(uint32_t rootDeviceIndex) {
383370 buildInfos[rootDeviceIndex].constStringSectionData .size };
384371 std::vector<NEO::Zebin::Debug::Segments::KernelNameIsaTupleT> kernels;
385372 for (const auto &kernelInfo : buildInfos[rootDeviceIndex].kernelInfoArray ) {
373+ NEO::Zebin::Debug::Segments::Segment segment;
374+
375+ if (kernelInfo->getIsaParentAllocation ()) {
376+ segment.address = static_cast <uintptr_t >(kernelInfo->getIsaGraphicsAllocation ()->getGpuAddress () + kernelInfo->getIsaOffsetInParentAllocation ());
377+ segment.size = kernelInfo->getIsaSubAllocationSize ();
378+ } else {
379+ segment.address = static_cast <uintptr_t >(kernelInfo->getIsaGraphicsAllocation ()->getGpuAddress ());
380+ segment.size = kernelInfo->getIsaGraphicsAllocation ()->getUnderlyingBufferSize ();
381+ }
386382
387- NEO::Zebin::Debug::Segments::Segment segment = {static_cast <uintptr_t >(kernelInfo->getGraphicsAllocation ()->getGpuAddress ()), kernelInfo->getGraphicsAllocation ()->getUnderlyingBufferSize ()};
388383 kernels.push_back ({kernelInfo->kernelDescriptor .kernelMetadata .kernelName , segment});
389384 }
390385 return Zebin::Debug::Segments (getGlobalSurface (rootDeviceIndex), getConstantSurface (rootDeviceIndex), strings, kernels);
0 commit comments