forked from OpenMP/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamples_array_shaping.tex
More file actions
27 lines (24 loc) · 1.19 KB
/
Examples_array_shaping.tex
File metadata and controls
27 lines (24 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
\section{Array Shaping}
\label{sec:array-shaping}
\ccppspecificstart
A pointer variable can be shaped to a multi-dimensional array to facilitate
data access. This is achieved by a \plc{shape-operator} casted in front of
a pointer (lvalue expression):
\begin{description}
\item[]\hspace*{5mm}\code{([$s_1$][$s_2$]...[$s_n$])}\plc{pointer}
\end{description}
where each $s_i$ is an integral-type expression of positive value.
The shape-operator can appear in either the \plc{motion-clause}
of the \code{target}~\code{update} directive or the \code{depend} clause.
The following example shows the use of the shape-operator in the
\code{target}~\code{update} directive. The shape-operator \code{([nx][ny+2])}
casts pointer variable $a$ to a 2-dimentional array of size
\plc{nx}$\times$\plc{(ny+2)}. The resulting array is then accessed as
array sections (such as \code{[0:nx][1]} and \code{[0:nx][ny]})
in the \code{from} or \code{to} clause for transferring two columns of
noncontiguous boundary data from or to the device.
Note the use of additional parentheses
around the shape-operator and $a$ to ensure the correct precedence
over array-section operations.
\cnexample{array_shaping}{1}
\ccppspecificend