restrict(amp) restrictions part 1 of N – fundamental types

This post assumes and requires that you have read the introductory post to this series which also includes a table of content. With that out of the way let’s look at restrictions around fundamental types.

The DirectX 11 programming model supports a smaller set of basic data types comparing to C++ fundamental types. For example, short types like char, short, etc., and longer types like long long are not supported. Since currently C++ AMP is built on top of the Direct3D platform, in order to support the full set of C++ fundamental types, we would have had to emulate those types unsupported by DirectX 11. The emulation introduces performance overhead, and has caveats for overflow semantics. To prevent programmers from unconsciously falling into such anti-performance patterns, we limit the supported fundamental types within an amp- restricted function to the following list:

  • bool
  • int, unsigned int (__int32, unsigned __int32)
  • long, unsigned long
  • float, double
  • void
  • std::nullptr_t

Note that bool and nullptr_t do not have full support as other fundamental types. For example, array of bool or array of nullptr_t is not supported. Next post of this series will explain restrictions that results in these special cases.