debugging tools tim purcell nvidia. programming soap box successful programming systems require at...

31
Debugging Tools Debugging Tools Tim Purcell Tim Purcell NVIDIA NVIDIA

Upload: maxim-flitter

Post on 14-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Debugging ToolsDebugging Tools

Tim PurcellTim Purcell

NVIDIANVIDIA

Page 2: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Programming Soap BoxProgramming Soap Box

• Successful programming systems Successful programming systems require at least three ‘tools’require at least three ‘tools’• CompilerCompiler

•Cg, HLSL, GLSL, RTSL, Brook…Cg, HLSL, GLSL, RTSL, Brook…

• DebuggerDebugger

• ProfilerProfiler

Page 3: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Ideal Fragment Program Ideal Fragment Program DebuggerDebugger• Automate ‘printf’ debuggingAutomate ‘printf’ debugging

Page 4: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

‘‘printf’ Debuggingprintf’ Debugging

• MOV suspect register to outputMOV suspect register to output• Comment out anything else writing to outputComment out anything else writing to output

• Scale and bias as neededScale and bias as needed

• RecompileRecompile

• Display/readback frame bufferDisplay/readback frame buffer

• Check valuesCheck values

• Repeat until error is (hopefully) Repeat until error is (hopefully) foundfound

Page 5: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

‘‘printf’ Debugging Examplesprintf’ Debugging Examples

Page 6: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

‘‘printf’ Debugging Examplesprintf’ Debugging Examples

Page 7: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

‘‘printf’ Debugging Examplesprintf’ Debugging Examples

Page 8: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

‘‘printf’ Debugging Examplesprintf’ Debugging Examples

Page 9: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Ideal Fragment Program Ideal Fragment Program DebuggerDebugger• Automate ‘printf’ debuggingAutomate ‘printf’ debugging• Intuitive and easy to use interfaceIntuitive and easy to use interface• Features over performanceFeatures over performance

• Debuggers don’t need to be fastDebuggers don’t need to be fast

•Should still be interactiveShould still be interactive

• Easy to add to existing appsEasy to add to existing apps• And removeAnd remove

• Touch as little GPU state as possibleTouch as little GPU state as possible• Report actual hardware valuesReport actual hardware values

• No software simulations!No software simulations!

Page 10: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Debugger FeaturesDebugger Features

• Per-pixel register watchPer-pixel register watch• Including interpolants, outputs, etc.Including interpolants, outputs, etc.

• BreakpointsBreakpoints

• Fragment program interpreterFragment program interpreter• Single step forwards or backwardsSingle step forwards or backwards

• Execute modified code on the flyExecute modified code on the fly

•And save itAnd save it

Page 11: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Debugger Features - Debugger Features - VisualizationVisualization• Display register value at each pixelDisplay register value at each pixel

• Color channel maskingColor channel masking

• Arbitrary code for visualizationArbitrary code for visualization

•Allows scale and bias of valuesAllows scale and bias of values

• Multiple visualization windowsMultiple visualization windows• Visualize each source register and resultVisualize each source register and result

•MUL R2, R1, R0;MUL R2, R1, R0;

= x

Page 12: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Debugging Options TodayDebugging Options Today

• Graphic Remedy gDebuggerGraphic Remedy gDebugger

• GLIntercept - [D. Trebilco]GLIntercept - [D. Trebilco]

• Microsoft Shader Debugger ToolMicrosoft Shader Debugger Tool

• Apple OpenGL Shader BuilderApple OpenGL Shader Builder

• Imdebug – The Image Debugger [B. Imdebug – The Image Debugger [B. Baxter]Baxter]

• Shadesmith – [T. Purcell, P. Sen]Shadesmith – [T. Purcell, P. Sen]

• Relational Debugging Engine [Duca Relational Debugging Engine [Duca et al. 2005]et al. 2005]

Page 13: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

GPU Vendor Debugging OptionsGPU Vendor Debugging Options

• ATI RenderMonkeyATI RenderMonkey

• Nvidia FXComposerNvidia FXComposer

• Won’t talk about these todayWon’t talk about these today

Page 14: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Graphic Remedy gDebuggerGraphic Remedy gDebugger

• ProsPros• Breakpoints, steppingBreakpoints, stepping

• Watch windowsWatch windows

• Performance analysisPerformance analysis

• OpenGL 2.0OpenGL 2.0

• ConsCons• OpenGL onlyOpenGL only

• Currently no program debuggingCurrently no program debugging

• http://www.gremedy.com/http://www.gremedy.com/

Page 15: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

gDebuggergDebugger

Page 16: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

GLInterceptGLIntercept

• ProsPros• Track all OpenGL stateTrack all OpenGL state

• Runtime shader edit and recompileRuntime shader edit and recompile

• Resource tracking and managementResource tracking and management

• ConsCons• OpenGL onlyOpenGL only

• No shader debuggingNo shader debugging

• No direct support for visualizationsNo direct support for visualizations

• http://glintercept.nutty.org/http://glintercept.nutty.org/

Page 17: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

GLInterceptGLIntercept

Page 18: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Microsoft Shader Debugger Microsoft Shader Debugger ToolTool• ProsPros

• Direct3D debugging integrated into Visual Studio IDEDirect3D debugging integrated into Visual Studio IDE

• Full featuredFull featured

• Assembly and high level debuggingAssembly and high level debugging• Vertex and fragment programsVertex and fragment programs• Watches, breakpoints, etc.Watches, breakpoints, etc.

• ConsCons• Only works with software rasterizerOnly works with software rasterizer

• Slow and painfulSlow and painful

• D3D onlyD3D only

