Quickstart with FPGA Acceleration using InAccel

InAccel
3 min readMar 28, 2023

Field-Programmable Gate Arrays (FPGAs) are a type of programmable hardware that can be customized to execute specific tasks. Xilinx FPGAs, such as the Alveo and AWS f1 boards, offer high-performance computing capabilities and are commonly used in data center applications. Harnessing the full power of these devices, however, can be a daunting task, especially for those new to FPGA programming. In this post, we will show you how to get started with FPGA acceleration using InAccel, a toolkit that simplifies FPGA management and allows you to package and deploy FPGA accelerated applications with ease.

Before we begin, make sure you have access to a Xilinx FPGA board and have installed Docker on your system. If you don’t have a board, you can still follow along and use the provided example to see how FPGA acceleration works.

Installing Docker

Docker is a containerization platform that allows you to package and distribute software in a lightweight, portable container. It is a prerequisite for using InAccel. If you haven’t installed Docker, you can do so with the following commands:

curl -sS https://get.docker.com | sh
sudo systemctl enable --now docker

Installing InAccel

InAccel is a product that allows you to build, ship, and run FPGA accelerated applications. Here’s how to install it:

curl -sS https://setup.inaccel.com/repository | sh -s install
sudo systemctl enable --now inaccel

If the Xilinx Runtime (XRT) is not already installed, you can install it using the following Docker InAccel command:

sudo docker inaccel run driver

Using InAccel

Now that you have Docker and InAccel installed, let’s see how to use InAccel to accelerate a simple example: vector addition.

First make sure that InAccel FPGA Operator is running:

sudo docker inaccel -e license=<license> -e monitor_port=<port> up

You can replace <license> and <port> with your specific values. The command starts the InAccel FPGA Operator services and allows you to monitor the FPGA performance using a web UI available at http://localhost:<port>.

You can also query information about the available FPGAs using the following command:

sudo docker inaccel exec get fpga

This will give you a JSON output containing information about the FPGA devices available on the machine. On AWS f1, the output of the above command would look like this:

[
{
"id": "...",
"vendor": "xilinx",
"name": "aws-vu9p-f1",
"version": "dynamic-shell",
...
}
]

To install the vector addition accelerator for your specific platform, use the following command, replacing <platform> with the appropriate platform identifier:

inaccel bitstream install --mode=others https://store.inaccel.com/artifactory/bitstreams/<platform>/vector/1/1addition

For AWS f1, <platform> would be xilinx/aws-vu9p-f1/dynamic-shell/aws. To find out which platforms are supported for the vector addition accelerator, please visit the InAccel GitHub repository at https://github.com/inaccel/vadd. Once you have installed the accelerator, you can use InAccel Coral API to invoke it.

The following Python code uses InAccel Coral to accelerate vector addition on an FPGA. The code generates two random arrays of float32 type, performs vector addition on them using the accelerator, and verifies the result against the CPU-based computation.

import inaccel.coral as inaccel
import numpy as np

size = np.int32(1024)

with inaccel.allocator:
a = np.random.rand(size).astype(np.float32)
b = np.random.rand(size).astype(np.float32)
c = np.ndarray(size, dtype=np.float32)

vadd = inaccel.request('vector.addition')
vadd.arg(a).arg(b).arg(c).arg(size)

inaccel.submit(vadd).result()

assert np.array_equal(c, a + b)

Before running the code, make sure to install the InAccel Coral API package using pip:

pip install coral-api

Note that coral-api works with Python >= 3.8.

And that's it! You should now have a working vector addition accelerator on your Xilinx FPGA.

Conclusion

In this post, we have demonstrated how to get started with FPGA acceleration using InAccel. While we used vector addition as a simple example, the techniques and tools presented here can be applied to a wide range of other compute-intensive applications, providing significant speedups over traditional CPU-based approaches.

FPGA acceleration is a rapidly growing field, and as more developers seek to harness the power of these devices, products like InAccel will become increasingly important. With the right knowledge and tools, it is possible to create high-performance FPGA-based solutions that can tackle the most demanding compute-intensive workloads.

We hope this guide has provided you with a useful starting point for exploring FPGA acceleration and has encouraged you to experiment with your own FPGA-based solutions. With a little practice and experimentation, you can unlock the full potential of Xilinx FPGAs and take your applications to the next level.

--

--

InAccel

InAccel is a product for you to build, ship and run FPGA accelerated applications