Intel® Fortran Compiler 17.0 Developer Guide and Reference
This topic only applies when targeting Intel® Many Integrated Core Architecture (Intel® MIC Architecture).
This topic discusses using the ALLOC modifier with the OFFLOAD set of directives
The ALLOC modifier contains an array section reference. When you specify it, then the allocation on the coprocessor is limited to that shape of array. Only unit stride is allowed in the section. When a section has a rank greater than one, the second and subsequent index expressions must specify all elements at that dimension. The array section must be contiguous.
Data is transferred into that portion of the array specified by the IN or OUT expression. Thus memory allocation and the data transfer can use separate array slice references.
When the lower bound of the first dimension of a section used in the ALLOC modifier is non-zero, then the memory allocation begins with that element. The memory preceding the lower bound is unallocated and should not be referenced by your program. By not referencing it, you enable a smaller section of the array to be transferred to the coprocessor without requiring that the entire array be allocated.
The array A has 15 elements on the CPU, A(1:15).
The ALLOC modifier allocates 8 elements A(3:10), the blue and orange regions on the coprocessor.
On the coprocessor, the elements A(1:2), the gray region, are uninitialized.
The IN clause transfers elements A(4:8), the orange region, from the CPU to the coprocessor.
INTEGER :: A (15) ! 8 elements allocated ! 5 data elements transferred starting at element 4 !DIR$ OFFLOAD … IN ( A(4:8) : ALLOC ( (3:10) ) … …
INTEGER, ALLOCATABLE :: B (:,:) ALLOCATE (B (5,4)) ! On the coprocessor: 16 elements allocated (rows 2 through 5) ! Shape of array is 5x4, first row is unallocated ! Data is transferred into row 3 only !DIR$ OFFLOAD … IN ( B (3, :) : ALLOC ( 2:5, : ) … …
In the diagram below:
B is allowed 5 rows, 4 columns on the CPU.
On the coprocessor, the ALLOC modifier allocates rows 2 through 5, the blue and orange regions, all columns.
On the coprocessor, row 1, the gray region, is not allocated.
The IN clause transfers the third row (3: :), the orange region, to the coprocessor.