This page contains examples for users who are new to Xilinx SDx OpenCL Flows. The focus of the examples is towards code optimization for Xilinx devices.The table lists various categories of examples in suggested order which users can follow.
Prerequisites
- User is familiar with basics of OpenCL flow.
- User has gone through SDx tutorial and is familiar with basics of tool functionality and terminology.
| S.No. | Category | Description |
|---|---|---|
| 1 | hello_world | Hello World examples for new users |
| 2 | cpu_to_fpga | Labs to showcase the cpu to fpga conversion with kernel optimizations. |
| 3 | host | OpenCL host code for optimized interfacing with Xilinx Devices |
| 4 | kernel_to_gmem | Kernel to Global Memory Access Optimization. |
| 5 | kernel_opt | Kernel Optimization for performance |
| 6 | dataflow | Kernel Optimization through Macro Level Pipelining |
| 7 | clk_freq | Improving Kernel Clock Frequency through Optimized code. |
| 8 | debug | Debugging and Profiling of Kernel. |
| 9 | rtl_kernel | RTL Kernel Based Examples |
Examples Table
| Example | Description | Key Concepts / Keywords |
|---|---|---|
| hello_world/helloworld_c/ | This is simple example of vector addition to describe how to use HLS kernels in Sdx Environment. This example highlights the concepts like PIPELINE which increases the kernel performance | Key Concepts - HLS C Kernel - OpenCL Host APIs Keywords - gmem - bundle - #pragma HLS INTERFACE - m_axi - s_axi4lite |
| hello_world/helloworld_ocl/ | This example is a simple OpenCL application. It will highlight the basic flow of an OpenCL application. | Key Concepts - OpenCL API |
| cpu_to_fpga/00_cpu/ | This is a simple example of matrix multiplication (Row x Col). | |
| cpu_to_fpga/01_kernel_c/ | This is a simple example of HLS matrix multiplication (Row x Col). | Key Concepts - OpenCL APIs |
| cpu_to_fpga/02_local_mem_c/ | This is a simple example of matrix multiplication (Row x Col) to demonstrate how to reduce number of memory accesses using local memory. | Key Concepts - Kernel Optimization - Local Memory |
| cpu_to_fpga/03_burst_rw_c/ | This is a simple example of matrix multiplication (Row x Col) to demonstrate how to achieve better pipeline with burst read and write to/from local memory from/to DDR. | Key Concepts - Kernel Optimization - Burst Read/Write |
| cpu_to_fpga/04_partition_c/ | This is a simple example of matrix multiplication (Row x Col) to demonstrate how to achieve better performance by array partitioning and loop unrolling. | Key Concepts - Array Partition - Loop Unroll Keywords - pragma HLS PIPELINE - pragma HLS ARRAY_PARTITION complete - pragma HLS UNROLL |
| host/concurrent_kernel_execution_c/ | This example will demonstrate how to use multiple and out of order command queues to simultaneously execute multiple kernels on an FPGA. | Key Concepts - Concurrent execution - Out of Order Command Queues - Multiple Command Queues Keywords - CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE - clSetEventCallback() |
| host/copy_buffer_c/ | This Copy Buffer example demonstrate how one buffer can be copied from another buffer. | Key Concepts - Copy Buffer Keywords - cl::CommandQueue::enqueueCopyBuffer() |
| host/data_transfer_c/ | This example illustrates several ways to use the OpenCL API to transfer data to and from the FPGA | Key Concepts - OpenCL API - Data Transfer - Write Buffers - Read Buffers - Map Buffers - Async Memcpy Keywords - enqueueWriteBuffer() - enqueueReadBuffer() - enqueueMapBuffer() - enqueueUnmapMemObject() - enqueueMigrateMemObjects() |
| host/device_query_c/ | This example prints the OpenCL properties of the platform and its devices. It also displays the limits and capabilities of the hardware. | Key Concepts - OpenCL API - Querying device properties Keywords - clGetPlatformIDs() - clGetPlatformInfo() - clGetDeviceIDs() - clGetDeviceInfo() |
| host/device_query_cpp/ | This Example prints the OpenCL properties of the platform and its devices using OpenCL CPP APIs. It also displays the limits and capabilities of the hardware. | Key Concepts - OpenCL API - Querying device properties |
| host/errors_c/ | This example discuss the different reasons for errors in OpenCL and how to handle them at runtime. | Key Concepts - OpenCL API - Error handling Keywords - CL_SUCCESS - CL_DEVICE_NOT_FOUND - CL_DEVICE_NOT_AVAILABLE |
| host/errors_cpp/ | This example discuss the different reasons for errors in OpenCL C++ and how to handle them at runtime. | Key Concepts - OpenCL C++ API - Error handling Keywords - CL_SUCCESS - CL_DEVICE_NOT_FOUND - CL_DEVICE_NOT_AVAILABLE - CL_INVALID_VALUE - CL_INVALID_KERNEL_NAME - CL_INVALID_BUFFER_SIZE |
| host/hbm_bandwidth/ | This is a HBM bandwidth check design. Design contains 8 compute units of a kernel which has access to all HBM banks (0:31). Host application allocate buffer into all HBM banks and run these 8 compute units concurrently and measure the overall bandwidth between Kernel and HBM Memory. | |
| host/hbm_simple/ | This is a simple example of vector addition to describe how to use HLS kernels with HBM (High Bandwidth Memory) for achieving high throughput. | Key Concepts - High Bandwidth Memory - Multiple HBM Banks Keywords - HBM - XCL_MEM_TOPOLOGY - cl_mem_ext_ptr_t |
| host/host_global_bandwidth/ | Host to global memory bandwidth test | |
| host/host_global_bandwidth_5.0_shell/ | Host to global memory bandwidth test for 5.0 shell | |
| host/kernel_swap_c/ | This example shows how host can swap the kernels and share same buffer between two kernels which are exist in separate binary containers. Dynamic platforms does not persist the buffer data so host has to migrate data from device to host memory before swapping the next kernel. After kernel swap, host has to migrate the buffer back to device. | Key Concepts - Handling Buffer sharing across multiple binaries - Multiple Kernel Binaries Keywords - clEnqueueMigrateMemObjects() - CL_MIGRATE_MEM_OBJECT_HOST |
| host/mult_compute_units/ | This is simple Example of Multiple Compute units to showcase how a single kernel can be instantiated into Multiple compute units. Host code will show how to use multiple compute units and run them concurrently. | Key Concepts - Multiple Compute Units Keywords - -nk |
| host/multiple_cus_asymmetrical/ | This is simple example of vector addition to demonstrate how to connect each compute unit to different banks and how to use these compute units in host applications | Key Concepts - Multiple Compute Units Keywords - #pragma HLS PIPELINE |
| host/multiple_devices_c/ | This example show how to take advantage of multiple FPGAs on a system. It will show how to initialized an OpenCL context, allocate memory on the two devices and execute a kernel on each FPGA. | Key Concepts - OpenCL API - Multi-FPGA Execution - Event Handling Keywords - cl_device_id - clGetDeviceIDs() |
| host/multiple_process_c/ | This example will demonstrate how to run multiple processes to utilize multiple kernels simultaneously on an FPGA device. Multiple processes can share access to the same device provided each process uses the same xclbin. Processes share access to all device resources but there is no support for exclusive access to resources by any process. | Key Concepts - Concurrent execution - Multiple HLS kernels - Multiple Process Support Keywords - PID - fork - XCL_MULTIPROCESS_MODE - multiprocess |
| host/overlap_c/ | This examples demonstrates techniques that allow user to overlap Host(CPU) and FPGA computation in an application. It will cover asynchronous operations and event object. | Key Concepts - OpenCL API - Synchronize Host and FPGA - Asynchronous Processing - Events - Asynchronous memcpy Keywords - cl_event - clCreateCommandQueue - CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE - clEnqueueMigrateMemObjects |
| host/streaming_chain/ | This is a kernel containing the cascaded Matrix Multiplication using dataflow. ap_ctrl_chain is enabled for this kernel to showcase how multiple enqueue of Kernel calls can be overlapped to give higher performance. ap_ctrl_chain allow kernel to start processing of next kernel operation before completing the current kernel operation. | Key Concepts - ap_ctrl_chain - PLRAM |
| host/streaming_host_bandwidth/ | This is a simple Vector Increment C Kernel design with 1 |