Skip to content
Branch: master
Find file History
martingkelly and jrprice drop __attribute__((aligned(X))) from cl_X defs
Currently, we add __attribute__((aligned(X))) for definitions like
cl_int, cl_short etc. This guarantees that the variable will be aligned
*at least* at an X byte boundary. We don't need to do this, for a few
reasons:

- Most of these types are fixed width (int32_t, int16_t, etc.). This
  means __attribute((aligned(X))) isn't doing anything, as the types are
  exactly the right size, so they will already be aligned to at least
  their size. float and double are not guaranteed to be any given width,
  though in practice they are almost always IEEE 754 floats and
  therefore 4 and 8 bytes respectively. If they were not 4/8 bytes, it's
  unclear that forcing 4/8 byte alignment would be good for either space
  or performance efficiency.

- Attributes don't carry over to templates, which ends up causing a
  GCC -Wignored-attributes warning in cl.hpp when we declare an
  std::vector<cl_int>. This warning is indicating that the attributes
  get dropped when put inside a template. Nothing seems to break when
  this happens, further suggesting that the attributes aren't really
  needed.

- The attributes aren't present on Windows, so if they were really
  needed, then Windows is currently broken. Again, it doesn't seem like
  anything is broken, so this is further evidence that we don't need to
  add these attributes.

See here for further reference on __attribute((aligned(X))):
https://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Type-Attributes.html
Latest commit c60b351 Jan 10, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
cl.h removing comments around arguments: Jan 17, 2019
cl_d3d10.h Unified Headers May 14, 2018
cl_d3d11.h Unified Headers May 14, 2018
cl_dx9_media_sharing.h
cl_dx9_media_sharing_intel.h removing comments around arguments: Jan 17, 2019
cl_egl.h removing comments around arguments: Jan 17, 2019
cl_ext.h
cl_ext_intel.h
cl_gl.h removing comments around arguments: Jan 17, 2019
cl_gl_ext.h removing comments around arguments: Jan 17, 2019
cl_platform.h
cl_va_api_media_sharing_intel.h
cl_version.h
opencl.h
You can’t perform that action at this time.