What does #pragma intrinsic mean?

Just want to know what #pragma intrinsic (_m_prefetchw) means?

+6
source share
4 answers

As far as I know, it looks like someone intended to change some MSVC ++ settings. However, this parameter is not valid for internal pragma . _ m_prefetchw , on the other hand, is 3D Now! internal function.

Like all compiler built-in functions, it provides (possibly) faster build instructions supported by the underlying hardware, your C or C ++ application in a way

a. more consistent with optimizers and
B. more consistent with the language compared to using the built-in assembly.

In MSVC on x86_64 / x64 / amd64 systems, the built-in assembly is not supported, therefore, to access the whizzbang functions of the underlying equipment, you must use such built-in functions.

Finally, it should be noted that _ m_prefetchw is 3D now! Built-in and 3D now! only supported on AMD hardware. This is probably not what you want to use for the new code (i.e., instead, you should use the SSE, which works on both Intel and AMD hardware, and has more download options).

+4
source

The meaning of "#pragma intrinsic" (spelling note), like all "#pragma" directives, varies from one compiler to another. Typically, this indicates that a particular thing that looks syntactically similar to an external function call should be replaced with some inline code. In some cases, this can significantly improve performance, especially if the compiler can determine constant values ​​for some or all of the arguments (in the latter situation, the compiler can calculate the value of the function and replace it with a constant).

Typically, having functions handled internally will not present any particular problem. The biggest danger is that if the user defines a function in one module with the same name as one of the built-in functions of the compiler and tries to call this function from another module, the compiler will instead replace the function call with its expected sequence of commands. To prevent this, some compilers do not allow built-in functions by default (as this will result in the above incompatibility with some standard-compatible programs), but provide #pragma directives to enable them. Compilers can also use the command line parameter to enable built-in functions (since the standard allows something there) or can define some functions, such as __memcpy () as internal, and inside string.h use the #define directive to convert memcpy to __memcpy (since programs that #include string.h cannot use memcpy for any other purpose).

+1
source

In C it depends on whether the implementation recognizes (and defines) it.

If the implementation does not recognize the "built-in" preprocessing token, the pragma is ignored.
If an implementation recognizes it, then what is defined will be determined (and if another implementation defines it differently, another implementation will occur in another implementation).

So, check the documentation for the implementation you are talking about (edit: and do not use it if you plan to compile the source in different implementations).

I could not find a link to "#pragma intrinsic" in man gcc on my system.

0
source

An internal pragma tells the compiler that the function knows the behavior. The compiler may call the function and not replace the function call with built-in instructions if this leads to increased performance.

Source: http://msdn.microsoft.com/en-us/library/tzkfha43(VS.80).aspx

-1
source

Source: https://habr.com/ru/post/886274/


All Articles