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

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

A.2.2. OpenCL 1.2 C Programming Language Implementation

The Intel® FPGA SDK for OpenCL™ supports a number of OpenCL C programming language features that are specified section 6 of the OpenCL Specification version 1.2 . The SDK conforms with the OpenCL C programming language with clarifications and exceptions.
Attention: The support status "●" means that the feature is supported, and there might be a clarification for the supported feature in the Notes column. The support status "○" means that the feature is supported with exceptions identified in the Notes column.
Table 16.  Support Statuses of OpenCL 1.2 C Programming Language Features
Section Feature Support Status Notes
6.1.3 Other Built-in Data Types Preliminary support. This feature might not conform with the OpenCL Specification version 1.0.
6.12.12 Miscellaneous Vector Functions The SDK supports implementations of the following additional built-in vector functions:
  • vec_step
  • shuffle
  • shuffle2
6.12.13 printf Preliminary support. This feature might not conform with the OpenCL Specification version 1.0. See below for details.

The printf function in OpenCL has syntax and features similar to the printf function in C99, with a few exceptions. For details, refer to the OpenCL Specification version 1.2.

To use a printf function, there are no requirements for special compilation steps, buffers, or flags. You can compile kernels that include printf instructions with the usual aoc command.

During kernel execution, printf data is stored in a global printf buffer that the Intel® FPGA SDK for OpenCL™ Offline Compiler allocates automatically. The size of this buffer is 64 kB; the total size of data arguments to a printf call should not exceed this size. When kernel execution completes, the contents of the printf buffer are printed to standard output.

Buffer overflows are handled seamlessly; printf instructions can be executed an unlimited number of times. However, if the printf buffer overflows, kernel pipeline execution stalls until the host reads the buffer and prints the buffer contents.

Because printf functions store their data into a global memory buffer, the performance of your kernel will drop if it includes such functions.

There are no usage limitations on printf functions. You can use printf instructions inside if-then-else statements, loops, etc. A kernel can contain multiple printf instructions executed by multiple work-items.

Format string arguments and literal string arguments of printf calls are transferred to the host system from the FPGA using a special memory region. This memory region can overflow if the total size of the printf string arguments is large (3000 characters or less is usually safe in a typical OpenCL application). If there is an overflow, the error message cannot parse auto-discovery string at byte offset 4096 is printed during host program execution.

Output from printf is never intermixed, even though work-items may execute printf functions concurrently. However, the order of concurrent printf execution is not guaranteed. In other words, printf outputs might not appear in program order if the printf instructions are in concurrent datapaths.