Jump to content

Automatic vectorization

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 159.153.138.54 (talk) at 20:58, 5 October 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Automatic vectorization, in the context of a computer program, refers to the transformation of a series of operations performed linearly, one step at a time, to operations performed in parallel, several at once, in a manner suitable for processing by a vector processor.

An example would be a program to sum the columns of a large table of numeric data. A linear approach would be something like:

for i = 1 to the number of columns in table T
{

V[i] = 0.0;
for j = 1 to the number of rows in table T
{
V[i] = V[i] + T[i, j];
}

}

This could be transformed to vectorized code something like:

for i = 1 to the number of columns in table T
{

Send column i of table T to an available vector processor to be summed
placing the result in V[i]; continue without waiting for the result;

}
Wait for the completion of all the above vector operations;

The vectorized approach permits the sums of several columns to be computed at the same time, which will be faster than the linear approach if the time required to communicate with the vector processors is small compared to the time to compute the sums in the linear approach.