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

ID 683342
Date 4/22/2019
Public
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.