Home

Awesome

coda

CODA: Burst Compiler Static Code Analysis

CODA is a static code analysis tool for the new burst compiler in Unity. It works by parsing the assembly language code output by the BurstCompiler Inspector, running the code through llvm-mca (with some sanitizations since llvm-mca cannot directly parse the code generated by the Burst Inspector). The output will show a graphical timeline of each instruction and how long it would take to run on the selected CPU (see limitations below), a profile report which can associate the timeline with your original C# burst job code (if you have enhanced disassembly turned on) and the detailed report produced by llvm-mca. If you've used llvm-mca or Intel's IACA tool before, you should feel right at home.

Bug reports and PRs are welcome!

Note: This is a personal hackathon project written in 12 hours. Here there be dragons. Windows ONLY for now.

Static analysis tools are best used to analyze a kernel with no branches, calls or other conditionals. To support this, I've added a begin and end marker function call which will show up in the assembly output by the burst inspector and can be used to feed the correct instruction block to llvm-mca for analysis.

Since this is a quickly hacked together static analysis tool, there are a number of limitations:

Installing

For now, the way to install this tool is to clone the project and copy the project contents to your Unity project assets folder under Assets/TapVoxel/Coda

The tool currently makes some assumptions about this path, so use exactly the path above.

Once copied to your project, you can run it by accessing the menu item Window / TapVoxel / Coda / Show Coda Manager

Running an analysis

  1. Start the Burst Inspector and select your burst job in the left-hand side. The recommended options are:
  1. Click Refresh Disassembly
  2. Click Copy to Clipboard
  3. Start the Coda Manager if you haven't already
  4. Chose which CPU you'd like to run the simulation on
  5. Click Paste Assembly Code and Analyze

At this point, the timeline should be populated and you should be able to click on the Show profile analysis and Show detailed analysis buttons.

Screenshots

CODA Timeline CODA Profile CODA Detailed Report

Future

I'd like to get this running on Mac and Linux. To do so, llvm-mca needs to be available on each platform and the tool needs to be modified to run llvm-mca from the path. Otherwise the code is mostly just plain old (rusty) C# and should be reasonably portable.