From 18eb37fc018fe2d303e076e0fb23ca4be3714629 Mon Sep 17 00:00:00 2001 From: foreman Date: Wed, 18 Feb 2015 17:22:47 -0500 Subject: [PATCH] P4 to Git Change 1123271 by wchau@wchau_WINDOWS7_OCL on 2015/02/18 16:59:12 ECR #399840 - OpenCL Runtime HW Debug support development - add install_trap API to avoid the expose of runtime trap handler to the DBE. Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_context.cpp#41 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_debugger_amd.cpp#5 edit ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_debugger_amd.h#5 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudebugmanager.cpp#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hwdebug.cpp#4 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hwdebug.hpp#5 edit [ROCm/clr commit: 7431a16712eb1140eb9f59b0e3dffe3144df872e] --- .../rocclr/runtime/device/gpu/gpudebugmanager.cpp | 9 +++------ projects/clr/rocclr/runtime/device/hwdebug.cpp | 14 +++++++++++++- projects/clr/rocclr/runtime/device/hwdebug.hpp | 13 +++++++------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/gpu/gpudebugmanager.cpp b/projects/clr/rocclr/runtime/device/gpu/gpudebugmanager.cpp index f67d0c9eb4..aa066f94d1 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpudebugmanager.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpudebugmanager.cpp @@ -93,7 +93,6 @@ GpuDebugManager::executePreDispatchCallBack(void* aqlPacket, oclEventHandle_, aqlPacket_, aclBinary_, - deviceTrapInfo_, preDispatchCallBackArgs_); } @@ -107,7 +106,7 @@ GpuDebugManager::executePostDispatchCallBack() if (NULL != postDispatchCallBackFunc_) { cl_device_id clDeviceId = as_cl(device_); postDispatchCallBackFunc_(clDeviceId, - 0, + aqlPacket_->completion_signal.handle, postDispatchCallBackArgs_); } } @@ -202,10 +201,8 @@ GpuDebugManager::setupTrapInformation(DebugToolInfo* toolInfo) toolInfo->reservedCuNum_ = execMode_.reservedCuNum; - toolInfo->trapHandler_ = - as_amd(reinterpret_cast(deviceTrapInfo_[kDebugTrapHandlerLocation])); - toolInfo->trapBuffer_ = - as_amd(reinterpret_cast(deviceTrapInfo_[kDebugTrapBufferLocation])); + toolInfo->trapHandler_ = rtTrapInfo_[kDebugTrapHandlerLocation]; + toolInfo->trapBuffer_ = rtTrapInfo_[kDebugTrapBufferLocation]; } diff --git a/projects/clr/rocclr/runtime/device/hwdebug.cpp b/projects/clr/rocclr/runtime/device/hwdebug.cpp index 8cfa01fa21..189478ece7 100644 --- a/projects/clr/rocclr/runtime/device/hwdebug.cpp +++ b/projects/clr/rocclr/runtime/device/hwdebug.cpp @@ -45,7 +45,9 @@ HwDebugManager::HwDebugManager(amd::Device* device) { memset(&debugInfo_, 0, sizeof(debugInfo_)); - memset(deviceTrapInfo_, 0, sizeof(uint64_t) * kDebugTrapLocationMax); + for (int i = 0; i < kDebugTrapLocationMax; i++) { + rtTrapInfo_[i] = NULL; + } } HwDebugManager::~HwDebugManager() @@ -172,4 +174,14 @@ HwDebugManager::assignKernelParamMem(uint32_t paramIdx, amd::Memory* mem) paramMemory_[paramIdx] = mem; } +void +HwDebugManager::installTrap(cl_dbg_trap_type_amd trapType, + amd::Memory* trapHandler, + amd::Memory* trapBuffer) +{ + rtTrapInfo_[trapType<<2] = trapHandler; + rtTrapInfo_[(trapType<<2)+1] = trapBuffer; +} + + } // namespace amd diff --git a/projects/clr/rocclr/runtime/device/hwdebug.hpp b/projects/clr/rocclr/runtime/device/hwdebug.hpp index bca608a75f..7fa5baedb4 100644 --- a/projects/clr/rocclr/runtime/device/hwdebug.hpp +++ b/projects/clr/rocclr/runtime/device/hwdebug.hpp @@ -157,6 +157,11 @@ public: //! Get kernel parameter memory object cl_mem getKernelParamMem(uint32_t paramIdx) const; + //! Install trap handler + void installTrap(cl_dbg_trap_type_amd trapType, + amd::Memory* pTrapHandler, + amd::Memory* pTrapBuffer); + //! Flush cache virtual void flushCache(uint32_t mask) = 0; @@ -207,7 +212,7 @@ public: //! Execute the pre-dispatch callback function virtual void executePreDispatchCallBack(void* aqlPacket, - void* toolInfo) = 0; + void* toolInfo) = 0; //! Return the use of HW DEBUG flag bool isMsgBufferReady() const { return dbgMsgBufferReady_; } @@ -222,9 +227,6 @@ protected: //! Return the register flag bool isRegistered() const { return isRegistered_; } - //! Return the device trap handler information - const uint64_t* deviceTrapInfo() const { return deviceTrapInfo_; } - protected: const amd::Context* context_; ///< context that used to create host queue for the debugger @@ -236,7 +238,7 @@ protected: void* postDispatchCallBackArgs_; //!< post-dispatch callback function arguments DispatchDebugInfo debugInfo_; //!< Debug setting/information for kernel dispatch - uint64_t deviceTrapInfo_[kDebugTrapLocationMax]; //!< Device trap buffer, to store various trap handlers on the device + amd::Memory* rtTrapInfo_[kDebugTrapLocationMax]; //!< Device trap buffer, to store various trap handlers on the device amd::Memory** paramMemory_; //!< list of memory pointers for kernel parameters uint32_t numParams_; //!< number of kernel parameters @@ -255,7 +257,6 @@ protected: cl_dbg_exception_policy_amd excpPolicy_; //!< exception policy cl_dbg_kernel_exec_mode_amd execMode_; //!< kernel execution mode RuntimeTrapInfo rtTrapHandlerInfo_; //!< Runtime trap information - };