Visible to Intel only — GUID: GUID-5C5B651F-F94D-4070-BB55-6087CFC5902E
Visible to Intel only — GUID: GUID-5C5B651F-F94D-4070-BB55-6087CFC5902E
Language Support for Auto-parallelization
This topic addresses specific C++ language features that better help to parallelize code.
Annotating Functions with Declarations
Annotating functions with the declaration:
// (Windows* OS)
__declspec(concurrency_safe(cost(cycles) | profitable))
-OR-
// (Linux* OS)
__attribute__(concurrency_safe(cost(cycles) | profitable))
guides the compiler to parallelize more loops and straight-line code.
Using the concurrency_safe attribute indicates to the compiler that there are no unaffected side-effects and no illegal (or improperly synchronized) memory access interfences among multiple invocations of the annotated function or between an invocation of this annotated function and other statements in the program, if they are executed concurrently.
For every function that is annotated with the concurrency_safe attribute, it is your responsibility to ensure that its side effects (if any) are acceptable (or expected), and the memory access interferences are properly synchronized.
The cost clause specifies the execution cycles of the annotated function for the compiler to perform parallelization profitability analysis while compiling its enclosing loops or blocks. The profitable clause indicates that the loops or blocks that contain calls to the annotated function are profitable to parallelize.
The value of cycles is a 2-byte unsigned integer (unsigned short), its maximal value is 2^16-1. If the cycle count is greater than 2^16-1, the user should use profitable clause.
The following example illustrates the use of this declaration.
Example using __declspec(concurrency_safe(cost(cycles) | profitable)) |
---|
|