From 172266c1bacba39b2ad73ac1bbff7e545bc01646 Mon Sep 17 00:00:00 2001
From: foreman
Date: Mon, 26 Jan 2015 12:53:29 -0500
Subject: [PATCH] P4 to Git Change 1115252 by
skudchad@skudchad_test_win_opencl2 on 2015/01/26 12:25:46
EPR #403782 - IOMMU2/SVM
- Detect SVM Fine Grain system in IOL and OpenCL runtime
- Changes to convey Allocation attribute to IOL
ReviewBoardURL = http://ocltc.amd.com/reviews/r/6685/diff/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#203 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.hpp#78 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuscsi.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpusettings.cpp#299 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpusettings.hpp#89 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/include/cal/cal.h#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/include/cal/calcl.h#31 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp#104 edit
---
rocclr/runtime/device/gpu/gpuresource.cpp | 10 ++++++++++
rocclr/runtime/device/gpu/gpuresource.hpp | 3 ++-
rocclr/runtime/device/gpu/gpuscsi.cpp | 5 +----
rocclr/runtime/device/gpu/gpusettings.cpp | 2 ++
rocclr/runtime/device/gpu/gpusettings.hpp | 3 ++-
rocclr/runtime/device/gpu/gslbe/src/include/cal/cal.h | 3 ++-
.../runtime/device/gpu/gslbe/src/include/cal/calcl.h | 1 +
rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp | 3 +++
8 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/rocclr/runtime/device/gpu/gpuresource.cpp b/rocclr/runtime/device/gpu/gpuresource.cpp
index 116d9fdd0f..851ab90a35 100644
--- a/rocclr/runtime/device/gpu/gpuresource.cpp
+++ b/rocclr/runtime/device/gpu/gpuresource.cpp
@@ -406,6 +406,7 @@ Resource::create(MemoryType memType, CreateParams* params, bool heap)
// Fall through ...
case RemoteUSWC:
case Remote:
+ case Shader:
case BusAddressable:
case ExternalPhysical:
// Fall through to process the memory allocation ...
@@ -437,6 +438,15 @@ Resource::create(MemoryType memType, CreateParams* params, bool heap)
else if (memoryType() == RemoteUSWC) {
desc.type = GSL_MOA_MEMORY_AGP;
}
+ else if (memoryType() == Shader){
+ if(dev().settings().svmFineGrainSystem_) {
+ desc.isAllocExecute = true;
+ }
+ // force to use remote memory for HW DEBUG or use
+ // local memory once we determine if FGS is supported
+ memType = (!dev().settings().enableHwDebug_) ? Local : RemoteUSWC;
+ cal_.type_ = memType;
+ }
else if (memoryType() == BusAddressable){
desc.type = GSL_MOA_MEMORY_CARD_BUS_ADDRESSABLE;
}
diff --git a/rocclr/runtime/device/gpu/gpuresource.hpp b/rocclr/runtime/device/gpu/gpuresource.hpp
index a47ba4fbe4..7ce8b593ac 100644
--- a/rocclr/runtime/device/gpu/gpuresource.hpp
+++ b/rocclr/runtime/device/gpu/gpuresource.hpp
@@ -137,7 +137,8 @@ public:
BusAddressable, //!< resource is a bus addressable memory
ExternalPhysical, //!< resource is an external physical memory
D3D9Interop, //!< resource is a D3D9 memory object
- Scratch //!< resource is scratch memory
+ Scratch, //!< resource is scratch memory
+ Shader, //!< resource is a shader
};
//! Resource map flags
diff --git a/rocclr/runtime/device/gpu/gpuscsi.cpp b/rocclr/runtime/device/gpu/gpuscsi.cpp
index 444871f6d6..5de3a41013 100644
--- a/rocclr/runtime/device/gpu/gpuscsi.cpp
+++ b/rocclr/runtime/device/gpu/gpuscsi.cpp
@@ -175,11 +175,8 @@ HSAILKernel::aqlCreateHWInfo(const void* shader, size_t shaderSize)
codeSize_ = codeEndAddress - codeStartAddress;
code_ = new gpu::Memory(dev(), amd::alignUp(codeSize_, gpu::ConstBuffer::VectorSize));
- // force to use remote memory for HW DEBUG
- Resource::MemoryType resMemType = (!dev().settings().enableHwDebug_) ? Resource::Local : Resource::RemoteUSWC;
-
// Initialize kernel ISA code
- if ((code_ != NULL) && code_->create(resMemType)) {
+ if ((code_ != NULL) && code_->create(Resource::Shader)) {
address cpuCodePtr = static_cast(code_->map(NULL, Resource::WriteOnly));
// Copy only amd_kernel_code_t
memcpy(cpuCodePtr, codeStartAddress, codeSize_);
diff --git a/rocclr/runtime/device/gpu/gpusettings.cpp b/rocclr/runtime/device/gpu/gpusettings.cpp
index 62c3d0cf8c..5fdbf97b1e 100644
--- a/rocclr/runtime/device/gpu/gpusettings.cpp
+++ b/rocclr/runtime/device/gpu/gpusettings.cpp
@@ -424,6 +424,8 @@ Settings::create(
svmAtomics_ = true;
}
+ svmFineGrainSystem_ = calAttr.isSVMFineGrainSystem;
+
// Enable some platform extensions
enableExtension(ClAmdDeviceAttributeQuery);
diff --git a/rocclr/runtime/device/gpu/gpusettings.hpp b/rocclr/runtime/device/gpu/gpusettings.hpp
index 437147466f..39859a1c2b 100644
--- a/rocclr/runtime/device/gpu/gpusettings.hpp
+++ b/rocclr/runtime/device/gpu/gpusettings.hpp
@@ -69,11 +69,12 @@ public:
uint hsail_: 1; //!< Enables HSAIL compilation
uint stagingWritePersistent_: 1; //!< Enables persistent writes
uint svmAtomics_: 1; //!< SVM device atomics
+ uint svmFineGrainSystem_: 1; //!< SVM fine grain system support
uint apuSystem_: 1; //!< Device is APU system with shared memory
uint asyncMemCopy_: 1; //!< Use async memory transfers
uint hsailDirectSRD_: 1; //!< Controls direct SRD for HSAIL
uint useDeviceQueue_: 1; //!< Submit to separate device queue
- uint reserved_: 2;
+ uint reserved_: 1;
};
uint value_;
};
diff --git a/rocclr/runtime/device/gpu/gslbe/src/include/cal/cal.h b/rocclr/runtime/device/gpu/gslbe/src/include/cal/cal.h
index b4f5d59d88..066a188fbc 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/include/cal/cal.h
+++ b/rocclr/runtime/device/gpu/gslbe/src/include/cal/cal.h
@@ -239,7 +239,8 @@ typedef struct CALdeviceattribsRec {
CALuint64 vaEnd; /**< VA end address */
bool isWorkstation; /**< Whether Device is a Workstation/Server part */
CALuint numOfVpu; /**< number of vpu in the device*/
- bool isOpenCL200Device; /**< the flag to mark if the device is OpenCL 200*/
+ bool isOpenCL200Device; /**< the flag to mark if the device is OpenCL 200 */
+ bool isSVMFineGrainSystem; /**< check if SVM finegrainsystem */
} CALdeviceattribs;
/** CAL device status */
diff --git a/rocclr/runtime/device/gpu/gslbe/src/include/cal/calcl.h b/rocclr/runtime/device/gpu/gslbe/src/include/cal/calcl.h
index 849aa0bf45..47d3056a9b 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/include/cal/calcl.h
+++ b/rocclr/runtime/device/gpu/gslbe/src/include/cal/calcl.h
@@ -146,6 +146,7 @@ typedef struct CALresourceDescRec {
mcaddr vaBase;
gslMemObjectAttribSection section;
CALuint minAlignment;
+ bool isAllocExecute;
} CALresourceDesc;
typedef enum CALresallocsliceviewflagsRec {
diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
index 0525cf3f64..b6ee6444dc 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
@@ -156,6 +156,7 @@ CALGSLDevice::getAttribs_int(gsl::gsCtx* cs)
m_attribs.vaEnd = static_cast(m_adp->pAsicInfo->vaEnd);
m_attribs.numOfVpu = m_adp->pAsicInfo->numberOfVPU;
m_attribs.isOpenCL200Device = m_adp->pAsicInfo->bIsOpen2Device;
+ m_attribs.isSVMFineGrainSystem = m_adp->pAsicInfo->svmFineGrainSystem;
}
void
@@ -733,6 +734,7 @@ CALGSLDevice::resAlloc(const CALresourceDesc* desc) const
attribs.location = desc->type;
attribs.vaBase = desc->vaBase;
attribs.section = desc->section;
+ attribs.isAllocExecute = desc->isAllocExecute;
attribs.minAlignment = desc->minAlignment;
//!@note GSL asserts with tiled 1D images of any type.
@@ -837,6 +839,7 @@ CALGSLDevice::resAllocView(gslMemObject res, gslResource3D size, CALdomain offse
);
attribs.bytePitch = bytePitch;
attribs.section = res->getAttribs().section;
+ attribs.isAllocExecute = res->getAttribs().isAllocExecute;
// Need to get the alignment info from hwl.
// Not sure hwl is correct though. Linear aligned 256b, tiled 8kb according to the address library.