Code Base Investigator#

Code Base Investigator (CBI) is an analysis tool that provides insight into the portability and maintainability of an application’s source code.

  • Measure “code divergence” to understand how much code is specialized for different compilers, operating systems, hardware micro-architectures and more.

  • Visualize the distance between the code paths used to support different compilation targets.

  • Identify stale, legacy, code paths that are unused by any compilation target.

  • Export metrics and code path information required for P3 analysis using other tools.

Installation#

The latest release of CBI is version 1.2.0. To download and install this release, run the following:

$ git clone --branch 1.2.0 https://github.com/intel/code-base-investigator.git
$ cd code-base-investigator
$ pip install .

We strongly recommend installing CBI within a virtual environment.

Getting Started#

Using CBI to analyze a code base is a three step process. For more detailed information on any of these steps, we recommend that you work through the tutorial using the sample code base.

  1. Generate a compilation database for each platform

    You can use the CMAKE_EXPORT_COMPILE_COMMANDS option with CMake, intercept the compilation of an application using Bear, or write a database manually.

  1. Create a TOML file describing the analysis

    CBI reads platform definitions from a TOML file, like the one shown below:

    [platform.cpu]
    commands = "cpu/compile_commands.json"
    
    [platform.gpu]
    commands = "gpu/compile_commands.json"
    
  2. Launch CBI

    To perform a full analysis, launch codebasin with no arguments except the input TOML file:

    $ codebasin analysis.toml
    

    To see the other options that are available, run codebasin -h.