Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How are scalars dealt with in vectorization?

dealt scalars vectorization
0
10 Posted

How are scalars dealt with in vectorization?

0
10

If a scalar variable is only used (not set) in a loop, then for AltiVec the scalar will be “splatted” into a vector register (replicated in each postion in the vector register) and the result used in the vector calculation. Scalars that are set and then used in a loop are “promoted” to vectors. These scalars are generally holding temporary values in a loop that we now need to temporary vector values. In the example, below, x is a “used” scalar and y is a “promoted” scalar: C Fortran float a[99], b[99], x, y; int i, n; for ( i=0; i < n; i++ ) { y = x + b[i]; a[i] = y + 1/y; } real a(99), b(99), x, y int i, n do i= 1, n y = x + b(i) a[i] = y + 1/y enddo Scalar that are used before they are set in a loop are called "carry-around" scalars. They are a problem for vectorization since the value computed in one pass of the loop is used in the next pass of the loop (the value is "carried" from one pass to the next).

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123