Freigeben über


restrict(amp) restrictions part 4 of N – literals

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 literals.

In an amp-restricted function, an integer constant or floating point constant must be within the maximum allowable ranges of supported fundamental types. Note that as long as the value of the literal can be expressed by some supported type, the literal is considered legal even the type specified by its suffix is not supported for amp. For example,

    int i = 0x1234LL; // legal since 0x1234 is within the data range of int

int j = 'c'; // legal since the ASCII code for 'c' (99) is within

                     // the data range of int

int k = 0x100000000; // illegal since it exceeds the data range of any integral

    // types supported for amp

String literals are not allowed unless they are directly passed to the following two special direct3d debugging intrinsics:

    void direct3d_errorf(const char *, ...) restrict(amp);

    void direct3d_printf(const char *, ...) restrict(amp);

You may notice that the parameter types of these two functions (const char * and ‘…’) are not allowed for amp-restricted functions based on restrictions on compound types and function declarators we discussed in the previous posts. We made exceptions for these two functions because they are handled as intrinsics and are mapped directly to DirectX 11 intrinsics. We will have a separate blog post to show how to take advantage of these debugging intrinsics while developing a C++ AMP application.