feature: bindless addressing mode support

- allow bindless kernels to execute
- bindless addressing kernels are using private heaps mode
- do not differentiate bindful and bindless surface state base addresses

Related-To: NEO-7063

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2023-06-14 18:26:31 +00:00
committed by Compute-Runtime-Automation
parent 9f7374da6e
commit 313fb84fda
25 changed files with 699 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -46,5 +46,6 @@ struct DispatchKernelEncoderI {
virtual bool requiresGenerationOfLocalIdsByRuntime() const = 0;
virtual ImplicitArgs *getImplicitArgs() const = 0;
virtual void patchBindlessOffsetsInCrossThreadData(uint64_t bindlessSurfaceStateBaseOffset) const = 0;
};
} // namespace NEO

View File

@@ -121,4 +121,45 @@ bool KernelDescriptor::isBindlessAddressingKernel(const KernelDescriptor &desc)
return bindlessBuffers || bindlessImages;
}
void KernelDescriptor::initBindlessOffsetToSurfaceState() {
std::call_once(initBindlessArgsMapOnce, [this]() {
uint32_t index = 0;
for (size_t i = 0; i < this->payloadMappings.explicitArgs.size(); i++) {
switch (this->payloadMappings.explicitArgs[i].type) {
case ArgDescriptor::ArgType::ArgTImage: {
auto &argImage = this->payloadMappings.explicitArgs[i].as<ArgDescImage>();
if (isValidOffset(argImage.bindless)) {
this->bindlessArgsMap.emplace(std::pair{argImage.bindless, index++});
}
} break;
case ArgDescriptor::ArgType::ArgTPointer: {
auto &argPtr = payloadMappings.explicitArgs[i].as<ArgDescPointer>();
if (isValidOffset(argPtr.bindless)) {
this->bindlessArgsMap.emplace(std::pair{argPtr.bindless, index++});
}
} break;
default:
break;
}
}
StackVec<ArgDescPointer *, 8> implicitArgsVec({&this->payloadMappings.implicitArgs.printfSurfaceAddress,
&this->payloadMappings.implicitArgs.globalVariablesSurfaceAddress,
&this->payloadMappings.implicitArgs.globalConstantsSurfaceAddress,
&this->payloadMappings.implicitArgs.privateMemoryAddress,
&this->payloadMappings.implicitArgs.deviceSideEnqueueEventPoolSurfaceAddress,
&this->payloadMappings.implicitArgs.deviceSideEnqueueDefaultQueueSurfaceAddress,
&this->payloadMappings.implicitArgs.systemThreadSurfaceAddress,
&this->payloadMappings.implicitArgs.syncBufferAddress});
for (size_t i = 0; i < implicitArgsVec.size(); i++) {
if (isValidOffset(implicitArgsVec[i]->bindless)) {
this->bindlessArgsMap.emplace(std::pair{implicitArgsVec[i]->bindless, index++});
}
}
});
}
} // namespace NEO

View File

@@ -17,12 +17,14 @@
#include <array>
#include <cstddef>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
namespace NEO {
using StringMap = std::unordered_map<uint32_t, std::string>;
using BindlessToSurfaceStateMap = std::unordered_map<CrossThreadDataOffset, uint32_t>;
using InstructionsSegmentOffset = uint16_t;
struct KernelDescriptor {
@@ -41,6 +43,10 @@ struct KernelDescriptor {
virtual ~KernelDescriptor() = default;
void updateCrossThreadDataSize();
void initBindlessOffsetToSurfaceState();
const BindlessToSurfaceStateMap &getBindlessOffsetToSurfaceState() const {
return bindlessArgsMap;
}
struct KernelAttributes {
uint32_t slmInlineSize = 0U;
@@ -229,6 +235,9 @@ struct KernelDescriptor {
std::vector<uint8_t> generatedSsh;
std::vector<uint8_t> generatedDsh;
BindlessToSurfaceStateMap bindlessArgsMap;
std::once_flag initBindlessArgsMapOnce;
};
} // namespace NEO

View File

@@ -527,6 +527,10 @@ void populateKernelDescriptor(KernelDescriptor &dst, const PatchTokenBinary::Ker
if (DebugManager.flags.UpdateCrossThreadDataSize.get()) {
dst.updateCrossThreadDataSize();
}
if (KernelDescriptor::isBindlessAddressingKernel(dst)) {
dst.initBindlessOffsetToSurfaceState();
}
}
} // namespace NEO