• Shader changes require recompilationShader changes require recompilation• http://msdn.microsoft.com/library/default.asp?url=/library/en-us/http://msdn.microsoft.com/library/default.asp?url=/library/en-us/

directx9_c/directx/graphics/Tools/ShaderDebugger.aspdirectx9_c/directx/graphics/Tools/ShaderDebugger.asp

Page 19: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Apple OpenGL Shader Apple OpenGL Shader BuilderBuilder• ProsPros

• Integrated development environmentIntegrated development environment

• Handy reference guide, resource managerHandy reference guide, resource manager

• Texture editorTexture editor

• On the fly edit and display of shader changesOn the fly edit and display of shader changes

• ConsCons• Canned geometryCanned geometry

• Basically a shader tool (in the traditional sense) Basically a shader tool (in the traditional sense) – not GPGPU debuggernot GPGPU debugger

• ARB vertex/fragment programs onlyARB vertex/fragment programs only

• No vendor specific GL extensions support?No vendor specific GL extensions support?• http://developer.apple.com/graphicsimaging/opengl/http://developer.apple.com/graphicsimaging/opengl/

shader_image.htmlshader_image.html

Page 20: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

imdebugimdebug

• Printf-style debuggerPrintf-style debugger• imdebug("rgb w=%d h=%d %p", 16, 17, imdebug("rgb w=%d h=%d %p", 16, 17,

testRGB);testRGB);

• Readback memory (texture/frame buffer) and Readback memory (texture/frame buffer) and display in image window display in image window

• http://www.billbaxter.com/projects/http://www.billbaxter.com/projects/imdebug/imdebug/

Page 21: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

imdebugimdebug

Page 22: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

imdebugimdebug

• ProsPros• Simple addition of single printf-style statement to Simple addition of single printf-style statement to

programsprograms

• Displays hardware computed values – not software Displays hardware computed values – not software generated valuesgenerated values

• Scale and bias Scale and bias

• Source available for downloadSource available for download

• ConsCons• Can’t breakpoint shadersCan’t breakpoint shaders

• Can only watch what shader outputsCan only watch what shader outputs

Page 23: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

ShadesmithShadesmith

• Debugger in the spirit of imdebugDebugger in the spirit of imdebug• Simply add a debug statement when binding shadersSimply add a debug statement when binding shaders

• Display window with scale, bias, component maskingDisplay window with scale, bias, component masking

• Advanced featuresAdvanced features• Can watch any shader register contents without Can watch any shader register contents without

recompilerecompile

• Shader single stepping (forward and backward), Shader single stepping (forward and backward), breakpointingbreakpointing

• Shader source edit and reload without recompileShader source edit and reload without recompile

• http://graphics.stanford.edu/projects/http://graphics.stanford.edu/projects/shadesmith/shadesmith/

Page 24: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Shadesmith Implementation Shadesmith Implementation InsightInsight• Only one register modified per Only one register modified per

instructioninstruction• Ignore CC for nowIgnore CC for now

• Decompose fragment program into Decompose fragment program into several smaller programsseveral smaller programs• One program per assembly instructionOne program per assembly instruction

• Save register state on hostSave register state on host

• Iterative deepening decompositionIterative deepening decomposition

Page 25: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Iterative DeepeningIterative Deepening...ADD R0, R1, f[WPOS];MAD R1, R0, R2, R3;TEX R2, R1, TEX0, RECT;...

Page 26: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Iterative DeepeningIterative Deepening

...ADD R0, R1, f[WPOS];MAD R1, R0, R2, R3;MOV o[COLR], R1;END

...ADD R0, R1, f[WPOS];MAD R1, R0, R2, R3;TEX R2, R1, TEX0, RECT;...

Page 27: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Iterative DeepeningIterative Deepening

...ADD R0, R1, f[WPOS];MAD R1, R0, R2, R3;TEX R2, R1, TEX0, RECT;MOV o[COLR], R2;END

Later code more expensive than early codeLater code more expensive than early code

...ADD R0, R1, f[WPOS];MAD R1, R0, R2, R3;TEX R2, R1, TEX0, RECT;...

Page 28: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Basic Shadesmith FlowBasic Shadesmith Flow

• Decompose program into smaller Decompose program into smaller programsprograms• Use iterative deepening approachUse iterative deepening approach

• Run programs required to determine Run programs required to determine watch valueswatch values• One program per value watched One program per value watched

• Readback modified register to hostReadback modified register to host

• Via glReadPixels()Via glReadPixels()

• Display register values per pixel Display register values per pixel • Visualization windowsVisualization windows

• Per-pixel values on mouseoverPer-pixel values on mouseover

Page 29: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Relational Debugging EngineRelational Debugging Engine

• Build database of GPU stateBuild database of GPU state• Including pipeline state, shader stateIncluding pipeline state, shader state

• SQL-like queries generate visualizationsSQL-like queries generate visualizations• Including vertex programsIncluding vertex programs

• Raw text output available as wellRaw text output available as well

• Built on top of ChromiumBuilt on top of Chromium• Can debug any OpenGL application without Can debug any OpenGL application without

recompilationrecompilation

• Current system assumes Cg shadersCurrent system assumes Cg shaders• Approach is applicable to other GPU languagesApproach is applicable to other GPU languages

Page 30: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Relational Debugging EngineRelational Debugging Engine

Page 31: Debugging Tools Tim Purcell NVIDIA. Programming Soap Box Successful programming systems require at least three ‘tools’ Successful programming systems

Relational Debugging EngineRelational Debugging Engine

• Sketch Thursday 1:45-3:30 Room Sketch Thursday 1:45-3:30 Room 515A515A