Intel® Fortran Compiler XE 13.1 User and Reference Guides
This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).
Offloaded code has the following restrictions:
Exception handling may be done as usual within code running on the CPU and within code running on the coprocessor. So exceptions can be raised, caught and handled on the CPU, or raised, caught and handled on the coprocessor. However it is not possible to propagate an exception from the coprocessor to the CPU.
Do not use the __MIC__ macro inside the statement following a !DIR$ OMP OFFLOAD statement. You can, however, use this macro in a subprogram called from the directive.
Multiple host CPU threads can execute concurrently while one host CPU thread offloads a section of code. In this case synchronization mechanisms such as locks, atomics, mutexes, OpenMP atomic operations, OpenMP critical, OpenMP taskwait, OpenMP barriers, etc. do not work between host CPU code and code offloaded to the target. However, if parallelism on the host CPU is enabled using OpenMP, then OpenMP synchronization at the end of a parallel region is guaranteed to work even if some part of the OpenMP parallel region has been offloaded to the target.
Global variables referenced by functions called from within offloaded code must be declared with matching target attributes to ensure that the variable is available on the target. The offloaded code cannot access the host CPU global variables. This is enforced by the compiler.
By default, pointer variables are assumed to point to a single element of the corresponding type. The offloaded code may dereference the pointer and access a single element. The data element pointed to is automatically copied into target memory and the pointer value adjusted accordingly. The element-count-expr expression available with in / out / inout parameters enable variable-length data to be copied back and forth.
Only pointers to non-pointer types are supported. These non-pointer types must have the TARGET attribute. Pointers to pointer variables are not supported. The compiler enforces this restriction.
Arrays are supported provided the array element type is a scalar or bitwise copyable derived type. Pointer arrays are supported provided the target is contiguous.
Because pointers are not copied across the host-target interface, but instead the data they point to is copied, do not assume that the relative distance between pointers that point to distinct variables remains the same between the host and target. Pointers within the same data structure still have the same distance between them after offload. Thus, some pointer comparisons and arithmetic that were meaningful on the host CPU can no longer be used reliably on the target.
Unions containing a combination of pointer and non-pointer members are treated as holding the non-pointer value type. Thus, no special treatment is given to the pointer, and the data pointed to is not copied to the target.
Unions consisting entirely of pointer members are not allowed to be copied between the host and the target.
If an offloaded statement calls a function defined in a separate file and that function references global variables, then those global variables cannot be copied in or out because the references are not visible to the compiler. Those variables are copied in or out if they are also referenced in the offloaded statement.
Global variables such as these must be explicitly named in in and out clauses in the offload specification. When these global variables are file-scope static variables, then they cannot be named in the in or out clauses. You need to access their values using one of the following methods:
Make them external and add them to the in or out clauses in the offload specification.
Fetch the variable values into local variables using functions designed specifically for that purpose, and then add the local variables to the in or out clauses.
You cannot use objects that are not bitwise copyable, inside a !DIR$ OFFLOAD region. The compiler enforces this restriction and issues an error.