Skip to content
Snippets Groups Projects
total-view.md 4.77 KiB
Newer Older
  • Learn to ignore specific revisions
  • David Hrbáč's avatar
    David Hrbáč committed
    # Total View
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    TotalView is a GUI-based source code multi-process, multi-thread debugger.
    
    David Hrbáč's avatar
    David Hrbáč committed
    
    ## License and Limitations for Anselm Users
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    On Anselm users can debug OpenMP or MPI code that runs up to 64 parallel processes. These limitation means that:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    
    David Hrbáč's avatar
    David Hrbáč committed
        1 user can debug up 64 processes, or
        32 users can debug 2 processes, etc.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    Debugging of GPU accelerated codes is also supported.
    
    You can check the status of the licenses here:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ cat /apps/user/licenses/totalview_features_state.txt
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
        # totalview
        # -------------------------------------------------
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        # FEATURE                       TOTAL   USED AVAIL
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        # -------------------------------------------------
    
    David Hrbáč's avatar
    David Hrbáč committed
        TotalView_Team                     64      0     64
        Replay                             64      0     64
        CUDA                               64      0     64
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Compiling Code to Run With TotalView
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ### Modules
    
    Load all necessary modules to compile the code. For example:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ ml intel **or** ml foss
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    Load the TotalView module:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ ml totalview/8.12
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    Compile the code:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ mpicc -g -O0 -o test_debug test.c
    $ mpif90 -g -O0 -o test_debug test.f
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ### Compiler Flags
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    Before debugging, you need to compile your code with theses flags:
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        \* **-g** : Generates extra debugging information usable by GDB. **-g3** includes even more debugging information. This option is available for GNU and INTEL C/C++ and Fortran compilers.
        \* **-O0** : Suppress all optimizations.
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Starting a Job With TotalView
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Be sure to log in with an X window forwarding enabled. This could mean using the -X in the ssh:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    local $ ssh -X username@anselm.it4i.cz
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Other options is to access login node using VNC. Please see the detailed information on how to use graphic user interface on Anselm.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    From the login node an interactive session with X windows forwarding (-X option) can be started by following command:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ qsub -I -X -A NONE-0-0 -q qexp -lselect=1:ncpus=16:mpiprocs=16,walltime=01:00:00
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Then launch the debugger with the totalview command followed by the name of the executable to debug.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ### Debugging a Serial Code
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To debug a serial code use:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ totalview test_debug
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ### Debugging a Parallel Code - Option 1
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To debug a parallel code compiled with **OpenMPI** you need to setup your TotalView environment:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! hint
    
        To be able to run parallel debugging procedure from the command line without stopping the debugger in the mpiexec source code you have to add the following function to your `~/.tvdrc` file:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        proc mpi_auto_run_starter {loaded_id} {
    
    David Hrbáč's avatar
    David Hrbáč committed
            set starter_programs {mpirun mpiexec orterun}
            set executable_name [TV::symbol get $loaded_id full_pathname]
            set file_component [file tail $executable_name]
    
            if {[lsearch -exact $starter_programs $file_component] != -1} {
                puts "*************************************"
                puts "Automatically starting $file_component"
                puts "*************************************"
                dgo
            }
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    
        # Append this function to TotalView's image load callbacks so that
        # TotalView run this program automatically.
    
        dlappend TV::image_load_callbacks mpi_auto_run_starter
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The source code of this function can be also found in
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ /apps/mpi/openmpi/intel/1.6.5/etc/openmpi-totalview.tcl
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        You can also add only following line to you ~/.tvdrc file instead of the entire function:
    
        **source /apps/mpi/openmpi/intel/1.6.5/etc/openmpi-totalview.tcl**
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    You need to do this step only once.
    
    Now you can run the parallel debugger using:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ mpirun -tv -n 5 ./test_debug
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    When following dialog appears click on "Yes"
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ![](../../../img/totalview1.png)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    At this point the main TotalView GUI window will appear and you can insert the breakpoints and start debugging:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ![](../../../img/totalview2.png)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ### Debugging a Parallel Code - Option 2
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Other option to start new parallel debugging session from a command line is to let TotalView to execute mpirun by itself. In this case user has to specify a MPI implementation used to compile the source code.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The following example shows how to start debugging session with Intel MPI:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```console
    $ ml intel
    $ ml totalview
    $ totalview -mpi "Intel MPI-Hydra" -np 8 ./hello_debug_impi
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    After running previous command you will see the same window as shown in the screenshot above.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    More information regarding the command line parameters of the TotalView can be found TotalView Reference Guide, Chapter 7: TotalView Command Syntax.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Documentation
    
    
    [1] The [TotalView documentation](http://www.roguewave.com/support/product-documentation/totalview-family.aspx#totalview) web page is a good resource for learning more about some of the advanced TotalView features.