Search code examples
androidandroid-ndkarmprofilingmali

How to Profile OpenCL code on Android run on an ARM Mali GPU


How can I profiler a Mali GPU on an Android device with native code?

Suppose a binary on the Android device is run as "./run.bin". This binary is not packaged as an apk. That binary contains OpenCL code. How can I profile this? I am ideally looking for a similar output as Nvidia's Nsight profiler.

I understand that the Streamline Performance Analyzer can profile applications on Android. However, the documentation outlines how to capture data for an apk started through Streamline. Can I somehow collect data for a native binary?


Solution

  • you've got your answer on Arm community forums, but I'll put it here for others as well:

    You will need a debug version of the binary and you will need to use the gatord tool.

    Push gatord (located at Arm_Performance_Studio/streamline/bin/android/arm64/) to the android device and then in adb shell run the exectuable like below, giving the name of the capture as part of output, eg something like:

    ./gatord -o /data/local/tmp/capture.apc -A application args...

    ought to work.

    Refer to --help for a list of command line arguments used to configure the target (see for example --print counters, and -C for configuration).

    You can also use the Streamline UI to make a live capture from the target in this configuration (which will allow you to apply GPU templates if you are interested in such things)... run gatord like:

    ./gatord -A application args...

    and then use the "TCP/IP" option, rather than the "Android" option in the "Start" tab. If your device is connected by adb/usb, and the adb command is in the PATH (or is configured in the Streamline UI preferences) then you should see the device appear in the list of available devices.