SWDEV-257789 - Initial change to skip kernel arg copy

The optimization is controlled with ROCR_SKIP_KERNEL_ARG_COPY.
This is initial check-in for experiments. Extra changes are
necessary for full support:
- handle graph capture with the original sysmem alloc
- avoid memobject references, otherwise there is a race condition with
reusage of the arg buffer
- Remove arg setup from hip

Change-Id: Ib0af710f93e79834711fa4049a7c66093711e68b
Этот коммит содержится в:
German Andryeyev committed 2021-10-28 20:35:35 -04:00
1 родитель 530283e12a
Коммит 7e12cf6318
7 files changed
+57 -29

No files matched your search

+2 -1
Просмотреть файл
@@ -633,7 +633,8 @@ int32_t NDRangeKernelCommand::captureAndValidate() {
int32_t error;
uint64_t lclMemSize = kernel().getDeviceKernel(device)->workGroupInfo()->localMemSize_;
parameters_ = kernel().parameters().capture(device, sharedMemBytes_ + lclMemSize, &error);
parameters_ = kernel().parameters().capture(*queue()->vdev(),
sharedMemBytes_ + lclMemSize, &error);
return error;
}
+13 -4
Просмотреть файл
@@ -154,14 +154,21 @@ void KernelParameters::set(size_t index, size_t size, const void* value, bool sv
desc.info_.defined_ = true;
}
address KernelParameters::capture(const Device& device, uint64_t lclMemSize, int32_t* error) {
address KernelParameters::capture(device::VirtualDevice& vDev, uint64_t lclMemSize, int32_t* error) {
const Device& device = vDev.device();
*error = CL_SUCCESS;
//! Information about which arguments are SVM pointers is stored after
// the actual parameters, but only if the device has any SVM capability
const size_t execInfoSize = getNumberOfSvmPtr() * sizeof(void*);
address mem = reinterpret_cast<address>(AlignedMemory::allocate(
totalSize_ + execInfoSize, PARAMETERS_MIN_ALIGNMENT));
address mem = vDev.allocKernelArguments(totalSize_ + execInfoSize, 128);
if (mem == nullptr) {
mem = reinterpret_cast<address>(AlignedMemory::allocate(totalSize_ + execInfoSize,
PARAMETERS_MIN_ALIGNMENT));
} else {
deviceKernelArgs_ = true;
}
if (mem != nullptr) {
::memcpy(mem, values_, totalSize_);
@@ -278,7 +285,9 @@ void KernelParameters::release(address mem, const amd::Device& device) const {
}
}
AlignedMemory::deallocate(mem);
if (!deviceKernelArgs()) {
AlignedMemory::deallocate(mem);
}
}
KernelSignature::KernelSignature(const std::vector<KernelParameterDescriptor>& params,
+13 -7
Просмотреть файл
@@ -137,10 +137,11 @@ class KernelParameters : protected HeapObject {
uint32_t totalSize_; //!< The total size of all captured parameters
struct {
uint32_t validated_ : 1; //!< True if all parameters are defined.
uint32_t execNewVcop_ : 1; //!< special new VCOP for kernel execution
uint32_t execPfpaVcop_ : 1; //!< special PFPA VCOP for kernel execution
uint32_t unused : 29; //!< unused
uint32_t validated_ : 1; //!< True if all parameters are defined.
uint32_t execNewVcop_ : 1; //!< special new VCOP for kernel execution
uint32_t execPfpaVcop_ : 1; //!< special PFPA VCOP for kernel execution
uint32_t deviceKernelArgs_:1; //!< Kernel arguments allocated on device
uint32_t unused : 28; //!< unused
};
public:
@@ -154,7 +155,8 @@ class KernelParameters : protected HeapObject {
queueObjects_(nullptr),
validated_(0),
execNewVcop_(0),
execPfpaVcop_(0) {
execPfpaVcop_(0),
deviceKernelArgs_(false) {
totalSize_ = signature.paramsSize() + (signature.numMemories() +
signature.numSamplers() + signature.numQueues()) * sizeof(void*);
values_ = reinterpret_cast<address>(this) + alignUp(sizeof(KernelParameters), 16);
@@ -179,7 +181,8 @@ class KernelParameters : protected HeapObject {
totalSize_(rhs.totalSize_),
validated_(rhs.validated_),
execNewVcop_(rhs.execNewVcop_),
execPfpaVcop_(rhs.execPfpaVcop_) {
execPfpaVcop_(rhs.execPfpaVcop_),
deviceKernelArgs_(false) {
values_ = reinterpret_cast<address>(this) + alignUp(sizeof(KernelParameters), 16);
memoryObjOffset_ = signature_.paramsSize();
memoryObjects_ = reinterpret_cast<amd::Memory**>(values_ + memoryObjOffset_);
@@ -210,7 +213,7 @@ class KernelParameters : protected HeapObject {
size_t localMemSize(size_t minDataTypeAlignment) const;
//! Capture the state of the parameters and return the stack base pointer.
address capture(const Device& device, uint64_t lclMemSize, int32_t* error);
address capture(device::VirtualDevice& vDev, uint64_t lclMemSize, int32_t* error);
//! Release the captured state of the parameters.
void release(address parameters, const amd::Device& device) const;
@@ -278,6 +281,9 @@ class KernelParameters : protected HeapObject {
//! get the PFPA VCOP in the execInfo container
bool getExecPfpaVcop() const { return (execPfpaVcop_ == 1); }
//! Returns true if arguemnts were allocated on device
bool deviceKernelArgs() const { return (deviceKernelArgs_ == 1); }
};
/*! \brief Encapsulates a __kernel function and the argument values