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

ID 683846
Date 6/21/2022

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

Document Table of Contents

11.1.9. Using an OpenCL Library that Works with External Memory (Example 2)

Intel® provides an OpenCL™ library design example of a simple kernel that uses a library containing two RTL modules that communicate with global memory.

The library_example2 includes a library, a kernel, and a host system. In this example, the RTL code that communicates with global memory is Custom Platform- or Reference Platform-dependent. Ensure that the compilation targets the board that corresponds to the Stratix® V Network Reference Platform.

Intel® generated the RTL modules copyElement() and sumOfElements() using the Intel® FPGA SDK for OpenCL™ Offline Compiler, which explains the extra inputs in the code.

The kernel source file includes two kernels. The kernel test6 is an NDRange kernel that calls the copyElement() RTL function, which copies data from B[] to A[] and then stores global_id+100 in C[]. The kernel test11 is a single work-item kernel that uses an RTL function. The sumOfElements() RTL function determines the sum of the elements of A[] in range [i, N] and then adds the rest to C[i].

Note: First invocations of sumOfElements(i=0) takes more time to execute than later invocations.

To compile this design example, perform the following tasks:

  1. Obtain the library_example2 from the OpenCL design examples in the $INTELFPGAOCLSDKROOT/examples_aoc directory.
  2. Copy it into 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 example2.aocx ...
    Running test6
    Launching the kernel test6 with globalsize=128 localSize=16
    Loading example2.aocx ...
    Running test11
    Launching the kernel test11 with globalsize=1 localSize=1