Source Mode (C++ Kernels)

The following guide demonstrates how to compile and run quadric C++ kernels using the quadric SDK. Additionally, if running on a quadric Development Platform, the execution of the aforementioned kernels on a FPGA will also be demonstrated.

Requirements

To compile quadric C++ kernels using the quadric SDK, you must have the following:

  1. The quadric SDK

    $ docker images
    
    REPOSITORY                                           TAG     IMAGE ID       CREATED       SIZE
    quadric-io/graphsim                                  0.8     e7b2fc44ae24   3 weeks ago   7.45GB
    
  2. Navigate to the folder where your kernel is located. In the following example, we’ll be compiling the simple_flow.cpp created in the Creating a Simple Kernel tutorial.

  3. Execute the quadric SDK in source mode using the prefered target configuration. We can optionally specify the target configuration with one of the following:

    --target q8
    --target q16
    --target q32
    

    The complete command is below:

    $ docker run -w /ws -v `pwd`:/ws -it  quadric.io/graphsim:0.8.8 source simple_flow.cpp
    

Running Kernels on the FPGA

Note

You must have a quadric Development Platform with an FPGA attached to perform the command(s) seen below. Please contact sales@quadric.io to order a quadric Development Platform.

To run the kernel above on an FPGA, we add the --fpga flag to the end of the docker command, and the --privileged flag after docker run. This flag allows docker to speak to devices on the host.

$ docker run --privileged -w /ws -v `pwd`:/ws -it quadric.io/graphsim:0.8.8 source simple_flow.cpp --fpga

Running Kernels on the Devkit

Note

You must have a quadric Devkit, and GraphSim 0.9.0 or greater to perform the command(s) seen below. Please contact sales@quadric.io to order a quadric devkit

To run the kernel above on the devkit, we add the --devkit flag to the end of the docker command, and the --privileged flag after docker run.

$ docker run --privileged -w /ws -v `pwd`:/ws -it quadric.io/graphsim:0.9.0 source simple_flow.cpp --devkit

Options

The options below for Source Mode configuration are passed in via Docker Enviornment Variables. To set them, simply prepend -e $MYSETTING=$MYVALUE to your docker run command. Examples are shown below:

Setting

Meaning

Valid Values

DEBUG

Prints a more detailed stack trace. Default False.

True or False

DDR_RD_BW

DDR read total bandwidth in Megabits per second. (i.e. 256000 mbps = 32 gigabytes per second)

Any integer number of mbps

DDR_WT_BW

DDR write total bandwidth in Megabits per second. (i.e. 256000 mbps = 32 gigabytes per second)

Any integer number of mbps

INST_MEM_SIZE

Instruction memory depth in units of instructions. Do not change.

Ant integer number of instructions

OCM_SIZE

OCM size in bytes, default is 8mb for the q8

Any integer number of bytes

DDR_RD_AVG_EFF

DDR Read average efficiency, default is 75

Any percentage

DDR_RD_MAX_EFF

DDR Read maximum efficiency, default is 80

Any percentage

DDR_WT_AVG_EFF

DDR Write average efficiency, default is 75

Any percentage

DDR_WT_MAX_EFF

DDR Write maximum efficiency, default is 80

Any percentage

Note

Unlike in Graph Mode, the number of cores and border cores is set by the --target flag, not NUM_CORES and NUM_BORDERS.

Examples

  • Running q16 ArchSim Simulator on a file (simple_flow.cpp) using a modified OCM_SIZE (in bytes):

$ docker run -e OCM_SIZE=$((8 * 1024 * 1024)) -w /ws -v `pwd`:/ws -it quadric.io/graphsim:0.8.8 source simple_flow.cpp --target q16
  • Using modified bandwidth flags. Specified in Mbits/s (e.g. 128000 Mbits/s = 16 Gigabytes per second):

$ docker run -e DDR_RD_BW=128000 -e DDR_WT_BW=128000 -w /ws -v `pwd`:/ws -it quadric.io/graphsim:0.8.8 source simple_flow.cpp
  • Using modified bandwidth efficiencies. Measured in percent. Set to 100% efficiency in the example below:

$ docker run -e DDR_RD_AVG_EFF=100 -e DDR_RD_MAX_EFF=100 -e DDR_WR_AVG_EFF=100 -e DDR_WR_MAX_EFF=100 -w /ws -v `pwd`:/ws -it quadric.io/graphsim:0.8 source simple_flow.cpp

Note

--help can be appended to any graphsim command to show a help prompt.

$ docker run -w /ws -v `pwd`:/ws -it quadric.io/graphsim:0.8.8 --help