P4 to Git Change 1123622 by wchau@wchau_WINDOWS7_OCL on 2015/02/19 17:52:17
ECR #399840 - OpenCL Runtime HW Debug support development
- use device to control debugger registration and exception notification so that debug event will not be tied to any particular queue.
- use aqlCodeInfo parameter for clHwDbgMapKernelCodeAMD() to be consistent with clHwDbgGetAqlPacketInfoAMD()
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_debugger_amd.cpp#6 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_debugger_amd.h#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudebugmanager.cpp#7 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudebugmanager.hpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#352 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.hpp#127 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLContext.cpp#70 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLContext.h#43 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hwdebug.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hwdebug.hpp#6 edit
[ROCm/clr commit: 3e53caa02e]
This commit is contained in:
@@ -111,6 +111,15 @@ GpuDebugManager::executePostDispatchCallBack()
|
||||
}
|
||||
}
|
||||
|
||||
//! Map the kernel code for host access
|
||||
void
|
||||
GpuDebugManager::mapKernelCode(void* aqlCodeInfo) const
|
||||
{
|
||||
AqlCodeInfo* codeInfo = reinterpret_cast<AqlCodeInfo*>(aqlCodeInfo);
|
||||
|
||||
codeInfo->aqlCode_ = reinterpret_cast<amd_kernel_code_t*>(aqlCodeAddr_);
|
||||
codeInfo->aqlCodeSize_ = aqlCodeSize_;
|
||||
}
|
||||
|
||||
cl_int
|
||||
GpuDebugManager::registerDebugger(amd::Context* context, uintptr_t messageStorage)
|
||||
@@ -125,8 +134,11 @@ GpuDebugManager::registerDebugger(amd::Context* context, uintptr_t messageStorag
|
||||
// first time register - set the message storage, flush queue and enable hw debug
|
||||
if (!isRegistered()) {
|
||||
debugMessages_ = messageStorage;
|
||||
dbgMsgBufferReady_ = true;
|
||||
isRegistered_ = false;
|
||||
if (!device()->gslCtx()->registerHwDebugger(debugMessages_)) {
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
isRegistered_ = true;
|
||||
}
|
||||
|
||||
context_ = context;
|
||||
@@ -142,35 +154,10 @@ GpuDebugManager::unregisterDebugger()
|
||||
|
||||
// reset the debugger registration flag
|
||||
isRegistered_ = false;
|
||||
dbgMsgBufferReady_ = false;
|
||||
|
||||
context_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
cl_int
|
||||
GpuDebugManager::registerDebuggerOnQueue(device::VirtualDevice* vDevice)
|
||||
{
|
||||
if (!isMsgBufferReady()) {
|
||||
return CL_DEBUGGER_REGISTER_FAILURE_AMD;
|
||||
}
|
||||
|
||||
if (isRegistered()) { // The debugger has already been registered,
|
||||
return CL_SUCCESS; // nothing to be done
|
||||
}
|
||||
|
||||
VirtualGPU* vGpu = reinterpret_cast<gpu::VirtualGPU*>(vDevice);
|
||||
|
||||
// populate the fields in the debugMessages structure used by the GPU exception notification
|
||||
if (vGpu->RegisterHwDebugger(debugMessages_)) {
|
||||
vGpu_ = vGpu;
|
||||
isRegistered_ = true;
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
return CL_DEBUGGER_REGISTER_FAILURE_AMD;
|
||||
}
|
||||
|
||||
void
|
||||
GpuDebugManager::flushCache(uint32_t mask)
|
||||
{
|
||||
@@ -205,7 +192,6 @@ GpuDebugManager::setupTrapInformation(DebugToolInfo* toolInfo)
|
||||
toolInfo->trapBuffer_ = rtTrapInfo_[kDebugTrapBufferLocation];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GpuDebugManager::getPacketAmdInfo(
|
||||
const void* aqlCodeInfo,
|
||||
@@ -259,8 +245,7 @@ GpuDebugManager::createDebugEvent(
|
||||
|
||||
osEventReset(shaderEvent); // initial state is non-signaled
|
||||
|
||||
if (vGpu_->ExceptionNotification(shaderEvent)) {
|
||||
isRegistered_ = true;
|
||||
if (device()->gslCtx()->exceptionNotification(shaderEvent)) {
|
||||
return shaderEvent;
|
||||
}
|
||||
}
|
||||
@@ -287,7 +272,7 @@ GpuDebugManager::destroyDebugEvent(DebugEvent* pEvent)
|
||||
osEventDestroy(*pEvent);
|
||||
*pEvent = 0;
|
||||
|
||||
vGpu_->ExceptionNotification(0);
|
||||
device()->gslCtx()->exceptionNotification(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -65,9 +65,6 @@ public:
|
||||
//! Register the debugger
|
||||
cl_int registerDebugger(amd::Context*context, uintptr_t messageStorage);
|
||||
|
||||
//! Register the debugger with KMD after command queue has been created
|
||||
cl_int registerDebuggerOnQueue(device::VirtualDevice* vDevice);
|
||||
|
||||
//! Unregister the debugger
|
||||
void unregisterDebugger();
|
||||
|
||||
@@ -84,6 +81,9 @@ public:
|
||||
uint64_t* watchMode,
|
||||
DebugEvent* pEvent);
|
||||
|
||||
//! Map the kernel code for host access
|
||||
void mapKernelCode(void* aqlCodeInfo) const;
|
||||
|
||||
//! Get the packet information for dispatch
|
||||
void getPacketAmdInfo(const void* aqlCodeInfo, void* packetInfo) const;
|
||||
|
||||
|
||||
@@ -403,7 +403,6 @@ VirtualGPU::VirtualGPU(
|
||||
, schedParamIdx_(0)
|
||||
, deviceQueueSize_(0)
|
||||
, hsaQueueMem_(NULL)
|
||||
, useHwDebug_(false)
|
||||
{
|
||||
memset(&cal_, 0, sizeof(CalVirtualDesc));
|
||||
for (uint i = 0; i < AllEngines; ++i) {
|
||||
@@ -587,15 +586,6 @@ VirtualGPU::create(
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if HW Debug is used and register the debugger if not done yet
|
||||
amd::HwDebugManager * dbgManager = dev().hwDebugMgr();
|
||||
|
||||
if ( dbgManager && dbgManager->isMsgBufferReady() ) {
|
||||
if ( dbgManager->registerDebuggerOnQueue(this) == CL_SUCCESS ) {
|
||||
useHwDebug_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1648,6 +1638,7 @@ VirtualGPU::submitKernelInternalHSA(
|
||||
uint64_t vmDefQueue = 0;
|
||||
amd::DeviceQueue* defQueue = kernel.program().context().defDeviceQueue(dev());
|
||||
VirtualGPU* gpuDefQueue = NULL;
|
||||
amd::HwDebugManager * dbgManager = dev().hwDebugMgr();
|
||||
|
||||
// Get the HSA kernel object
|
||||
const HSAILKernel& hsaKernel =
|
||||
@@ -1735,8 +1726,8 @@ VirtualGPU::submitKernelInternalHSA(
|
||||
|
||||
// setup the storage for the memory pointers of the kernel parameters
|
||||
uint numParams = kernel.signature().numParameters();
|
||||
if (useHwDebug_) {
|
||||
dev().hwDebugMgr()->allocParamMemList(numParams);
|
||||
if (dbgManager) {
|
||||
dbgManager->allocParamMemList(numParams);
|
||||
}
|
||||
|
||||
// Program the kernel arguments for the GPU execution
|
||||
@@ -1768,7 +1759,7 @@ VirtualGPU::submitKernelInternalHSA(
|
||||
HwDbgKernelInfo kernelInfo;
|
||||
HwDbgKernelInfo *pKernelInfo = NULL;
|
||||
|
||||
if (useHwDebug_) {
|
||||
if (dbgManager) {
|
||||
buildKernelInfo(hsaKernel, aqlPkt, kernelInfo, enqueueEvent);
|
||||
pKernelInfo = &kernelInfo;
|
||||
}
|
||||
@@ -1778,10 +1769,8 @@ VirtualGPU::submitKernelInternalHSA(
|
||||
runAqlDispatch(gpuEvent, aqlPkt, vmMems(), cal_.memCount_,
|
||||
scratch, scratchOffset, hsaKernel.cpuAqlCode(), hsaQueueMem_->vmAddress(), pKernelInfo);
|
||||
|
||||
if (useHwDebug_) {
|
||||
if (NULL != dev().hwDebugMgr()->postDispatchCallBackFunc()) {
|
||||
dev().hwDebugMgr()->executePostDispatchCallBack();
|
||||
}
|
||||
if (dbgManager && (NULL != dbgManager->postDispatchCallBackFunc())) {
|
||||
dbgManager->executePostDispatchCallBack();
|
||||
}
|
||||
|
||||
if (hsaKernel.dynamicParallelism()) {
|
||||
|
||||
@@ -554,8 +554,6 @@ private:
|
||||
uint deviceQueueSize_; //!< Device queue size
|
||||
|
||||
Memory* hsaQueueMem_; //!< Memory for the amd_queue_t object
|
||||
|
||||
bool useHwDebug_; //!< Flag of using HW debug
|
||||
};
|
||||
|
||||
/*@}*/} // namespace gpu
|
||||
|
||||
@@ -1300,18 +1300,6 @@ CALGSLContext::virtualQueueHandshake(GpuEvent& event, const gslMemObject mem, mc
|
||||
eventEnd(MainEngine, event);
|
||||
}
|
||||
|
||||
bool
|
||||
CALGSLContext::RegisterHwDebugger(uint64 debugMessages)
|
||||
{
|
||||
return m_cs->registerHwDebugger(debugMessages);
|
||||
}
|
||||
|
||||
bool
|
||||
CALGSLContext::ExceptionNotification(osEventHandle debugEvent)
|
||||
{
|
||||
return m_cs->exceptionNotification(debugEvent);
|
||||
}
|
||||
|
||||
void
|
||||
CALGSLContext::InvalidateSqCaches(bool instInvalidate, bool dataInvalidate, bool tcL1, bool tcL2)
|
||||
{
|
||||
|
||||
@@ -142,8 +142,6 @@ public:
|
||||
void writeSurfRaw(GpuEvent& event, gslMemObject mem, size_t size, const void* data);
|
||||
|
||||
/// HW Debug support functions
|
||||
bool RegisterHwDebugger(uint64 debugMessages);
|
||||
bool ExceptionNotification(osEventHandle debugEvent);
|
||||
void InvalidateSqCaches(bool instInvalidate = true, bool dataInvalidate = true, bool tcL1 = true, bool tcL2 = true);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -41,7 +41,6 @@ HwDebugManager::HwDebugManager(amd::Device* device)
|
||||
, scratchRingAddr_(NULL)
|
||||
, scratchRingSize_(0)
|
||||
, isRegistered_(false)
|
||||
, dbgMsgBufferReady_(false)
|
||||
{
|
||||
memset(&debugInfo_, 0, sizeof(debugInfo_));
|
||||
|
||||
@@ -81,7 +80,6 @@ HwDebugManager::getDispatchDebugInfo(void* debugInfo) const
|
||||
memcpy(debugInfo, (void*) &debugInfo_, sizeof(DispatchDebugInfo));
|
||||
}
|
||||
|
||||
|
||||
//! Set the kernel code address and its size
|
||||
void
|
||||
HwDebugManager::setKernelCodeInfo(address aqlCodeAddr, uint32_t aqlCodeSize)
|
||||
@@ -98,14 +96,6 @@ HwDebugManager::setScratchRing(address scratchRingAddr, uint32_t scratchRingSize
|
||||
scratchRingSize_ = scratchRingSize;
|
||||
}
|
||||
|
||||
//! Map the shader (AQL code) for host access
|
||||
void
|
||||
HwDebugManager::mapKernelCode(uint64_t* aqlCodeAddr, uint32_t* aqlCodeSize) const
|
||||
{
|
||||
*aqlCodeAddr = reinterpret_cast<uint64_t>(aqlCodeAddr_);
|
||||
*aqlCodeSize = aqlCodeSize_;
|
||||
}
|
||||
|
||||
//! Map the scratch ring for host access
|
||||
void
|
||||
HwDebugManager::mapScratchRing(uint64_t* scratchRingAddr, uint32_t* scratchRingSize) const
|
||||
|
||||
@@ -68,8 +68,6 @@ struct RuntimeTrapInfo {
|
||||
//!< Buffer to backup the VGPR used by the runtime trap handler
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Opaque pointer to trap event
|
||||
*/
|
||||
@@ -113,9 +111,6 @@ public:
|
||||
//! Get the scratch ring
|
||||
void setScratchRing(address scratchRingAddr, uint32_t scratchRingSize);
|
||||
|
||||
//! Map the shader (AQL code) for host access
|
||||
void mapKernelCode(uint64_t* aqlCodeAddr, uint32_t* aqlCodeSize) const;
|
||||
|
||||
//! Map the scratch ring for host access
|
||||
void mapScratchRing(uint64_t* scratchRingAddr, uint32_t* scratchRingSize) const;
|
||||
|
||||
@@ -177,9 +172,6 @@ public:
|
||||
//! Register the debugger
|
||||
virtual cl_int registerDebugger(amd::Context* context, uintptr_t pMessageStorage) = 0;
|
||||
|
||||
//! Call KMD to register the debugger
|
||||
virtual cl_int registerDebuggerOnQueue(device::VirtualDevice* vDevice) = 0;
|
||||
|
||||
//! Unregister the debugger
|
||||
virtual void unregisterDebugger() = 0;
|
||||
|
||||
@@ -197,6 +189,9 @@ public:
|
||||
uint64_t* watchMode,
|
||||
DebugEvent* event) = 0;
|
||||
|
||||
//! Map the shader (AQL code) for host access
|
||||
virtual void mapKernelCode(void* aqlCodeInfo) const = 0;
|
||||
|
||||
//! Get the packet information for dispatch
|
||||
virtual void getPacketAmdInfo(const void* aqlCodeInfo,
|
||||
void* packetInfo) const = 0;
|
||||
@@ -214,9 +209,6 @@ public:
|
||||
virtual void executePreDispatchCallBack(void* aqlPacket,
|
||||
void* toolInfo) = 0;
|
||||
|
||||
//! Return the use of HW DEBUG flag
|
||||
bool isMsgBufferReady() const { return dbgMsgBufferReady_; }
|
||||
|
||||
protected:
|
||||
//! Return the context
|
||||
const amd::Context* context() const { return context_; }
|
||||
@@ -252,7 +244,6 @@ protected:
|
||||
uint32_t scratchRingSize_; //!< The size of the scratch ring
|
||||
|
||||
bool isRegistered_; //! flag to indicate the debugger has been registered
|
||||
bool dbgMsgBufferReady_; //! flag to indicate the HW DEBUG is using
|
||||
|
||||
cl_dbg_exception_policy_amd excpPolicy_; //!< exception policy
|
||||
cl_dbg_kernel_exec_mode_amd execMode_; //!< kernel execution mode
|
||||
|
||||
Reference in New Issue
Block a user