170 likes | 351 Views
TotalView Debugger. Dr. Fabrizio Gala Dipartimento di Scienze di Base e Applicate Per l’Ingegneria – Sezione di Fisica Via Scarpa 14-16 00141 Rome , Italy. Outline. Starting TotalView on CRESCO Basic Debugging Root Window Stepping Toolbar Action Points Visualizing Arrays
E N D
TotalViewDebugger Dr. Fabrizio Gala Dipartimento di Scienze di Base e Applicate Per l’Ingegneria – Sezione di Fisica Via Scarpa 14-16 00141 Rome, Italy
Outline • StartingTotalView on CRESCO • BasicDebugging • RootWindow • Stepping Toolbar • ActionPoints • VisualizingArrays • Visualizing C++ Sturctures • MPI Debugging • MessageQueueGraph • MemoryMenagement • MemoryDebugging • SegmentationFaults • MemoryLeaks • Online Informations
StartingTotalView on CRESCO Open a terminal throughFARO Compile the code todebug Load the TotalViewmodule Submit the job PARALLEL ENVIRONMENT http://www.cresco.enea.it/nx.html mpicc–g –O0 –omyprogram.xmyprogram.c ~/> moduleloadtotalview bsub–n#procs-I –a tv –q#queuetotalview#exe MPI TASK NUMBER
RootWindow The RootWindowcontains a listofall the processes and threadsyou are currentlydebugging. ROOT WINDOW • T = sTopped • B = Breakpoint • E = Error • W = Watchpoint • R = Running • M = Mixed ACTION POINT ID NUMBER STATUS INFO : 4
Stepping Toolbar • Go : run the program • Halt : pause the execution • Kill : ends the process • Restart : equal to Kill plus Go • Next : executes all code on a line (i.e. a subroutine call) • Step : executes the line • Out : run up to return of a subroutine • Run to : runs to a selected line 5
ActionPoints To set anactionpoint, click on the linenumber in the source panel and thenchoosewhatkindofactionyouneed. SOURCE PANEL • The basicactionpoints are: • Breakpoint : stopsexecutionof the processesofthreadsthatreachit, • Evaluationpoint: executes a code fragmentwhenitisreached, • ProcessBarrier Point : holdeachprocesswhenitreaches the barrierpointuntilallprocess in the grouphavereached the barrir point 6
VisualizingArrays STACK FRAME PANEL Afterhaving set a breakpoint, itispossibletohave a look inside a variable, bysimplyselecting the variable in the Stack Frame Panel and thendivingby a double-click. This can beusefulifonewantstoexplore a variableamongdifferentthreads. THREAD INDEX 7
Visualizing C++ Structures Tocalculate the sizeofanyobjecttype, the compiler must take into account anyaddress alignmentthatmaybeneedtomeetefficiency or achitecturalconstraints. The compiler accomplishesthis task byinsertingunusedpaddingbytesbetweenmembersasneededtosatisfy the alignmentrequirements. Theremayalsobepadding at the end of a structuretoensureproperalignment in case the structureiseverusedasanelementofanarray. SelectingView > Paddinggives: CODE 8
MessageQueueGraph (1) Tools > MessageQueueGraphdisplays a windowthatshows a graphicrepresentation of the state ofmessagequeue information. Thisgraphshowsyou the state ofyour program at a particularinstant. WARNING: WORKS only ON CRESCO 1 or 2 MPI MESSAGE TAG • GREENPendingSends • BLUEPendingReceives • REDUnespectedMsgs STATUS INFO : PROC ID 9 PSEUDO CODE
MessageQueueGraph (2) • Pendingmessagesoften indicate that a process can'tkeep up with the amountof work itisexpectedtoperform.Thesemessages indicate placeswhereyoumaybeabletoimproveyourprogram'sefficiency. • Unexpectedmessages can indicate thatsomethingis wrong withyourprogrambecause the receivingprocessdoesn'tknowhowtoprocess the message. • Loops in the graphmay indicate deadlocks.( Cycles can behighlitedbyOptions > Cycle Detection) PSEUDO CODE DEADLOCK EXAMPLE 10
MemoryDebugging (1) Select the Debug > EnableMemoryDebuggingcommandbeforestarting the program. When the programmakes a memoryrequest, MemoryScaperecords the stackframes thatexistedwhen the actionoccurred. MemoryScapestops the programexecutionwhenoneof the followingeventsoccurs: • Freeingmemorythatisalreadyfreed, • Freeing the wrong address • Freeeinganinteriorpointer, • Misaligningblocks WARNING: NOT WORKING correcltywithOpenMPIcompiledwithintel 11
MemoryDebugging (2) MemoryUsage Chart Report displays the memoryoccupiedbyeachprocess: TEXT: The amountofmemoryusedforstoring the program'smachine code instructions. DATA: The amountofmemoryusedforstoring uninitialized and initialized data. HEAP: The amountofmemorycurrentlybeing usedfor data created at runtime (i.e. allocatedpointers). STACK: The amountofmemoryusedby the currentlyexecuting routine and all the routines in itsbacktrace. 12
MemoryDebugging (3) Looking at how the programisusingmemorymay help in understandingwhereparallelization can beimproved. UNBALANCED MEMORY OCCUPANCY AMONG PROCESSES 13
SegmentationFaults When aSegmentation Fault occurs,MemoryScapekeepstrackof the event, you can have a look at it in Debug > MemoryEventDetails) CODE 14
In Leak Detection Reports > Source Report MemoryLeaks (1) A memoryleakoccurswhen the programincorrectlymenagesmemoryallocations. As a consequence, a memoryleak can diminish the performance byreducing the amountofavailablememory. Eventually, in the worst case, toomuchof the availablememorymaybecomeallocated and all or part of the system e stopsworkingcorrectly, the applicationfails, or the system slows down unacceptably. POINTERS ALLOCATION MEMORY PSEUDO CODE The instructionherefreesonly A, nottmp MEMORY LEAK 15
MemoryLeaks (2) In Leak Detection Reports > Source Report in facttellsus : sizeof (double) 16
Online Information TotalViewdocumentation can befoundhere: http://www.roguewave.com/support/product-documentation/totalview.aspx THANKS TO Prof. G. ZOLLO and Dr. A. SCHIAVI & THANK YOU TO EVERYBODY FOR THE ATTENTION 17