Common SQLite examples
########################

.. _examples:

This section lists recepies to frequently asked questions on "how-to's" with
NVIDIA Nsight Systems data exported in SQLite format.

General notes
**************

The data exported into SQLite database don't contain any indexes by default and
are as close to the contents of the report as possible. Therefore, for better
readability and speed of execution, queries below will alter tables.

Common helper commands
***********************

When utilizing `sqlite3` commandline tool, it's helpful to have data printed
as named columns, this can be done with:

::

    .mode column
    .headers on

Default column width is determined by the data in the first row of results. If
this doesn't work out well, you can specify widths manually:

::

    .width 10 20 50

Obtaining sample report
************************

CLI interface of Nsight Systems was used to profile ``radixSortThrust``
CUDA sample, then the resulting ``.qdrep`` file was exported using the
``nsys-exporter`` tool.

::

    nsys profile --trace=cuda,osrt radixSortThrust
    nsys-exporter --export-sqlite report1.qdrep


Transfer CUDA kernel names onto API ranges
*******************************************

.. _transfer_cuda_kernel_on_api:

.. literalinclude:: cuda_kernel_api.sql
   :language: sql

Results:

.. literalinclude:: cuda_kernel_api.results.txt


Remove ranges overlapping with overhead
****************************************

.. _overhead_overlapping:

.. literalinclude:: overhead.sql
   :language: sql

Results:

.. literalinclude:: overhead.results.txt


Backtraces for OSRT ranges
***************************

.. _osrt_callchains:

.. literalinclude:: osrt.sql
   :language: sql

Results:

.. literalinclude:: osrt.results.txt
