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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784
|
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
* Copyright (C) 2020 Federal University of Rio Grande do Sul (UFRGS)
*
* StarPU is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* StarPU is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU Lesser General Public License in COPYING.LGPL for more details.
*/
/*! \page OfflinePerformanceTools Offline Performance Tools
To get an idea of what is happening, a lot of performance feedback is available,
detailed in this chapter. The various informations should be checked for.
<ul>
<li>
What does the Gantt diagram look like? (see \ref CreatingAGanttDiagram)
<ul>
<li> If it's mostly green (tasks running in the initial context) or context specific
color prevailing, then the machine is properly
utilized, and perhaps the codelets are just slow. Check their performance, see
\ref PerformanceOfCodelets.
</li>
<li> If it's mostly purple (FetchingInput), tasks keep waiting for data
transfers, do you perhaps have far more communication than computation? Did
you properly use CUDA streams to make sure communication can be
overlapped? Did you use data-locality aware schedulers to avoid transfers as
much as possible?
</li>
<li> If it's mostly red (Blocked), tasks keep waiting for dependencies,
do you have enough parallelism? It might be a good idea to check what the DAG
looks like (see \ref CreatingADAGWithGraphviz).
</li>
<li> If only some workers are completely red (Blocked), for some reason the
scheduler didn't assign tasks to them. Perhaps the performance model is bogus,
check it (see \ref PerformanceOfCodelets). Do all your codelets have a
performance model? When some of them don't, the schedulers switches to a
greedy algorithm which thus performs badly.
</li>
</ul>
</li>
</ul>
You can also use the Temanejo task debugger (see \ref UsingTheTemanejoTaskDebugger) to
visualize the task graph more easily.
\section Off-linePerformanceFeedback Off-line Performance Feedback
\subsection GeneratingTracesWithFxT Generating Traces With FxT
StarPU can use the FxT library (see
https://savannah.nongnu.org/projects/fkt/) to generate traces
with a limited runtime overhead.
You can get a tarball from http://download.savannah.gnu.org/releases/fkt/?C=M
Compiling and installing the FxT library in the <c>$FXTDIR</c> path is
done following the standard procedure:
\verbatim
$ ./configure --prefix=$FXTDIR
$ make
$ make install
\endverbatim
In order to have StarPU to generate traces, StarPU should be configured with
the option \ref with-fxt "--with-fxt" :
\verbatim
$ ./configure --with-fxt=$FXTDIR
\endverbatim
Or you can simply point the <c>PKG_CONFIG_PATH</c> to
<c>$FXTDIR/lib/pkgconfig</c> and pass
\ref with-fxt "--with-fxt" to <c>configure</c>
When FxT is enabled, a trace is generated when StarPU is terminated by calling
starpu_shutdown(). The trace is a binary file whose name has the form
<c>prof_file_XXX_YYY</c> where <c>XXX</c> is the user name, and
<c>YYY</c> is the MPI id of the process that used StarPU (or 0 when running a sequential program).
One can change
the name of the file by setting the environnement variable \ref
STARPU_FXT_SUFFIX, its contents will be used instead of <c>prof_file_XXX</c>.
This file is saved in the
<c>/tmp/</c> directory by default, or by the directory specified by
the environment variable \ref STARPU_FXT_PREFIX.
The additional \c configure option \ref enable-fxt-lock "--enable-fxt-lock" can
be used to generate trace events which describes the locks behaviour during
the execution. It is however very heavy and should not be used unless debugging
StarPU's internal locking.
The environment variable \ref STARPU_FXT_TRACE can be set to 0 to disable the
generation of the <c>prof_file_XXX_YYY</c> file.
When the FxT trace file <c>prof_file_something</c> has been generated,
it is possible to generate different trace formats by calling:
\verbatim
$ starpu_fxt_tool -i /tmp/prof_file_something
\endverbatim
Or alternatively, setting the environment variable \ref STARPU_GENERATE_TRACE
to <c>1</c> before application execution will make StarPU do it automatically at
application shutdown.
One can also set the environment variable \ref
STARPU_GENERATE_TRACE_OPTIONS to specify options, see
<c>starpu_fxt_tool --help</c>, for example:
\verbatim
$ export STARPU_GENERATE_TRACE=1
$ export STARPU_GENERATE_TRACE_OPTIONS="-no-acquire"
\endverbatim
When running a MPI application, \ref STARPU_GENERATE_TRACE will not
work as expected (each node will try to generate trace files, thus
mixing outputs...), you have to collect the trace files from the MPI
nodes, and specify them all on the command <c>starpu_fxt_tool</c>, for
instance:
\verbatim
$ starpu_fxt_tool -i /tmp/prof_file_something*
\endverbatim
By default, the generated trace contains all informations. To reduce
the trace size, various <c>-no-foo</c> options can be passed to
<c>starpu_fxt_tool</c>, see <c>starpu_fxt_tool --help</c> .
\subsubsection CreatingAGanttDiagram Creating a Gantt Diagram
One of the generated files is a trace in the Paje format. The file,
located in the current directory, is named <c>paje.trace</c>. It can
be viewed with ViTE (http://vite.gforge.inria.fr/) a trace
visualizing open-source tool. To open the file <c>paje.trace</c> with
ViTE, use the following command:
\verbatim
$ vite paje.trace
\endverbatim
Tasks can be assigned a name (instead of the default \c unknown) by
filling the optional starpu_codelet::name, or assigning them a
performance model. The name can also be set with the field
starpu_task::name or by using \ref STARPU_NAME when calling
starpu_task_insert().
Tasks are assigned default colors based on the worker which executed
them (green for CPUs, yellow/orange/red for CUDAs, blue for OpenCLs,
red for MICs, ...). To use a different color for every type of task,
one can specify the option <c>-c</c> to <c>starpu_fxt_tool</c> or in
\ref STARPU_GENERATE_TRACE_OPTIONS. Tasks can also be given a specific
color by setting the field starpu_codelet::color or the
starpu_task::color. Colors are expressed with the following format
\c 0xRRGGBB (e.g \c 0xFF0000 for red). See
<c>basic_examples/task_insert_color</c> for examples on how to assign
colors.
To get statistics on the time spend in runtime overhead, one can use the
statistics plugin of ViTE. In Preferences, select Plugins. In "States Type",
select "Worker State". Then click on "Reload" to update the histogram. The red
"Idle" percentages are due to lack of parallelism, while the brown "Overhead"
and "Scheduling" percentages are due to the overhead of the runtime and of the
scheduler.
To identify tasks precisely, the application can also set the field
starpu_task::tag_id or setting \ref STARPU_TAG_ONLY when calling
starpu_task_insert(). The value of the tag will then show up in the
trace.
One can also introduce user-defined events in the diagram thanks to the
starpu_fxt_trace_user_event_string() function.
One can also set the iteration number, by just calling starpu_iteration_push()
at the beginning of submission loops and starpu_iteration_pop() at the end of
submission loops. These iteration numbers will show up in traces for all tasks
submitted from there.
Coordinates can also be given to data with the starpu_data_set_coordinates() or
starpu_data_set_coordinates_array() function. In the trace, tasks will then be
assigned the coordinates of the first data they write to.
Traces can also be inspected by hand by using the tool <c>fxt_print</c>, for instance:
\verbatim
$ fxt_print -o -f /tmp/prof_file_something
\endverbatim
Timings are in nanoseconds (while timings as seen in ViTE are in milliseconds).
\subsubsection CreatingADAGWithGraphviz Creating a DAG With Graphviz
Another generated trace file is a task graph described using the DOT
language. The file, created in the current directory, is named
<c>dag.dot</c> file in the current directory.
It is possible to get a graphical output of the graph by using the
<c>graphviz</c> library:
\verbatim
$ dot -Tpdf dag.dot -o output.pdf
\endverbatim
\subsubsection TraceTaskDetails Getting Task Details
Another generated trace file gives details on the executed tasks. The
file, created in the current directory, is named <c>tasks.rec</c>. This file
is in the recutils format, i.e. <c>Field: value</c> lines, and empty lines to
separate each task. This can be used as a convenient input for various ad-hoc
analysis tools. By default it only contains information about the actual
execution. Performance models can be obtained by running
<c>starpu_tasks_rec_complete</c> on it:
\verbatim
$ starpu_tasks_rec_complete tasks.rec tasks2.rec
\endverbatim
which will add <c>EstimatedTime</c> lines which contain the performance
model-estimated time (in µs) for each worker starting from 0. Since it needs
the performance models, it needs to be run the same way as the application
execution, or at least with <c>STARPU_HOSTNAME</c> set to the hostname of the
machine used for execution, to get the performance models of that machine.
Another possibility is to obtain the performance models as an auxiliary <c>perfmodel.rec</c> file, by using the <c>starpu_perfmodel_recdump</c> utility:
\verbatim
$ starpu_perfmodel_recdump tasks.rec -o perfmodel.rec
\endverbatim
\subsubsection MonitoringActivity Monitoring Activity
Another generated trace file is an activity trace. The file, created
in the current directory, is named <c>activity.data</c>. A profile of
the application showing the activity of StarPU during the execution of
the program can be generated:
\verbatim
$ starpu_workers_activity activity.data
\endverbatim
This will create a file named <c>activity.eps</c> in the current directory.
This picture is composed of two parts.
The first part shows the activity of the different workers. The green sections
indicate which proportion of the time was spent executed kernels on the
processing unit. The red sections indicate the proportion of time spent in
StartPU: an important overhead may indicate that the granularity may be too
low, and that bigger tasks may be appropriate to use the processing unit more
efficiently. The black sections indicate that the processing unit was blocked
because there was no task to process: this may indicate a lack of parallelism
which may be alleviated by creating more tasks when it is possible.
The second part of the picture <c>activity.eps</c> is a graph showing the
evolution of the number of tasks available in the system during the execution.
Ready tasks are shown in black, and tasks that are submitted but not
schedulable yet are shown in grey.
\subsubsection Animation Getting Modular Schedular Animation
When using modular schedulers (i.e. schedulers which use a modular architecture,
and whose name start with "modular-"), the call to
<c>starpu_fxt_tool</c> will also produce a <c>trace.html</c> file
which can be viewed in a javascript-enabled web browser. It shows the
flow of tasks between the components of the modular scheduler.
\subsection LimitingScopeTrace Limiting The Scope Of The Trace
For computing statistics, it is useful to limit the trace to a given portion of
the time of the whole execution. This can be achieved by calling
\code{.c}
starpu_fxt_autostart_profiling(0)
\endcode
before calling starpu_init(), to
prevent tracing from starting immediately. Then
\code{.c}
starpu_fxt_start_profiling();
\endcode
and
\code{.c}
starpu_fxt_stop_profiling();
\endcode
can be used around the portion of code to be traced. This will show up as marks
in the trace, and states of workers will only show up for that portion.
\section PerformanceOfCodelets Performance Of Codelets
The performance model of codelets (see \ref PerformanceModelExample)
can be examined by using the tool <c>starpu_perfmodel_display</c>:
\verbatim
$ starpu_perfmodel_display -l
file: <malloc_pinned.hannibal>
file: <starpu_slu_lu_model_21.hannibal>
file: <starpu_slu_lu_model_11.hannibal>
file: <starpu_slu_lu_model_22.hannibal>
file: <starpu_slu_lu_model_12.hannibal>
\endverbatim
Here, the codelets of the example <c>lu</c> are available. We can examine the
performance of the kernel <c>22</c> (in micro-seconds), which is history-based:
\verbatim
$ starpu_perfmodel_display -s starpu_slu_lu_model_22
performance model for cpu
# hash size mean dev n
57618ab0 19660800 2.851069e+05 1.829369e+04 109
performance model for cuda_0
# hash size mean dev n
57618ab0 19660800 1.164144e+04 1.556094e+01 315
performance model for cuda_1
# hash size mean dev n
57618ab0 19660800 1.164271e+04 1.330628e+01 360
performance model for cuda_2
# hash size mean dev n
57618ab0 19660800 1.166730e+04 3.390395e+02 456
\endverbatim
We can see that for the given size, over a sample of a few hundreds of
execution, the GPUs are about 20 times faster than the CPUs (numbers are in
us). The standard deviation is extremely low for the GPUs, and less than 10% for
CPUs.
This tool can also be used for regression-based performance models. It will then
display the regression formula, and in the case of non-linear regression, the
same performance log as for history-based performance models:
\verbatim
$ starpu_perfmodel_display -s non_linear_memset_regression_based
performance model for cpu_impl_0
Regression : #sample = 1400
Linear: y = alpha size ^ beta
alpha = 1.335973e-03
beta = 8.024020e-01
Non-Linear: y = a size ^b + c
a = 5.429195e-04
b = 8.654899e-01
c = 9.009313e-01
# hash size mean stddev n
a3d3725e 4096 4.763200e+00 7.650928e-01 100
870a30aa 8192 1.827970e+00 2.037181e-01 100
48e988e9 16384 2.652800e+00 1.876459e-01 100
961e65d2 32768 4.255530e+00 3.518025e-01 100
...
\endverbatim
The same can also be achieved by using StarPU's library API, see
\ref API_Performance_Model and notably the function
starpu_perfmodel_load_symbol(). The source code of the tool
<c>starpu_perfmodel_display</c> can be a useful example.
An XML output can also be printed by using the <c>-x</c> option:
\verbatim
tools/starpu_perfmodel_display -x -s non_linear_memset_regression_based
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE StarPUPerfmodel SYSTEM "starpu-perfmodel.dtd">
<!-- symbol non_linear_memset_regression_based -->
<!-- All times in us -->
<perfmodel version="45">
<combination>
<device type="CPU" id="0" ncores="1"/>
<implementation id="0">
<!-- cpu0_impl0 (Comb0) -->
<!-- time = a size ^b + c -->
<nl_regression a="5.429195e-04" b="8.654899e-01" c="9.009313e-01"/>
<entry footprint="a3d3725e" size="4096" flops="0.000000e+00" mean="4.763200e+00" deviation="7.650928e-01" nsample="100"/>
<entry footprint="870a30aa" size="8192" flops="0.000000e+00" mean="1.827970e+00" deviation="2.037181e-01" nsample="100"/>
<entry footprint="48e988e9" size="16384" flops="0.000000e+00" mean="2.652800e+00" deviation="1.876459e-01" nsample="100"/>
<entry footprint="961e65d2" size="32768" flops="0.000000e+00" mean="4.255530e+00" deviation="3.518025e-01" nsample="100"/>
</implementation>
</combination>
</perfmodel>
\endverbatim
The tool <c>starpu_perfmodel_plot</c> can be used to draw performance
models. It writes a <c>.gp</c> file in the current directory, to be
run with the tool <c>gnuplot</c>, which shows the corresponding curve.
\image html starpu_non_linear_memset_regression_based.png
\image latex starpu_non_linear_memset_regression_based.eps "" width=\textwidth
When the field starpu_task::flops is set (or \ref STARPU_FLOPS is passed to
starpu_task_insert()), <c>starpu_perfmodel_plot</c> can directly draw a GFlops
curve, by simply adding the <c>-f</c> option:
\verbatim
$ starpu_perfmodel_plot -f -s chol_model_11
\endverbatim
This will however disable displaying the regression model, for which we can not
compute GFlops.
\image html starpu_chol_model_11_type.png
\image latex starpu_chol_model_11_type.eps "" width=\textwidth
When the FxT trace file <c>prof_file_something</c> has been generated, it is possible to
get a profiling of each codelet by calling:
\verbatim
$ starpu_fxt_tool -i /tmp/prof_file_something
$ starpu_codelet_profile distrib.data codelet_name
\endverbatim
This will create profiling data files, and a <c>distrib.data.gp</c> file in the current
directory, which draws the distribution of codelet time over the application
execution, according to data input size.
\image html distrib_data.png
\image latex distrib_data.eps "" width=\textwidth
This is also available in the tool <c>starpu_perfmodel_plot</c>, by passing it
the fxt trace:
\verbatim
$ starpu_perfmodel_plot -s non_linear_memset_regression_based -i /tmp/prof_file_foo_0
\endverbatim
It will produce a <c>.gp</c> file which contains both the performance model
curves, and the profiling measurements.
\image html starpu_non_linear_memset_regression_based_2.png
\image latex starpu_non_linear_memset_regression_based_2.eps "" width=\textwidth
If you have the statistical tool <c>R</c> installed, you can additionally use
\verbatim
$ starpu_codelet_histo_profile distrib.data
\endverbatim
Which will create one <c>.pdf</c> file per codelet and per input size, showing a
histogram of the codelet execution time distribution.
\image html distrib_data_histo.png
\image latex distrib_data_histo.eps "" width=\textwidth
\section DataTrace Data trace and tasks length
It is possible to get statistics about tasks length and data size by using :
\verbatim
$ starpu_fxt_data_trace filename [codelet1 codelet2 ... codeletn]
\endverbatim
Where filename is the FxT trace file and codeletX the names of the codelets you
want to profile (if no names are specified, <c>starpu_fxt_data_trace</c> will profile them all).
This will create a file, <c>data_trace.gp</c> which
can be executed to get a <c>.eps</c> image of these results. On the image, each point represents a
task, and each color corresponds to a codelet.
\image html data_trace.png
\image latex data_trace.eps "" width=\textwidth
\section TraceStatistics Trace Statistics
More than just codelet performance, it is interesting to get statistics over all
kinds of StarPU states (allocations, data transfers, etc.). This is particularly
useful to check what may have gone wrong in the accurracy of the SimGrid
simulation.
This requires the <c>R</c> statistical tool, with the <c>plyr</c>,
<c>ggplot2</c> and <c>data.table</c> packages. If your system
distribution does not have packages for these, one can fetch them from
<c>CRAN</c>:
\verbatim
$ R
> install.packages("plyr")
> install.packages("ggplot2")
> install.packages("data.table")
> install.packages("knitr")
\endverbatim
The <c>pj_dump</c> tool from <c>pajeng</c> is also needed (see
https://github.com/schnorr/pajeng)
One can then get textual or <c>.csv</c> statistics over the trace states:
\verbatim
$ starpu_paje_state_stats -v native.trace simgrid.trace
"Value" "Events_native.csv" "Duration_native.csv" "Events_simgrid.csv" "Duration_simgrid.csv"
"Callback" 220 0.075978 220 0
"chol_model_11" 10 565.176 10 572.8695
"chol_model_21" 45 9184.828 45 9170.719
"chol_model_22" 165 64712.07 165 64299.203
$ starpu_paje_state_stats native.trace simgrid.trace
\endverbatim
An other way to get statistics of StarPU states (without installing <c>R</c> and
<c>pj_dump</c>) is to use the <c>starpu_trace_state_stats.py</c> script which parses the
generated <c>trace.rec</c> file instead of the <c>paje.trace</c> file. The output is similar
to the previous script but it doesn't need any dependencies.
The different prefixes used in <c>trace.rec</c> are:
\verbatim
E: Event type
N: Event name
C: Event category
W: Worker ID
T: Thread ID
S: Start time
\endverbatim
Here's an example on how to use it:
\verbatim
$ python starpu_trace_state_stats.py trace.rec | column -t -s ","
"Name" "Count" "Type" "Duration"
"Callback" 220 Runtime 0.075978
"chol_model_11" 10 Task 565.176
"chol_model_21" 45 Task 9184.828
"chol_model_22" 165 Task 64712.07
\endverbatim
<c>starpu_trace_state_stats.py</c> can also be used to compute the different
efficiencies. Refer to the usage description to show some examples.
And one can plot histograms of execution times, of several states for instance:
\verbatim
$ starpu_paje_draw_histogram -n chol_model_11,chol_model_21,chol_model_22 native.trace simgrid.trace
\endverbatim
and see the resulting pdf file:
\image html paje_draw_histogram.png
\image latex paje_draw_histogram.eps "" width=\textwidth
A quick statistical report can be generated by using:
\verbatim
$ starpu_paje_summary native.trace simgrid.trace
\endverbatim
it includes gantt charts, execution summaries, as well as state duration charts
and time distribution histograms.
Other external Paje analysis tools can be used on these traces, one just needs
to sort the traces by timestamp order (which not guaranteed to make recording
more efficient):
\verbatim
$ starpu_paje_sort paje.trace
\endverbatim
\section TheoreticalLowerBoundOnExecutionTime Theoretical Lower Bound On Execution Time
StarPU can record a trace of what tasks are needed to complete the
application, and then, by using a linear system, provide a theoretical lower
bound of the execution time (i.e. with an ideal scheduling).
The computed bound is not really correct when not taking into account
dependencies, but for an application which have enough parallelism, it is very
near to the bound computed with dependencies enabled (which takes a huge lot
more time to compute), and thus provides a good-enough estimation of the ideal
execution time.
\ref TheoreticalLowerBoundOnExecutionTimeExample provides an example on how to
use this.
\section TheoreticalLowerBoundOnExecutionTimeExample Theoretical Lower Bound On Execution Time Example
For kernels with history-based performance models (and provided that
they are completely calibrated), StarPU can very easily provide a
theoretical lower bound for the execution time of a whole set of
tasks. See for instance <c>examples/lu/lu_example.c</c>: before
submitting tasks, call the function starpu_bound_start(), and after
complete execution, call starpu_bound_stop().
starpu_bound_print_lp() or starpu_bound_print_mps() can then be used
to output a Linear Programming problem corresponding to the schedule
of your tasks. Run it through <c>lp_solve</c> or any other linear
programming solver, and that will give you a lower bound for the total
execution time of your tasks. If StarPU was compiled with the library
<c>glpk</c> installed, starpu_bound_compute() can be used to solve it
immediately and get the optimized minimum, in ms. Its parameter
<c>integer</c> allows to decide whether integer resolution should be
computed and returned
The <c>deps</c> parameter tells StarPU whether to take tasks, implicit
data, and tag dependencies into account. Tags released in a callback
or similar are not taken into account, only tags associated with a task are.
It must be understood that the linear programming
problem size is quadratic with the number of tasks and thus the time to solve it
will be very long, it could be minutes for just a few dozen tasks. You should
probably use <c>lp_solve -timeout 1 test.pl -wmps test.mps</c> to convert the
problem to MPS format and then use a better solver, <c>glpsol</c> might be
better than <c>lp_solve</c> for instance (the <c>--pcost</c> option may be
useful), but sometimes doesn't manage to converge. <c>cbc</c> might look
slower, but it is parallel. For <c>lp_solve</c>, be sure to try at least all the
<c>-B</c> options. For instance, we often just use <c>lp_solve -cc -B1 -Bb
-Bg -Bp -Bf -Br -BG -Bd -Bs -BB -Bo -Bc -Bi</c> , and the <c>-gr</c> option can
also be quite useful. The resulting schedule can be observed by using
the tool <c>starpu_lp2paje</c>, which converts it into the Paje
format.
Data transfer time can only be taken into account when <c>deps</c> is set. Only
data transfers inferred from implicit data dependencies between tasks are taken
into account. Other data transfers are assumed to be completely overlapped.
Setting <c>deps</c> to 0 will only take into account the actual computations
on processing units. It however still properly takes into account the varying
performances of kernels and processing units, which is quite more accurate than
just comparing StarPU performances with the fastest of the kernels being used.
The <c>prio</c> parameter tells StarPU whether to simulate taking into account
the priorities as the StarPU scheduler would, i.e. schedule prioritized
tasks before less prioritized tasks, to check to which extend this results
to a less optimal solution. This increases even more computation time.
\section starvz Trace visualization with StarVZ
Creating views with StarVZ (see: https://github.com/schnorr/starvz) is made up of two steps. The initial
stage consists of a pre-processing of the traces generated by the application.
The second step consists of the analysis itself and is carried out with the
aid of R packages. To download and install StarVZ, it is necessary to have R,
pajeng and the following packages:
\verbatim
# For pajeng
apt install -y git cmake build-essential libboost-dev asciidoc flex bison
git clone git://github.com/schnorr/pajeng.git
mkdir -p pajeng/b ; cd pajeng/b
cmake ..
make
# For R tidyverse
apt install -y r-base libxml2-dev libssl-dev libcurl4-openssl-dev libgit2-dev libboost-dev
\endverbatim
To install the StarVZ the following commands can be used:
\verbatim
git clone https://github.com/schnorr/starvz.git
echo "install.packages(c('tidyverse', 'devtools'), repos = 'https://cloud.r-project.org')" | R --vanilla
echo "library(devtools); devtools::install_local(path='./starvz/R_package')" | R --vanilla
\endverbatim
To generate traces from an application, it is necessary to set \ref STARPU_GENERATE_TRACE.
and build StarPU with FxT. Then, Step 1 of StarVZ can be used on a folder with
StarPU FxT traces:
\verbatim
export PATH=starvz/:$PATH
export PATH=pajeng/b:$PATH
export PATH=$STARPU_HOME/bin:$PATH
./starvz/src/phase1-workflow.sh /tmp/ ""
\endverbatim
Then the second step can be executed directly in R, StarVZ enables a set of
different plots that can be configured on a .yaml file. A default file is provided
<c>full_config.yaml</c>; also the options can be changed directly in R.
\verbatim
library(starvz)
dtrace <- the_fast_reader_function("./")
pajer <- config::get(file = "starvz/full_config.yaml")
pajer$starpu$active = TRUE
pajer$submitted$active = TRUE
pajer$st$abe$active = TRUE
plot <- the_master_function(dtrace)
\endverbatim
An example of visualization follows:
\image html starvz_visu.png
\image latex starvz_visu.eps "" width=\textwidth
\section MemoryFeedback Memory Feedback
It is possible to enable memory statistics. To do so, you need to pass
the option \ref enable-memory-stats "--enable-memory-stats" when running <c>configure</c>. It is then
possible to call the function starpu_data_display_memory_stats() to
display statistics about the current data handles registered within StarPU.
Moreover, statistics will be displayed at the end of the execution on
data handles which have not been cleared out. This can be disabled by
setting the environment variable \ref STARPU_MEMORY_STATS to <c>0</c>.
For example, if you do not unregister data at the end of the complex
example, you will get something similar to:
\verbatim
$ STARPU_MEMORY_STATS=0 ./examples/interface/complex
Complex[0] = 45.00 + 12.00 i
Complex[0] = 78.00 + 78.00 i
Complex[0] = 45.00 + 12.00 i
Complex[0] = 45.00 + 12.00 i
\endverbatim
\verbatim
$ STARPU_MEMORY_STATS=1 ./examples/interface/complex
Complex[0] = 45.00 + 12.00 i
Complex[0] = 78.00 + 78.00 i
Complex[0] = 45.00 + 12.00 i
Complex[0] = 45.00 + 12.00 i
#---------------------
Memory stats:
#-------
Data on Node #3
#-----
Data : 0x553ff40
Size : 16
#--
Data access stats
/!\ Work Underway
Node #0
Direct access : 4
Loaded (Owner) : 0
Loaded (Shared) : 0
Invalidated (was Owner) : 0
Node #3
Direct access : 0
Loaded (Owner) : 0
Loaded (Shared) : 1
Invalidated (was Owner) : 0
#-----
Data : 0x5544710
Size : 16
#--
Data access stats
/!\ Work Underway
Node #0
Direct access : 2
Loaded (Owner) : 0
Loaded (Shared) : 1
Invalidated (was Owner) : 1
Node #3
Direct access : 0
Loaded (Owner) : 1
Loaded (Shared) : 0
Invalidated (was Owner) : 0
\endverbatim
\section DataStatistics Data Statistics
Different data statistics can be displayed at the end of the execution
of the application. To enable them, you need to define the environment
variable \ref STARPU_ENABLE_STATS. When calling
starpu_shutdown() various statistics will be displayed,
execution, MSI cache statistics, allocation cache statistics, and data
transfer statistics. The display can be disabled by setting the
environment variable \ref STARPU_STATS to <c>0</c>.
\verbatim
$ ./examples/cholesky/cholesky_tag
Computation took (in ms)
518.16
Synthetic GFlops : 44.21
#---------------------
MSI cache stats :
TOTAL MSI stats hit 1622 (66.23 %) miss 827 (33.77 %)
...
\endverbatim
\verbatim
$ STARPU_STATS=0 ./examples/cholesky/cholesky_tag
Computation took (in ms)
518.16
Synthetic GFlops : 44.21
\endverbatim
// TODO: data transfer stats are similar to the ones displayed when
// setting STARPU_BUS_STATS
*/
|