diff --git a/opencl/api/opencl/amdocl/cl_debugger_amd.cpp b/opencl/api/opencl/amdocl/cl_debugger_amd.cpp index 508b494412..9781fc3ea5 100644 --- a/opencl/api/opencl/amdocl/cl_debugger_amd.cpp +++ b/opencl/api/opencl/amdocl/cl_debugger_amd.cpp @@ -107,7 +107,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgFlushCacheAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->flushCache(mask.ui32All); + debugManager->flushCache(mask.ui32All); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -142,7 +144,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgSetExceptionPolicyAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->setExceptionPolicy(policy); + debugManager->setExceptionPolicy(policy); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -176,7 +180,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgGetExceptionPolicyAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->getExceptionPolicy(policy); + debugManager->getExceptionPolicy(policy); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -210,7 +216,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgSetKernelExecutionModeAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->setKernelExecutionMode(mode); + debugManager->setKernelExecutionMode(mode); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -244,7 +252,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgGetKernelExecutionModeAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->getKernelExecutionMode(mode); + debugManager->getKernelExecutionMode(mode); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -365,7 +375,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgDestroyEventAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->destroyDebugEvent(*pDebugEvent); + debugManager->destroyDebugEvent(pDebugEvent); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -403,6 +415,11 @@ RUNTIME_ENTRY(cl_int, clHwDbgRegisterDebuggerAMD, ( return CL_INVALID_VALUE; } + // check if the debugger has already registered + if (NULL != as_amd(device)->hwDebugMgr()) { + return CL_INVALID_VALUE; + } + return as_amd(device)->hwDebugManagerInit(as_amd(context), reinterpret_cast(pMessageStorage)); } @@ -430,7 +447,10 @@ RUNTIME_ENTRY(cl_int, clHwDbgUnregisterDebuggerAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->unregisterDebugger(); + as_amd(device)->hwDebugManagerRemove(); + + return CL_SUCCESS; + } RUNTIME_EXIT @@ -519,7 +539,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgWaveControlAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->wavefrontControl(action, mode, trapId, (void *) &waveAddress); + debugManager->wavefrontControl(action, mode, trapId, (void *) &waveAddress); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -584,9 +606,11 @@ RUNTIME_ENTRY(cl_int, clHwDbgAddressWatchAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->setAddressWatch(numWatchPoints, watchAddress, watchMask, - reinterpret_cast(watchMode), - watchEvent); + debugManager->setAddressWatch(numWatchPoints, watchAddress, watchMask, + reinterpret_cast(watchMode), + watchEvent); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -620,7 +644,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgGetAqlPacketInfoAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->getPacketAmdInfo(aqlCodeInfo, packetInfo); + debugManager->getPacketAmdInfo(aqlCodeInfo, packetInfo); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -644,12 +670,19 @@ RUNTIME_ENTRY(cl_int, clHwDbgGetDispatchDebugInfoAMD, ( return CL_INVALID_DEVICE; } + if (NULL == debugInfo) { + LogWarning("clHwDbgGetDispatchDebugInfoAMD: Invalid debug information pointer."); + return CL_INVALID_VALUE; + } + amd::HwDebugManager * debugManager = as_amd(device)->hwDebugMgr(); if (NULL == debugManager) { return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->getDispatchDebugInfo((void *) debugInfo); + debugManager->getDispatchDebugInfo((void *) debugInfo); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -680,7 +713,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgMapKernelCodeAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->mapKernelCode(aqlCodeAddress, aqlCodeSize); + debugManager->mapKernelCode(aqlCodeAddress, aqlCodeSize); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -743,7 +778,9 @@ RUNTIME_ENTRY(cl_int, clHwDbgMapScratchRingAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->mapScratchRing(scratchRingAddr, scratchRingSize); + debugManager->mapScratchRing(scratchRingAddr, scratchRingSize); + + return CL_SUCCESS; } RUNTIME_EXIT @@ -796,9 +833,9 @@ RUNTIME_EXIT * - CL_INVALID_KERNEL_ARGS if it fails to get the memory object for the kernel argument */ RUNTIME_ENTRY(cl_int, clHwDbgGetKernelParamMemAMD, ( - cl_device_id device, - cl_uint paramIdx, - cl_ulong * paramMem)) + cl_device_id device, + cl_uint paramIdx, + cl_mem * paramMem)) { if (!is_valid(device)) { return CL_INVALID_DEVICE; @@ -847,7 +884,7 @@ RUNTIME_EXIT */ RUNTIME_ENTRY(cl_int, clHwDbgSetGlobalMemoryAMD, ( cl_device_id device, - void * memObject, + cl_mem memObject, cl_uint offset, void * srcMem, cl_uint size)) @@ -862,7 +899,14 @@ RUNTIME_ENTRY(cl_int, clHwDbgSetGlobalMemoryAMD, ( return CL_HWDBG_MANAGER_NOT_AVAILABLE_AMD; } - return debugManager->setGlobalMemory(memObject, offset, srcMem, size); + if (0 > offset || 0 >= size) { + return CL_INVALID_VALUE; + } + + amd::Memory* globalMem = as_amd(memObject); + debugManager->setGlobalMemory(globalMem, offset, srcMem, size); + + return CL_SUCCESS; } RUNTIME_EXIT diff --git a/opencl/api/opencl/amdocl/cl_debugger_amd.h b/opencl/api/opencl/amdocl/cl_debugger_amd.h index b1e17223ad..e27cdad5e8 100644 --- a/opencl/api/opencl/amdocl/cl_debugger_amd.h +++ b/opencl/api/opencl/amdocl/cl_debugger_amd.h @@ -112,7 +112,7 @@ extern "C" { #define CL_EVENT_TIMEOUT_AMD -83 -typedef cl_ulong cl_dbg_event_amd; //! debug event +typedef uintptr_t cl_dbg_event_amd; //! debug event /*! \brief Wave actions used to control the wave execution on the hardware * @@ -732,7 +732,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL clHwDbgUnmapScratchRingAMD( extern CL_API_ENTRY cl_int CL_API_CALL clHwDbgGetKernelParamMemAMD( cl_device_id /* devicepointer */, cl_uint /* paramIdx */, - cl_ulong * /* paramMem */ + cl_mem * /* paramMem */ ) CL_API_SUFFIX__VERSION_2_0; /*! \brief Set value of a global memory object @@ -755,7 +755,7 @@ extern CL_API_ENTRY cl_int CL_API_CALL clHwDbgGetKernelParamMemAMD( */ extern CL_API_ENTRY cl_int CL_API_CALL clHwDbgSetGlobalMemoryAMD( cl_device_id /* device */, - void * /* memObject */, + cl_mem /* memObject */, cl_uint /* offset */, void * /* srcMem */, cl_uint /* size */