File: futhark-profile.rst

package info (click to toggle)
haskell-futhark 0.25.32-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,236 kB
  • sloc: haskell: 100,484; ansic: 12,100; python: 3,440; yacc: 785; sh: 561; javascript: 558; lisp: 399; makefile: 277
file content (111 lines) | stat: -rw-r--r-- 3,873 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
.. role:: ref(emphasis)

.. _futhark-profile(1):

===============
futhark-profile
===============

SYNOPSIS
========

futhark profile JSONFILES

DESCRIPTION
===========

This tool produces human-readable profiling information based on information
collected with :ref:`futhark bench<futhark-bench(1)>`. Futhark has basic support
for profiling. The system can collect information about the run-time behaviour
of the program, and connects it as best it is able to the program source code.
This works best for the GPU backends, and not at all for the sequential
backends. The collected information can then be used to estimate the source of
inefficiencies.

USAGE
=====

The first step is to run :ref:`futhark bench<futhark-bench(1)>` on
your program, while passing ``--profile`` and ``--json``. This will
produce a JSON file containing runtime measurements, as well as
collected profiling information. If you neglect to pass ``--profile``,
the profiling information will be missing. The information in the JSON
file is complete, but it is difficult for humans to read.

The next step is to run ``futhark profile`` on the JSON file.  For a
JSON file ``prog.json``, this will create a *top level directory*
``prog.prof`` that contains files with human-readable profiling
information.  A set of files will be created for each benchmark
dataset.  If the original invocation of ``futhark bench`` included
multiple programs, then ``futhark profile`` will create subdirectories
for each program (although all inside the same top level directory).

You can pass multiple JSON files to ``futhark profile``. Each will
produce a distinct top level directory.

Files produced
--------------

Supposing a dataset ``foo``, ``futhark profile`` will produce the
following files in the top level directory.

* ``foo.log``: the running log produced during execution. Contains many details
  on dynamic behaviour, depending on the exact backend.

* ``foo.summary``: a summary of memory usage and cost centres. For the GPU
  backends, the cost centres are kernel executions and memory copies.

* ``foo.timeline``: a list of all recorded profiling events, in the order in
  which they occurred, along with their runtime and other available information,
  most importantly the source locations.

The log file is often too verbose to be useful, but the summary and timeline
should be inspected, even if the latter is sometimes fairly large.

Technicalities
--------------

The profiling information, including the log, is collected from a
*final* run performed after all the measured runs.  Profiling
information is not collected during the runs that contribute to the
runtime measurement reported by ``futhark bench``.  However, enabling
profiling may still affect performance, as it changes the
behaviour of the run time system.

Raw reports
-----------

Alternatively, the JSON file passed to ``futhark profile`` may also be a raw
profiling report as produced by the C API function ``futhark_context_report()``.
A directory is still created, but it will only contain a single set of files,
and it will not contain a log.

EXAMPLES
========

This shows the sequence of commands one might use to profile the
program ``LocVolCalib.fut``, which has three datasets associated with
it, using the ``hip`` backend::

 $ futhark bench --backend=hip --profile --json result.json LocVolCalib.fut
 $ futhark profile result.json
 $ tree result.prof/
 result.prof/
 ├── LocVolCalib-data_large.in.log
 ├── LocVolCalib-data_large.in.summary
 ├── LocVolCalib-data_medium.in.log
 ├── LocVolCalib-data_medium.in.summary
 ├── LocVolCalib-data_small.in.log
 └── LocVolCalib-data_small.in.summary

BUGS
====

Only the C-based backends currently support profiling.

The ``c`` backend does not actually record useful profiling information.

SEE ALSO
========

:ref:`futhark-bench(1)`