-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #309 from LLNL/feature/performance_tests
CI Overhaul
- Loading branch information
Showing
32 changed files
with
831 additions
and
1,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,119 @@ | ||
Code Performance Diagnostics | ||
############################ | ||
Code Debugging and Diagnostics | ||
############################## | ||
|
||
Spheral uses Caliper to preform code diagnostics, such as timing. To enable this functionality in the code, Spheral needs to be configured with ``ENABLE_TIMER=ON``. Otherwise, the timing regions are no-ops for improved preformance. | ||
Valgrind | ||
======== | ||
|
||
We advise using Valgrind to check memory leaks when doing development on Spheral. | ||
When using Valgrind to check Spheral, be sure to use the provided suppression file | ||
:: | ||
|
||
./scripts/devtools/host-config-build.py <sys_type>-<spec>.cmake -DENABLE_TIMER=ON | ||
valgrind --suppressions=./scripts/devtools/valgrind_python_suppression ./spheral | ||
|
||
|
||
Querying using Caliper | ||
====================== | ||
Using Caliper | ||
============= | ||
|
||
Spheral uses Caliper to preform code diagnostics, such as timing. To enable this functionality in the code, Spheral needs to be configured with ``ENABLE_TIMER=ON``. Otherwise, the timing regions are no-ops for improved preformance. | ||
:: | ||
|
||
./scripts/devtools/host-config-build.py <sys_type>-<spec>.cmake -DENABLE_TIMER=ON | ||
|
||
Caliper is configured and started through the ``cali::ConfigManager``. | ||
The ``cali::ConfigManager`` is wrapped in a ``TimerMgr`` singleton class, which has a python interface. | ||
|
||
.. note:: | ||
``TimerMgr`` is initialized and started during ``commandLine()`` in ``src/SimulationControl/SpheralOptionParser.py``. This is because ``commandLine()`` is almost always invoked directly near the start of a problem. However, if ``commandLine()`` is not called, the timers would need to be configured and started directly using the ``TimerMgr`` class. See :ref:`below <manual_caliper>` for more details. | ||
``TimerMgr`` is initialized in ``src/SimulationControl/SpheralTimingParser.py`` which is called during ``commandLine()`` in ``src/SimulationControl/SpheralOptionParser.py``. This is because ``commandLine()`` is almost always invoked directly near the start of a problem. However, if ``commandLine()`` is not called, the timer manager would need to be configured and started directly using the ``TimerMgr`` class. See :ref:`below <manual_caliper>` for more details. | ||
|
||
By default, the Caliper configuration is set to ``spot`` and outputs Caliper files (``.cali``). | ||
For the default configuration, the Caliper files are named based on what file is being run, for example: | ||
:: | ||
|
||
python Noh-cylindrical-2d.py | ||
There are many different Caliper configurations to view various information. Here are some extra links for those who want to read or experiment with other features in Caliper that can be incorporated into Spheral: | ||
|
||
will produce a timing file called ``Noh-cylindrical-2d_YEAR_MONTH_DATE_TIME.cali`` where the file name includes the current date and time. | ||
* `Configuration basics <https://software.llnl.gov/Caliper/CaliperBasics.html#more-on-configurations>`_ | ||
* `Builtin Configuration <https://software.llnl.gov/Caliper/BuiltinConfigurations.html>`_ | ||
* `Manual Configuration <https://software.llnl.gov/Caliper/configuration.html>`_ | ||
* `Output Format <https://software.llnl.gov/Caliper/OutputFormats.html>`_ | ||
|
||
The Caliper file name can be specified using the command line | ||
:: | ||
Caliper and Adiak Options | ||
------------------------- | ||
|
||
python Noh-cylindrical-2d.py --caliperFilename 'new_test_name.cali' | ||
.. option:: --caliperFilename | ||
|
||
Different Caliper configurations can be set at the command line using ``--caliperConfig`` like so | ||
:: | ||
Name of Caliper timing file. Should include file extensions. Optional, default: ``name_of_file_YEAR_MONTH_DATE_TIME.cali``. | ||
|
||
python Noh-cylindrical-2d.py --caliperConfig 'runtime-report(output=time.txt),calc.inclusive,region.count' | ||
.. option:: --caliperConfig CONFIG_STR | ||
|
||
.. note:: | ||
The above configuration produces timing results similar to the previous ``Spheral::Timer`` method. This results in a file named ``time.txt`` with cumulative times for the nested regions as well as a count of how many times each region ran. | ||
Specify a built-in Caliper configuration or turn off timers with ``none``. Optional, default: ``spot``. | ||
|
||
Similarly, a non-default Caliper configuration can be read in from a JSON file using ``--caliperConfigJSON`` and providing the file name. | ||
Lastly, Caliper timers can be turned off using ``--caliperConfig none``. | ||
**Example**: | ||
:: | ||
|
||
There are many different Caliper configurations to view various information. Here are some extra links for those who want to read or experiment with other features in Caliper that can be incorporated into Spheral: | ||
./spheral ex_prog.py --caliperConfig 'runtime-report(output=time.txt),calc.inclusive,region.count' | ||
|
||
* `Configuration basics <https://software.llnl.gov/Caliper/CaliperBasics.html#more-on-configurations>`_ | ||
* `Builtin Configuration <https://software.llnl.gov/Caliper/BuiltinConfigurations.html>`_ | ||
* `Manual Configuration <https://software.llnl.gov/Caliper/configuration.html>`_ | ||
* `Output Format <https://software.llnl.gov/Caliper/OutputFormats.html>`_ | ||
.. note:: | ||
The configuration in the example above produces timing results similar to the previous ``Spheral::Timer`` method. This results in a file named ``time.txt`` with cumulative times for the nested regions as well as a count of how many times each region ran. | ||
|
||
.. option:: --caliperConfigJSON JSON_FILE | ||
|
||
Adding Region Timers in C++ | ||
=========================== | ||
Specify a JSON file containing a non-default Caliper configuration. Optional. | ||
|
||
So far there are two different types of regions in Spheral, using the following macros: | ||
:: | ||
.. option:: --adiakData ADIAK_DATA_STR | ||
|
||
TIME_FUNCTION | ||
Specify any Adiak data directly in the command line. Must be a string in key:value format, separated by commas. Optional. | ||
|
||
or | ||
**Example**: | ||
:: | ||
|
||
:: | ||
./spheral ex_prog.py --adiakData "test_name: the_cheat, test_num:10" | ||
|
||
TIME_BEGIN("timer_name") | ||
TIME_END("timer_name") | ||
.. note:: | ||
By default, all ``commandLine()`` inputs are added as Adiak metadata. ``--adiakData`` are for metadata that does not come through Spheral command line arguments. Adiak metadata can also be added through the python interface. See :ref:`below <python_adiak>` for more details. | ||
|
||
|
||
Adding Region Timers in C++ | ||
--------------------------- | ||
|
||
The following macros are used to create timing regions in the Spheral C++ interface: | ||
|
||
- ``TIME_FUNCTION`` can be added to the very beginning of a function and creates a region for the entire function using the function's name. ``TIME_FUNCTION`` uses just the function name and no class or parameter information, so be careful when using this method with functions that could share names. | ||
|
||
- ``TIME_BEGIN("timer_name")`` and ``TIME_END("timer_name")`` create a region between the two different calls and use the string (in this case ``timer_name``) as the name. | ||
|
||
|
||
Adding Region Timers in Python | ||
============================== | ||
------------------------------ | ||
|
||
Region timers can be added inside the python code using the following function calls: | ||
:: | ||
|
||
from SpheralUtilities import TimerMgr | ||
TimerMgr.timer_start("timer_name") | ||
some_function_call() | ||
TimerMgr.timer_end("timer_name") | ||
|
||
.. note:: | ||
IMPORTANT: All timers must have both a start and end call. Otherwise, memory issues will occur. | ||
All timers must have both a start and end call. Otherwise, memory issues will occur. | ||
|
||
.. _python_adiak: | ||
|
||
Adding Adiak Metadata in Python | ||
------------------------------- | ||
|
||
Adiak metadata can be added inside python code using the following function calls: | ||
|
||
.. code-block:: python | ||
adiak_values("value_name", value) | ||
.. _manual_caliper: | ||
|
||
Starting Caliper Manually | ||
======================== | ||
========================= | ||
|
||
As mentioned above, Caliper (not an individual Caliper timer) is normally configured and started in ``commandLine()`` python routine. However, Caliper can be directly configured and started through the python interface, if desired. This can be done by putting the following into the python file: | ||
As mentioned above, the Caliper timing manager is normally configured and started in the ``commandLine()`` routine. However, Caliper can be directly configured and started through the python interface, if desired. This can be done by putting the following into the python file: | ||
:: | ||
|
||
from SpheralUtilities import TimerMgr | ||
caliper_config = "some_configuration(output=some_filename.txt)" | ||
TimerMgr.add(caliper_config) | ||
TimerMgr.start() |
Oops, something went wrong.