[2/n] Unified Shared Memory

- Add kernel flags specifying indirect usage of device allocations.
- make device usm allocation resident when kernel requires this

Related-To: NEO-3148

Change-Id: I689347a0ea9b0f84c83f7883ca2381be63c61af9
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
Mrozek, Michal
2019-06-13 15:49:35 +02:00
committed by sys_ocldev
parent 0894601edc
commit 8e969684f1
5 changed files with 56 additions and 2 deletions

View File

@ -34,6 +34,7 @@
#include "runtime/mem_obj/pipe.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/memory_manager/surface.h"
#include "runtime/memory_manager/svm_memory_manager.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/platform/platform.h"
#include "runtime/program/kernel_info.h"
@ -940,6 +941,12 @@ void Kernel::clearKernelExecInfo() {
svmAllocationsRequireCacheFlush = false;
}
void Kernel::setUnifiedMemoryProperty(cl_kernel_exec_info infoType, bool infoValue) {
if (infoType == CL_KERNEL_EXEC_INFO_INDIRECT_DEVICE_ACCESS_INTEL) {
this->unifiedMemoryControls.indirectDeviceAllocationsAllowed = infoValue;
}
}
inline void Kernel::makeArgsResident(CommandStreamReceiver &commandStreamReceiver) {
auto numArgs = kernelInfo.kernelArgInfo.size();
@ -989,6 +996,10 @@ void Kernel::makeResident(CommandStreamReceiver &commandStreamReceiver) {
}
gtpinNotifyMakeResident(this, &commandStreamReceiver);
if (unifiedMemoryControls.indirectDeviceAllocationsAllowed) {
this->getContext().getSVMAllocsManager()->makeInternalAllocationsResident(commandStreamReceiver);
}
}
void Kernel::getResidency(std::vector<Surface *> &dst) {

View File

@ -61,6 +61,10 @@ class Kernel : public BaseObject<_cl_kernel> {
bool isUncacheable = false;
};
struct UnifiedMemoryControls {
bool indirectDeviceAllocationsAllowed = false;
};
typedef int32_t (Kernel::*KernelArgHandler)(uint32_t argIndex,
size_t argSize,
const void *argVal);
@ -388,6 +392,7 @@ class Kernel : public BaseObject<_cl_kernel> {
void setAuxTranslationFlag(bool auxTranslationFlag) {
this->auxTranslationKernel = auxTranslationFlag;
}
void setUnifiedMemoryProperty(cl_kernel_exec_info infoType, bool infoValue);
protected:
struct ObjectCounts {
@ -457,8 +462,8 @@ class Kernel : public BaseObject<_cl_kernel> {
uint64_t privateMemoryCurbeOffset, uint32_t privateMemoryPatchSize, uint64_t privateMemoryGpuAddress);
};
protected:
void makeArgsResident(CommandStreamReceiver &commandStreamReceiver);
void
makeArgsResident(CommandStreamReceiver &commandStreamReceiver);
void *patchBufferOffset(const KernelArgInfo &argInfo, void *svmPtr, GraphicsAllocation *svmAlloc);
@ -515,5 +520,6 @@ class Kernel : public BaseObject<_cl_kernel> {
bool specialPipelineSelectMode = false;
bool svmAllocationsRequireCacheFlush = false;
std::vector<GraphicsAllocation *> kernelArgRequiresCacheFlush;
UnifiedMemoryControls unifiedMemoryControls;
};
} // namespace NEO