Vector operations are supported natively only on 64-bit processors and offer a performance advantage only on these processors. The data sheet of the controller provides information about the processor used on the controller.
Currently, vector operations on the x86/64-bit platforms with SSE2 and ARM64 with NEON are supported natively. On all other platforms, vector operations are translated into individual statements. For example, vector addition is then executed with multiple single addition operations.
The command set extensions of the processors are SIMD extensions. SIMD (Single Instruction, Multiple Data) describes a computer architecture in which multiple data sets of the same type are processed simultaneously in parallel and therefore faster with one command call. In vector operations, for example, 4 pairs of numbers can then be added at the same time.
Syntax
<variable name> : __VECTOR[ <vector size> ] OF <element type> := <initialization> ; <vector size> : 1 |2 | 3 | 4 | 5| 6 | 7| 8 <element type> : REAL | LREAL
The initialization of variables is optional.
A vector data type is an array of floating-point numbers with a maximum of 8 elements.
The __vc<operator name>
operators are available for this data type. You can use these to implement vector
operations without additional function calls.
Syntax for index access
<variable name>[ <index> ] <index> : 0 | 1 | 2| 3 | 4 | 5| 6 | 7
When indexing a vector variable, you can access a single element of the vector. The index starts at 0 and goes until <vector size> - 1.
Example
PROGRAM PLC_PRG VAR vcA : __VECTOR[3] OF REAL; END_VAR vcA[0] := 1.1; vcA[1] := 2.2; vcA[2] := 3.3;
-
Determining the optimal vector size
-
Operator: __VCADD
-
Operator: __VCSUB
-
Operator: __VCMUL
-
Operator: __VCDIV
-
Operator: __VCDOT
-
Operator: __VCSQRT
-
Operator: __VCMAX
-
Operator: __VCMIN
-
Operator: __VCSET_REAL
-
Operator: __VCSET_LREAL
-
Operator: __VCLOAD_REAL
-
Operator: __VCLOAD_LREAL
-
Operator: __VCSTORE