P4 to Git Change 1368703 by todli@todli-win-opencl-kv1 on 2017/02/02 18:12:31
SWDEV-96241 - Support SDI on PAL (runtime changes)
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#10 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#23 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsettings.cpp#16 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#42 edit
[ROCm/clr commit: 1eda218988]
This commit is contained in:
@@ -168,7 +168,6 @@ Memory::create(
|
|||||||
if (result) {
|
if (result) {
|
||||||
switch (memoryType()) {
|
switch (memoryType()) {
|
||||||
case Resource::Pinned:
|
case Resource::Pinned:
|
||||||
case Resource::ExternalPhysical:
|
|
||||||
// Marks memory object for direct GPU access to the host memory
|
// Marks memory object for direct GPU access to the host memory
|
||||||
flags_ |= HostMemoryDirectAccess;
|
flags_ |= HostMemoryDirectAccess;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -399,9 +399,9 @@ Resource::memTypeToHeap(Pal::GpuMemoryCreateInfo* createInfo)
|
|||||||
createInfo->heaps[0] = Pal::GpuHeapGartCacheable;
|
createInfo->heaps[0] = Pal::GpuHeapGartCacheable;
|
||||||
desc_.cardMemory_ = false;
|
desc_.cardMemory_ = false;
|
||||||
break;
|
break;
|
||||||
case Shader:
|
|
||||||
case BusAddressable:
|
|
||||||
case ExternalPhysical:
|
case ExternalPhysical:
|
||||||
|
desc_.cardMemory_ = false;
|
||||||
|
case Shader:
|
||||||
// Fall through to process the memory allocation ...
|
// Fall through to process the memory allocation ...
|
||||||
case Local:
|
case Local:
|
||||||
createInfo->heapCount = 2;
|
createInfo->heapCount = 2;
|
||||||
@@ -1075,6 +1075,18 @@ Resource::create(MemoryType memType, CreateParams* params)
|
|||||||
createInfo.alignment = MaxGpuAlignment;
|
createInfo.alignment = MaxGpuAlignment;
|
||||||
createInfo.vaRange = Pal::VaRange::Default;
|
createInfo.vaRange = Pal::VaRange::Default;
|
||||||
createInfo.priority = Pal::GpuMemPriority::Normal;
|
createInfo.priority = Pal::GpuMemPriority::Normal;
|
||||||
|
|
||||||
|
if (memoryType() == ExternalPhysical){
|
||||||
|
cl_bus_address_amd bus_address =
|
||||||
|
(reinterpret_cast<amd::Buffer*>(params->owner_))->busAddress();
|
||||||
|
createInfo.surfaceBusAddr = bus_address.surface_bus_address;
|
||||||
|
createInfo.markerBusAddr = bus_address.marker_bus_address;
|
||||||
|
createInfo.flags.sdiExternal = true;
|
||||||
|
}
|
||||||
|
else if (memoryType() == BusAddressable){
|
||||||
|
createInfo.flags.busAddressable = true;
|
||||||
|
}
|
||||||
|
|
||||||
memTypeToHeap(&createInfo);
|
memTypeToHeap(&createInfo);
|
||||||
// createInfo.priority;
|
// createInfo.priority;
|
||||||
memRef_ = dev().resourceCache().findGpuMemory(&desc_, createInfo.size, createInfo.alignment);
|
memRef_ = dev().resourceCache().findGpuMemory(&desc_, createInfo.size, createInfo.alignment);
|
||||||
|
|||||||
@@ -353,13 +353,12 @@ Settings::create(
|
|||||||
}
|
}
|
||||||
#endif // !defined(WITH_LIGHTNING_COMPILER)
|
#endif // !defined(WITH_LIGHTNING_COMPILER)
|
||||||
|
|
||||||
//! @todo
|
if (palProp.gpuMemoryProperties.busAddressableMemSize > 0) {
|
||||||
/*
|
|
||||||
if (calAttr.totalSDIHeap > 0) {
|
|
||||||
//Enable bus addressable memory extension
|
//Enable bus addressable memory extension
|
||||||
enableExtension(ClAMDBusAddressableMemory);
|
enableExtension(ClAMDBusAddressableMemory);
|
||||||
}
|
}
|
||||||
|
//! @todo
|
||||||
|
/*
|
||||||
if (calAttr.longIdleDetect) {
|
if (calAttr.longIdleDetect) {
|
||||||
// KMD is unable to detect if we map the visible memory for CPU access, so
|
// KMD is unable to detect if we map the visible memory for CPU access, so
|
||||||
// accessing persistent staged buffer may fail if LongIdleDetct is enabled.
|
// accessing persistent staged buffer may fail if LongIdleDetct is enabled.
|
||||||
|
|||||||
@@ -1264,6 +1264,7 @@ VirtualGPU::copyMemory(cl_command_type type
|
|||||||
|
|
||||||
// Check if HW can be used for memory copy
|
// Check if HW can be used for memory copy
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case CL_COMMAND_MAKE_BUFFERS_RESIDENT_AMD:
|
||||||
case CL_COMMAND_SVM_MEMCPY:
|
case CL_COMMAND_SVM_MEMCPY:
|
||||||
case CL_COMMAND_COPY_BUFFER: {
|
case CL_COMMAND_COPY_BUFFER: {
|
||||||
amd::Coord3D realSrcOrigin(srcOrigin[0]);
|
amd::Coord3D realSrcOrigin(srcOrigin[0]);
|
||||||
@@ -2731,28 +2732,28 @@ VirtualGPU::submitSignal(amd::SignalCommand & vcmd)
|
|||||||
{
|
{
|
||||||
amd::ScopedLock lock(execution());
|
amd::ScopedLock lock(execution());
|
||||||
profilingBegin(vcmd);
|
profilingBegin(vcmd);
|
||||||
pal::Memory* gpuMemory = dev().getGpuMemory(&vcmd.memory());
|
pal::Memory* pGpuMemory = dev().getGpuMemory(&vcmd.memory());
|
||||||
Unimplemented();
|
|
||||||
/*
|
GpuEvent gpuEvent;
|
||||||
|
eventBegin(MainEngine);
|
||||||
|
|
||||||
|
uint32_t value = vcmd.markerValue();
|
||||||
|
uint32_t size = vcmd.memory().getSize();
|
||||||
|
|
||||||
|
addVmMemory(pGpuMemory);
|
||||||
|
|
||||||
if (vcmd.type() == CL_COMMAND_WAIT_SIGNAL_AMD) {
|
if (vcmd.type() == CL_COMMAND_WAIT_SIGNAL_AMD) {
|
||||||
uint64_t surfAddr = gpuMemory->iMem()->getPhysicalAddress(cs());
|
iCmd()->CmdWaitMemoryValue(*(pGpuMemory->iMem()), size, value, 0xFFFFFFFF, Pal::CompareFunc::GreaterEqual);
|
||||||
uint64_t markerAddr = gpuMemory->iMem()->getMarkerAddress(cs());
|
|
||||||
uint64_t markerOffset = markerAddr - surfAddr;
|
|
||||||
cs()->p2pMarkerOp(gpuMemory->iMem(), vcmd.markerValue(),
|
|
||||||
markerOffset, false);
|
|
||||||
}
|
}
|
||||||
else if (vcmd.type() == CL_COMMAND_WRITE_SIGNAL_AMD) {
|
else if (vcmd.type() == CL_COMMAND_WRITE_SIGNAL_AMD) {
|
||||||
GpuEvent gpuEvent;
|
iCmd()->CmdUpdateMemory(*(pGpuMemory->iMem()), size, 4, &value);
|
||||||
eventBegin(MainEngine);
|
|
||||||
cs()->p2pMarkerOp(gpuMemory->iMem(), vcmd.markerValue(), vcmd.markerOffset(), true);
|
|
||||||
//! @todo We don't need flush if an event is tracked.
|
|
||||||
cs()->Flush();
|
|
||||||
eventEnd(MainEngine, gpuEvent);
|
|
||||||
gpuMemory->setBusy(*this, gpuEvent);
|
|
||||||
// Update the global GPU event
|
|
||||||
setGpuEvent(gpuEvent);
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
eventEnd(MainEngine, gpuEvent);
|
||||||
|
pGpuMemory->setBusy(*this, gpuEvent);
|
||||||
|
// Update the global GPU event
|
||||||
|
setGpuEvent(gpuEvent);
|
||||||
|
|
||||||
profilingEnd(vcmd);
|
profilingEnd(vcmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2761,39 +2762,24 @@ VirtualGPU::submitMakeBuffersResident(amd::MakeBuffersResidentCommand & vcmd)
|
|||||||
{
|
{
|
||||||
amd::ScopedLock lock(execution());
|
amd::ScopedLock lock(execution());
|
||||||
profilingBegin(vcmd);
|
profilingBegin(vcmd);
|
||||||
|
|
||||||
std::vector<amd::Memory*> memObjects = vcmd.memObjects();
|
std::vector<amd::Memory*> memObjects = vcmd.memObjects();
|
||||||
cl_uint numObjects = memObjects.size();
|
uint32_t numObjects = memObjects.size();
|
||||||
Pal::IGpuMemory** pGpuMemObjects = new Pal::IGpuMemory*[numObjects];
|
|
||||||
|
|
||||||
for(cl_uint i = 0; i < numObjects; ++i)
|
for (int i = 0; i < numObjects; i++)
|
||||||
{
|
{
|
||||||
pal::Memory* gpuMemory = dev().getGpuMemory(memObjects[i]);
|
// dummy render into the SDI surfaces so that KMD will be able to provide the bus addresses
|
||||||
pGpuMemObjects[i] = gpuMemory->iMem();
|
uint dummy = 0;
|
||||||
gpuMemory->syncCacheFromHost(*this);
|
static_cast<const KernelBlitManager&>(dev().xferMgr())
|
||||||
}
|
.writeRawData(*(dev().getGpuMemory(memObjects[i])), sizeof(dummy), &dummy);
|
||||||
|
|
||||||
uint64_t* surfBusAddr = new uint64_t[numObjects];
|
pal::Memory* pGpuMemory = dev().getGpuMemory(memObjects[i]);
|
||||||
uint64_t* markerBusAddr = new uint64_t[numObjects];
|
|
||||||
Unimplemented();
|
pGpuMemory->syncCacheFromHost(*this);
|
||||||
/*
|
|
||||||
gslErrorCode res = cs()->makeBuffersResident(numObjects, pGpuMemObjects,
|
vcmd.busAddress()[i].surface_bus_address = pGpuMemory->iMem()->Desc().surfaceBusAddr;
|
||||||
surfBusAddr, markerBusAddr);
|
vcmd.busAddress()[i].marker_bus_address = pGpuMemory->iMem()->Desc().markerBusAddr;
|
||||||
if(res != GSL_NO_ERROR) {
|
|
||||||
LogError("MakeBuffersResident failed");
|
|
||||||
vcmd.setStatus(CL_INVALID_OPERATION);
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
cl_bus_address_amd* busAddr = vcmd.busAddress();
|
|
||||||
for(cl_uint i = 0; i < numObjects; ++i)
|
|
||||||
{
|
|
||||||
busAddr[i].surface_bus_address = surfBusAddr[i];
|
|
||||||
busAddr[i].marker_bus_address = markerBusAddr[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
delete[] pGpuMemObjects;
|
|
||||||
delete[] surfBusAddr;
|
|
||||||
delete[] markerBusAddr;
|
|
||||||
profilingEnd(vcmd);
|
profilingEnd(vcmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user