Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 327

Data transfer of an “array of pointers” using the Intel® Language Extensions for Offload (LEO) for the Intel® Xeon Phi™ coprocessor

$
0
0

The Intel® Parallel Studio XE 2015 Composer Editions for C++ Windows* and Linux* have a feature enhancement supporting data transfer of an “array of pointers” with the Intel® Language Extensions for Offload (LEO) for the Intel® Xeon Phi™ coprocessor.

The feature adds support under the LEO offload data marshalling model for transferring a pointer type that is an “array of pointers”, where the element-type of the variable reference (variable-ref) used in the data transfer clauses (i.e in, out, inout, nocopy) of the #pragma offload/offload_transfer is a pointer to a standard data type (i.e. signed char, unsigned char, signed int, unsigned int, float, double) or bit-wise copyable type.

Under the offload data marshalling model, each data movement clause (in, out, inout, nocopy) shares a common basic syntax shown in the details below. The feature enhancement includes new modifiers for specifying details related to the array of pointers as discussed below.

Syntax:   
                #pragma offloadclause [ clause …]
                #pragma offload_transferclause [ clause …]

                Where clause may include the data transfer clauses of:

                              in ( variable-ref [, variable-ref …] [ modifier [ modifier … ] ])
                              out ( variable-ref [, variable-ref …] [ modifier [ modifier … ] ])
                              inout (variable-ref [, variable-ref …] [ modifier [ modifier … ] ])
                              nocopy (variable-ref [, variable-ref …] [ modifier [ modifier … ] ])

                And, specific to using with an array of pointers, the modifier may be:

                              length ( element-count-expr)
                              extent (start :length )
                              alloc_if (condition )
                              free_if (condition )
                              align (align-expr)
                              alloc (identifier [ c-shape])
                              alloc ([c-shape])
                              alloc_extent (start :length )
                              into (variable-ref)
                              into_extent (start :length )

For the array of pointers, the variable-ref specifies the pointers in the pointer array whose pointed-to data is to be transferred. The elements of each pointer that are to be transferred may be specified with either a length modifier or an extent modifier. When a length modifier that is a scalar integral expression is used, then that many elements pointed to by each pointer in the array are transferred, beginning with the 0th element. A length modifier that is an array expression specifies a set of length values that apply one-to-one with the pointers in the variable-ref. The first length value applies to the first pointer, the second length to the second pointer and so on. The starting element to transfer is 0 in each case.

Example:

          //  Transfer the dark-green elements in the pointer arrays
          //  See figure 1 below

          int *p[4];          // assume pointers are assigned values
          ...
          #pragma offload …in( p[0:4] : length(2) )
          ...

The alternative to using the length modifier is to use the extent modifier. This modifier allows two array expressions to be written. The first is an array of starting element values. The second is an array of length values. The one-to-one correspondence between pointer elements and start and length values is the same as that of the length modifier.

Example:

          //   Transfer the dark-green elements in the pointer arrays
          //   See figure 2 below

          int start[4] = {0,1,0,2};
          int len[4] =   {1,1,3,3};
          int *p[4];    // assume pointers are assigned values
          …
          #pragma offload …in( p[0:4] : extent( start[0:4] : len[0:4] ) )
          …

The alloc_if, free_if, and align modifiers when used with a single pointer are scalar expressions. When used with an array of pointers these modifiers may take an array expression and follow the same rule of one-to-one correspondence as the length and extent modifiers discussed earlier.

The alloc and into modifiers when used with a single pointer are scalar expressions.  When used with an array of pointers these modifiers may take an array expression and follows the same rule of one-to-one correspondence as the length and extent modifiers discussed earlier. The alternative is to use alloc_extent and into_extent. Similar to the extent modifier, when used with an array of pointers they take two array expressions separated by a colon. The first array expression is a set of start values. The second array expression specifies a set of element counts.

NOTE: For each of the modifiers discussed above, when an array expression is allowed, a scalar expression may be specified. Then, that expression value is expanded to the size of the pointer array.

When a variable-list is used in an in/out/inout/nocopy clause and the list contains variables of pointer types, all pointer variables must be either plain pointers or arrays of pointers. Then, the modifiers used, such as length or extent can be consistent with all the pointer variables in the list.

Refer to the Intel® Parallel Studio XE 2015 Composer Edition for C++ product documentation for additional details.


Viewing all articles
Browse latest Browse all 327

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>