This example design runs two instances of a class in two separate threads. Each instance uses a different kernel: First instance executes a vector addition kernel to perform: C = A + B where A, B, and C are N-element vectors. Second instance executes a memberwise vector multiplication kernel to perform: C = A * B (memberwise). The kernels are intentionally kept simple and not optimized.
Since the device cannot be programmed to use two separate programs simultaneously, both of the problem instances share the same OpenCL™ program (hence running in the same context). However, as is the case in this example, the two threads can have separate command queues. For simplicity, the two threads run on two instances of the same code, with different arguments, but they can generally run two separate classses.
In addition to demonstrating the basic OpenCL application programming interface (API), this example supports partitioning the problem across multiple OpenCL devices, if available. If there are M available devices, the problem is divided so that each device operates on N/M points. The host program assumes that all devices are of the same type (that is, the same binary can be used, but the code can be generalized to support different device types easily).
The design example provides source code for the OpenCL device (.cl) as well as the host application. For compiling the host application, the Linux package includes a Makefile and the Windows package includes a Microsoft Visual Studio 2010 project.
The following downloads are provided for this example:
The use of this design is governed by, and subject to, the terms and conditions of the hardware reference design license agreement.
Software and Hardware Requirements
This design example requires the following tools:
- Intel® FPGA Software v17.1 or later
- Intel® FPGA SDK for OpenCL™ v17.1 or later
- On Linux: GNU Make and gcc
- On Windows: Microsoft Visual Studio 2010
To download the Intel design tools, visit the OpenCL download page. The requirements for the underlying operating system are the same as those of the Intel FPGA SDK for OpenCL.
OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos.
* Product is based on a published Khronos Specification, and has passed the Khronos Conformance Testing Process. Current conformance status can be found at www.khronos.org/conformance.
Design Examples Disclaimer
These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.