Array Operations are Rewarded
PV-WAVE programs are compiled into a low-level abstract machine code, which is interpretively executed. The dynamic nature of variables in PV-WAVE and the relative complexity of the operators precludes the use of directly executable code. Statements are only compiled once, regardless of the frequency of their execution.
The PV-WAVE interpreter emulates a simple stack machine with approximately 50 operation codes. When performing an operation, the interpreter must determine the type and structure of each operand, and branch to the appropriate routine. The time required to properly dispatch each operation may be longer than the time required for the operation itself.
Array-array and array-scalar operations are implemented by generating and executing optimized machine code in a temporary buffer. The characteristics of the time required for array operations is similar to that of vector computers and array processors. There is an initial set-up time, followed by rapid evaluation of the operation for each element. The time required per element is shorter in longer arrays because the cost of this initial set-up period is spread over more elements.
The speed of PV-WAVE is comparable to that of optimized FORTRAN insofar as array operations are considered. When data are treated as scalars, efficiency degrades by a factor of 30 or more.
For example, evaluating the square-root of a 10,000-element floating-point vector and adding 2 to each element of a 512-by-512 byte image was timed using scalar operations, array operations, and FORTRAN. The times for these operations are shown in
Processing Times:
As can be seen above, there is a large penalty for using scalar operations when array operations are appropriate. There is little difference in the times required by PV-WAVE array operations and FORTRAN.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.