Vitis™ Application Acceleration Development Flow Tutorials - Optimizing Accelerated FPGA Applications: Bloom Filter Example
A Bloom filter is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set.
In general, a Bloom filter application has use cases in data analytics, such as browsing through unstructured email and text file data to identify the documents that are closely associated with a specific user and send notifications accordingly.
In this tutorial, each document consists of an array of words where: each word is a 32-bit unsigned integer comprised of a 24-bit word ID and an 8-bit integer representing the frequency. The search array consists of words of interest to the user, and represents a smaller set of 24-bit word IDs, where each word ID has a weight associated with it, determining the importance of the word.
-
Go to the cpu_src directory, open the main.cpp file, and look at line 63.
-
The Bloom filter application is 64 KB, which is implemented as 1L<<bloom_size where bloom_size is defined as 14 in the header file sizes.h (calculated as (2^14)*4B = 64 KB).
-
The score for each document is obtained by the cumulative product of multiplying the weight of word ID with its frequency. The greater the score, the more relevant the document that matches the search array.
# Build SW version application
$ cd src/cpu_src/
$ make run
# Build FPGA accelerated application (target Xilinx U50)
$ cd src/makefile/
# You can set PF = 1, 2, 4, 8, 16 to have different number of words to be processed in parallel.
$ make build STEP=single_buffer PF=1
# Go to host application directory
$ cd build/single_buffer/kernel_1/hw
# Run application with number of documents
$ ./host 10000
Here, I run the application on CPU and actual hardware with different number of kernel (PF=2, 4, 8, 16).
Example of application running on CPU:
Example of application running on FPGA:
We can now use the actual hardware accelerated throughput then normalize to CPU throughput generate the speed up comparison in below graph.
Furthermore, we can use Vitis Analyzer to see additional information such as application timeline, resource utilization, etc.
Example of application timeline (kernel/PF=2)
Example of resource utilization (kernel/PF=8)