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

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

5.7. Using Predefined Preprocessor Macros in Conditional Compilation

You may take advantage of predefined preprocessor macros that allow you to conditionally compile portions of your kernel code.
  • To include device-specific (for example, FPGA_board_1) code in your kernel program, structure your kernel program in the following manner:
    #if defined(AOCL_BOARD_FPGA_board_1)
        //FPGA_board_1-specific statements
    #else
        //FPGA_board_2-specific statements
    #endif
    When you target your kernel compilation to a specific board, it sets the predefined preprocessor macro AOCL_BOARD_<board_name> to 1. If <board_name> is FPGA_board_1, the Intel® FPGA SDK for OpenCL™ Offline Compiler will compile the FPGA_board_1-specific parameters and features.
  • To introduce Intel® FPGA SDK for OpenCL™ Offline Compiler-specific compiler features and optimizations, structure your kernel program in the following manner:
    #if defined(INTELFPGA_CL)
        //statements
    #else
        //statements
    #endif
    Where INTELFPGA_CL is the Intel® predefined preprocessor macro for the offline compiler.