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

ID 683342
Date 4/22/2019
Public
Document Table of Contents

12.1.8. 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 example2.tgz tar ball 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 example2.cl 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) will take more time to execute than later invocations.

To compile this design example, perform the following tasks:

  1. Obtain the example2.tgz from the OpenCL Design Examples web page.
  2. Unpack it into a local directory.
  3. Follow the instructions in the README.html file, which is located in the top-level of the unpacked example.
    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
    PASSED