11.1.9. Using an OpenCL Library that Works with External Memory (Example 2)
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 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].
To compile this design example, perform the following tasks:
- Obtain the library_example2 from the OpenCL design examples in the $INTELFPGAOCLSDKROOT/examples_aoc directory.
- Copy it into a local directory.
- 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 PASSED