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

ID 683846
Date 10/04/2021

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

Document Table of Contents

5.9.3. Specifying the Alignment of a Struct

You may instruct the Intel® FPGA SDK for OpenCL™ Offline Compiler to set a specific alignment of a struct data structure.
To specify the struct alignment, insert the aligned(N) attribute prior to the kernel source code for a struct data structure.
For example:

struct __attribute__((aligned(2))) Context
   float param1;
   float param2;
   int param3;
   uint param4;
__kernel void algorithm(__global float * 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.