Back to All
Developer Blog

Introducing Qualcomm Adreno Shader Debugger: debug OpenCL kernels at the source

Sign up for Developer monthly newsletter-image

Sign up for Developer monthly newsletter

Join thousands of developers around the globe who receive latest news and updates from our monthly curated newsletter.

Sign up
Come for support, stay for the community-image

Come for support, stay for the community

Get support from experts, connect with like-minded developers, and access exclusive virtual events.

Join Developer Discord

TL;DR:

  • Debugging OpenCL Kernel execution in GPU faults  doesn’t have to involve tedious logging, validation layers, and manual experimentation. Qualcomm Adreno Shader Debugger lets you analyze and debug OpenCL kernels and individual GPU work items directly from Visual Studio Code.
  • The tool helps you inspect variables and kernel state on devices powered by Adreno GPUs, starting with the Snapdragon 8 Elite Gen 6 Mobile Platform.
  • Adreno Shader Debugger is available at no additional charge from the Qualcomm Software Center. With the Quick Start in this blog post, you can put it to work for you in no time.

You enjoy your work developing GPU kernels for applications in graphics, AI and compute. But debugging those kernels means you have to resort to logging, validation layers, and manual experimentation, which takes a lot of the fun out of it.

What if you could analyze and debug OpenCL kernels and individual GPU work items directly from Visual Studio Code? What if you could immediately inspect variables and kernel state, and set source-level breakpoints for a given GPU thread?

Now, with Qualcomm Adreno Shader Debugger, you can. It’s designed so you can debug graphics shaders and compute kernels running on devices powered by Qualcomm Adreno GPUs, starting with the Snapdragon 8 Elite Gen 6 Mobile Platform.

You can use the tool to apply breakpoints in the source code of any graphics or compute application that runs OpenCL kernels. Then you can review in-scope variable values and workload context at any breakpoint hit.

We’ve made it available in two flavors: as a Visual Studio Code (VS Code) extension and as a command-line interface (CLI) for automation and integration with existing development pipelines.

Follow the Quick Start below to see how you can integrate the tool to your workflow. (You’ll find full installation and launch details in the Qualcomm Adreno Shader Debugger User Guide.)

Quick Start – Adreno Shader Debugger

On your development workstation, navigate to Qualcomm Software Center, then download and install the archive. Next, open VS Code and install the extension from the .vsix file. (The CLI requires no installation — it's a standalone executable.)

Then, on your Android device, enable Developer Options from the Settings app, then enable USB Debugging. Finally, connect the device to the workstation over USB and click on the Adreno Shader Debugger icon in the activity bar of VS Code.

You’re now ready to start your first debug session. (For step-by-step details and for debugging with the CLI, see the Qualcomm Adreno Shader Debugger User Guide.)

1)     In the Application Config card, click Edit and provide the information needed to launch your application.

Qualcomm-image
Figure 1: Editing the application config

2) In the Debugger Config card, click Edit and enter the x, y, and z coordinates of the OpenCL work item you want to debug. 

Qualcomm-image
Figure 2: Entering coordinates of OpenCL work item

3) Set a breakpoint in the gutter next to the desired line in your OpenCL kernel source file.

Qualcomm-image
Figure 3: Setting a breakpoint

4) Click Start Debugging. The debugger launches your application on the device and begins monitoring for breakpoint hits.

5) Inspect captured data. When the selected work item hits the breakpoint, the debugger captures the item’s variable values and displays them in the Variables panel on the left.

Qualcomm-image
Figure 4: Debugger displays values of captured variables

6) Click the continue button to continue execution to the next breakpoint. 

Qualcomm-image
Figure 5: Continue button

While the application is running and no breakpoint data is available, the debugger displays: “Running - no breakpoint currently hit.”

7) When you’ve finished inspecting data, click End Debugging.

Variables and kernel state details exposed

In the Variables panel you’ll find information about the OpenCL API call that launched the kernel, including the following:

  • Kernel – Name of the kernel being executed
  • Program – Program object associated with the kernel
  • Command Queue – Command queue used to launch the kernel
  • Work Dimension – Number of dimensions used for the kernel launch (1D, 2D, or 3D)
  • Global Work Offset – Starting offset for global IDs, if specified
  • Global Work Size – Number of work-items launched in each dimension
  • Local Work Size – Work-group size used for execution

Next, you’ll see Hit Count, which is the ordinal number of the current breakpoint. Adreno Shader Debugger supports breakpoints conditioned on Hit Count.

Below Hit Count are the values of variables in scope at the breakpoint location for the selected work-item. Among others, possible values include these:

  • Scalar variables such as integers and floating-point values
  • Pointers displayed as memory addresses
  • Arrays, shown as individual elements
  • OpenCL vector types displayed as individual vector components

The debugger expands array elements and vector components individually, making it easier for you to inspect their contents without additional calculations or memory lookups.

Companion tool: Qualcomm Adreno Crash Insight

Another useful tool for graphics developers is Adreno Crash Insight, which bridges the gap between a raw GPU crash snapshot and information you can actually use to troubleshoot it. It shows you what the GPU was doing at the moment of the crash and gives you strong clues about the first places to search for offending code.

Like Adreno Shader Debugger, you can use it on devices powered by Qualcomm Adreno GPUs, starting with the Snapdragon 8 Elite Gen 6 Mobile Platform.

It’s one more in the series of GPU tools from Qualcomm Technologies that help reduce debugging time and improve your ability to troubleshoot GPU execution.

Next steps

Adreno Shader Debugger brings source-level OpenCL kernel debugging right into VS Code or your preferred development environment. It supports debugging of four VS Code application types: Standalone Deploy & Launch, Standalone Application, APK Install & Launch and APK Launch.

Take a look at the Qualcomm Adreno Shader Debugger User Guide. If you see a potential fit with your development environment, download the tool at no additional charge from the Qualcomm Software Center.

If you have questions or want help, contact us at Qualcomm Developers Discord. Let us know what you think!

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries ("Qualcomm"). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.

Snapdragon and Qualcomm branded products are products of Qualcomm Technologies, Inc. and/or its subsidiaries.

About the Author
Aravind Srinivasa Raghavan
Aravind Srinivasa RaghavanSr. Staff Engineer/Manager, Qualcomm Technologies

© Qualcomm Technologies, Inc. and/or its affiliated companies.

Snapdragon and Qualcomm branded products are products of Qualcomm Technologies, Inc. and/or its subsidiaries. Qualcomm patents are licensed by Qualcomm Incorporated.

Note: Certain services and materials may require you to accept additional terms and conditions before accessing or using those items.

References to "Qualcomm" may mean Qualcomm Incorporated, or subsidiaries or business units within the Qualcomm corporate structure, as applicable.

Qualcomm Incorporated includes our licensing business, QTL, and the vast majority of our patent portfolio. Qualcomm Technologies, Inc., a subsidiary of Qualcomm Incorporated, operates, along with its subsidiaries, substantially all of our engineering, research and development functions, and substantially all of our products and services businesses, including our QCT semiconductor business.

Materials that are as of a specific date, including but not limited to press releases, presentations, blog posts and webcasts, may have been superseded by subsequent events or disclosures.

Nothing in these materials is an offer to sell or license any of the services or materials referenced herein.