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

ID 683846
Date 9/26/2022

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

5.9.2. Disabling Insertion of Data Structure Padding

You may instruct the Intel® FPGA SDK for OpenCL™ Offline Compiler to disable automatic padding insertion between members of a struct data structure.
To disable automatic padding insertion, insert the packed attribute prior to the kernel source code for a struct data structure.
For example:

struct __attribute__((packed)) Context
   float param1;
   float param2;
   int param3;
   uint param4;
__kernel void algorithm(__global float * restrict A, 
                        __global struct Context * restrict c)
   if ( c->param3 )
      // Dereference through a pointer and so on
For more information, refer to the Align a Struct with or without Padding section of the Intel® FPGA SDK for OpenCL™ Best Practices Guide.