Streamline Cache Test example - Arm Development Suite

Table of Contents:
This example illustrates the use of Streamline to reveal cache efficiency by way of simple instrumented C code.

Purpose and scope

This document describes how to build, run and analyze the Streamline cache test example provided with Arm DS IDE.
This example illustrates the use of Streamline to reveal cache efficiency by way of simple instrumented C code.

Terminology

This document refers to 'host' and 'target' systems. The 'host' system is the Linux or Windows desktop computer that you use for most of your work. The 'target' system is some Arm-based hardware (or model of such hardware) on which the example Arm Linux distribution is running.
This example is intended to be run and analyzed on an Arm Linux hardware target that supports Streamline, though it can also be run only (not analyzed) on a software model such as the FVP model.

Hardware and software requirements

Exploring the Example

This project includes a simple C file cache-test.c, Streamline annotation C source and header files streamline_annotate.c/.h, Makefile, debug launcher Streamline_cache_test-gdbserver.launch, pre-built stripped and unstripped versions of the executable cache-test, and a ready-made Streamline capture.
Open cache-test.c to view the test code. Its main() function first allocates some arrays, then fills them with some data. main() then calls xy_loop() to perform a sum in row-major ordering, then calls yx_loop() to perform a sum in column-major ordering. When the cache_test application is run (see below), it prints into the App Console of Arm DS IDE Debugger similar to:
Starting loop addition with 5000 iterations...
row-major ordering: took 157.22 ms
col-major ordering: took 1373.94 ms (8.7x slower)
        
The Streamline capture will reveal that in this case, the row-major ordering make much more efficient use of the cache than the column-major ordering.
The ready-made Streamline capture for this example can be viewed in Streamline using the Import Streamline Sample Captures wizard. To view the ready-made Streamline capture, first launch the Streamline application, then import the capture for this example by selecting File → Import..., Import Streamline Sample Captures, then selecting Linux → Arm DS IDE Cache Test Example from the list of sample captures. The capture is added to the Streamline Data view. Double-click on the capture to generate and view an Analysis Report.
To explore the Analysis Report for the example:
For more information, see Using Streamline to Guide Cache Optimization.
The master sources for the Streamline annotation C source and header files streamline_annotate.c/.h are provided in install_directory\sw\streamline\gator\annotate\.

Building this example

A pre-built executable is provided for aarch64 linux systems.
This example is intended to be built with aarch64-none-linux-gnu GCC. If you wish to modify and rebuild the example, you must have a suitable GCC installed.

Building on the command-line

To build on the command-line with the supplied make utility:
Then navigate to ...\Streamline_cache_test then type:
make
The usual make rules: clean, all and rebuild are provided in the Makefile.

Building with Eclipse

  1. In the Project Explorer view, select the project you want to build.
  2. Select Project → Build Project.
The supplied Streamline_cache_test Eclipse (makefile builder) project is used to build this example.

Running/Debugging the example on a hardware target

This example can be run and debugged on a hardware target by using the supplied Streamline_cache_test-gdbserver debug configuration.

Loading the example onto the hardware target manually

Instead of using the supplied Streamline_cache_test-gdbserver debug configuration, the example stripped executable cache_test can be manually downloaded onto the target, before the example can be run/debugged. To load this file onto the target, you can either:

Running the example manually

Instead of using the supplied Streamline_cache_test-gdbserver debug configuration, cache_test can be run directly from the target's command-line.
First, navigate to the directory on the target where cache_test is located, then execute the following command on the target:
./cache_test

Preparing to debug the example with gdbserver manually

Instead of using the supplied Streamline_cache_test-gdbserver debug configurations, you can prepare to debug cache_test with gdbserver manually.
First, navigate to the directory on the target where cache_test is located, then execute the following command on the target:
gdbserver :5000 ./cache_test &
Connect from Arm DS IDE Debugger to gdbserver, as described in Configuring a connection to a Linux application using gdbserver in Arm DS IDE Debugger User Guide.

Capturing data and annotations

Assuming the stripped cache_test executable has already been loaded to the target, it can now be analyzed with Streamline.
  1. First prepare the Streamline capture configuration in the Streamline Data view: Click on Capture & analysis options and enter a name for the capture session. In the Address field, enter the host name or IP address of the target. Select an Output path to where to save the data. Add the name of the program image to capture - for this example, Streamline must load the debug information from the debug/unstripped version of the image at ${workspace_loc}\Streamline_cache_test\cache_test. Click Save to return to Streamline Data.
  2. Press Start capture. If the capture configuration is correct, a new analysis file appears in the Streamline Data, with a Stop button within it.
  3. Start the example from the command line with: ./cache_test.
  4. After the example finishes, press Stop in Streamline Data. The collected data is then processed for viewing.
  5. When the analysis completes, Streamline automatically opens the Analysis Report. To analyze the captured data again with other settings, click on the Options gear-wheel icon on the right-hand side of the Streamline_cache_test Capture Data.
For more information, see Streamline User Guide.

Known issues and troubleshooting

See also: