Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide

ID 683846
Date 6/21/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

11.1.8. Using an OpenCL Library that Works with Simple Functions (Example 1)

Intel® provides an OpenCL™ library design example of a simple kernel that uses a library containing RTL implementations of three double-precision functions: sqrt, rsqrt, and divide.

The library_example1 includes a library, a kernel, and a host system. The example1.cl kernel source file includes two kernels. The kernel test_lib uses library functions; the kernel test_builtin uses built-in functions. The host runs both kernels and then compares their outputs and runtimes. Intel® recommends that you use the same strategy to verify your own library functions.

To compile this design example, perform the following tasks:

  1. Obtain the library_example1 from the OpenCL design examples in the $INTELFPGAOCLSDKROOT/examples_aoc directory.
  2. Copy it to a local directory.
  3. Follow the instructions in the README.html file, which is located in the top-level of the example directory.
    When you run the compiled host program, it should produce the following output:
    Loading example1.aocx ...
    Create buffers
    Generate random data for conversion...
    Enqueuing both library and builtin in kernels 4 times with global size 65536
    Kernel computation using library function took 5.35333 seconds
    Kernel computation using built-in function took 5.39949 seconds
    Reading results to buffers...
    Checking results...
    Library function throughput is within 5% of builtin throughput.
    PASSED