refactor(opencl/gtpin): Extend OCL/GTPin interface for stateless kernels

Remove blocking condition disallowing GTPin instrumentation using OCL interface
for stateless kernels (where SSH size == 0). It is required in order to
reintroduce support for GTPin on platforms supporting stateless
addressing model only.
- Always allow for adding surface state for GTPin use, even if kernel
SSH size == 0,
- Correct addSurfaceState function logic
- Remove and/or modify GTPin unit tests based on previous approach
- Wrap logic for pushing BT and SSH into separate function
- Minor code refactor; remove not needed test function

Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
Kacper Nowak
2023-03-07 22:43:53 +00:00
committed by Compute-Runtime-Automation
parent 3c2c2ee0c4
commit bac3c93e45
9 changed files with 81 additions and 401 deletions

View File

@@ -74,10 +74,7 @@ void gtpinNotifyKernelCreate(cl_kernel kernel) {
// Enlarge local copy of SSH by 1 SS
auto &gtpinHelper = device->getGTPinGfxCoreHelper();
if (!gtpinHelper.addSurfaceState(pKernel)) {
// Kernel with no SSH or Kernel EM, not supported
return;
}
gtpinHelper.addSurfaceState(pKernel);
if (pKernel->isKernelHeapSubstituted()) {
// ISA for this kernel was already substituted
return;
@@ -121,10 +118,6 @@ void gtpinNotifyKernelSubmit(cl_kernel kernel, void *pCmdQueue) {
auto rootDeviceIndex = device.getRootDeviceIndex();
auto pMultiDeviceKernel = castToObjectOrAbort<MultiDeviceKernel>(kernel);
auto pKernel = pMultiDeviceKernel->getKernel(rootDeviceIndex);
if (pKernel->getSurfaceStateHeapSize() == 0) {
// Kernel with no SSH, not supported
return;
}
Context *pContext = &(pKernel->getContext());
cl_context context = (cl_context)pContext;
uint64_t kernelId = pKernel->getKernelId();

View File

@@ -25,7 +25,7 @@ class GTPinGfxCoreHelper {
public:
static std::unique_ptr<GTPinGfxCoreHelper> create(GFXCORE_FAMILY gfxCore);
virtual uint32_t getGenVersion() const = 0;
virtual bool addSurfaceState(Kernel *pKernel) const = 0;
virtual void addSurfaceState(Kernel *pKernel) const = 0;
virtual void *getSurfaceState(Kernel *pKernel, size_t bti) const = 0;
virtual bool canUseSharedAllocation(const HardwareInfo &hwInfo) const = 0;
@@ -43,7 +43,7 @@ class GTPinGfxCoreHelperHw : public GTPinGfxCoreHelper {
return gtpinHelper;
}
uint32_t getGenVersion() const override;
bool addSurfaceState(Kernel *pKernel) const override;
void addSurfaceState(Kernel *pKernel) const override;
void *getSurfaceState(Kernel *pKernel, size_t bti) const override;
bool canUseSharedAllocation(const HardwareInfo &hwInfo) const override;

View File

@@ -14,19 +14,18 @@
namespace NEO {
template <typename GfxFamily>
bool GTPinGfxCoreHelperHw<GfxFamily>::addSurfaceState(Kernel *pKernel) const {
void GTPinGfxCoreHelperHw<GfxFamily>::addSurfaceState(Kernel *pKernel) const {
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
using BINDING_TABLE_STATE = typename GfxFamily::BINDING_TABLE_STATE;
size_t sshSize = pKernel->getSurfaceStateHeapSize();
if (sshSize == 0) {
// Kernels which do not use SSH or use Execution Model are not supported (yet)
return false;
}
size_t ssSize = sizeof(RENDER_SURFACE_STATE);
size_t btsSize = sizeof(BINDING_TABLE_STATE);
size_t sizeToEnlarge = ssSize + btsSize;
size_t currBTOffset = pKernel->getBindingTableOffset();
size_t currBTOffset = 0u;
if (isValidOffset<SurfaceStateHeapOffset>(static_cast<SurfaceStateHeapOffset>(pKernel->getBindingTableOffset()))) {
currBTOffset = pKernel->getBindingTableOffset();
}
size_t currSurfaceStateSize = currBTOffset;
char *pSsh = static_cast<char *>(pKernel->getSurfaceStateHeap());
char *pNewSsh = new char[sshSize + sizeToEnlarge];
@@ -40,7 +39,6 @@ bool GTPinGfxCoreHelperHw<GfxFamily>::addSurfaceState(Kernel *pKernel) const {
*pNewBTS = GfxFamily::cmdInitBindingTableState;
pNewBTS->setSurfaceStatePointer((uint64_t)currBTOffset);
pKernel->resizeSurfaceStateHeap(pNewSsh, sshSize + sizeToEnlarge, currBTCount + 1, newSurfaceStateSize);
return true;
}
template <typename GfxFamily>

View File

@@ -122,5 +122,6 @@ struct HardwareCommandsHelper : public PerThreadDataHelper {
static bool inlineDataProgrammingRequired(const Kernel &kernel);
static bool kernelUsesLocalIds(const Kernel &kernel);
static size_t checkForAdditionalBTAndSetBTPointer(IndirectHeap &ssh, const Kernel &kernel);
};
} // namespace NEO

View File

@@ -228,9 +228,7 @@ size_t HardwareCommandsHelper<GfxFamily>::sendIndirectState(
ssh.align(BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE);
auto dstBindingTablePointer = EncodeSurfaceState<GfxFamily>::pushBindingTableAndSurfaceStates(ssh, kernelInfo.kernelDescriptor.payloadMappings.bindingTable.numEntries,
kernel.getSurfaceStateHeap(), kernel.getSurfaceStateHeapSize(),
kernel.getNumberOfBindingTableStates(), kernel.getBindingTableOffset());
size_t dstBindingTablePointer = HardwareCommandsHelper<GfxFamily>::checkForAdditionalBTAndSetBTPointer(ssh, kernel);
// Copy our sampler state if it exists
const auto &samplerTable = kernelInfo.kernelDescriptor.payloadMappings.samplerTable;
@@ -326,4 +324,20 @@ bool HardwareCommandsHelper<GfxFamily>::kernelUsesLocalIds(const Kernel &kernel)
return kernel.getKernelInfo().kernelDescriptor.kernelAttributes.numLocalIdChannels > 0;
}
template <typename GfxFamily>
size_t HardwareCommandsHelper<GfxFamily>::checkForAdditionalBTAndSetBTPointer(IndirectHeap &ssh, const Kernel &kernel) {
size_t dstBindingTablePointer{0u};
const auto &kernelInfo = kernel.getKernelInfo();
if (isGTPinInitialized && 0u == kernelInfo.kernelDescriptor.payloadMappings.bindingTable.numEntries) {
dstBindingTablePointer = EncodeSurfaceState<GfxFamily>::pushBindingTableAndSurfaceStates(ssh, 1u,
kernel.getSurfaceStateHeap(), kernel.getSurfaceStateHeapSize(),
kernel.getNumberOfBindingTableStates(), kernel.getBindingTableOffset());
} else {
dstBindingTablePointer = EncodeSurfaceState<GfxFamily>::pushBindingTableAndSurfaceStates(ssh, kernelInfo.kernelDescriptor.payloadMappings.bindingTable.numEntries,
kernel.getSurfaceStateHeap(), kernel.getSurfaceStateHeapSize(),
kernel.getNumberOfBindingTableStates(), kernel.getBindingTableOffset());
}
return dstBindingTablePointer;
}
} // namespace NEO