next up previous contents
Next: Example: Parallelizing ``axpy'' for Up: Vector-Vector Operations Previous: PLAPACK calls

Example: Parallelizing Inner Product

 

Given two global vectors x and y in objects x and y, we wish to compute their inner product

displaymath13996

Notice that if both x and y are of object type vector and they are aligned identically to the template, then the result equals

displaymath13997

Thus, in this situation it suffices to call the local inner product routine on the local data, and reduce the results into the global result tex2html_wrap_inline14004 , stored in alpha.

If x and y are not distributed as vectors, one approach is to create two temporary vectors that are aligned, copy x and y into the temporary vectors, execute the above described procedure for aligned vectors, and compute the result. We illustrate code for this solution in Figure gif. In the implementation of the routine pdot, we are given objects x, y and alpha as parameters to the subroutine. The first two we assume are of object type vector, possibly projected and/or duplicated. The last is a tex2html_wrap_inline14014 multiscalar, possibly duplicated in rows and/or columns. We start by creating temporary objects, temp_x and temp_y, of object type vector, identically aligned to the template. We also create temp_alpha, a tex2html_wrap_inline14016 multiscalar duplicated on all nodes, so that all nodes have a place to put local results. The contents of x and y are copied to the temporary vectors using PLA_Copy. Local results are computed by calling PLA_Local_dot, leaving the result in the local buffer of temp_alpha. Finally, the local contributions are reduced into the output multiscalar alpha.

PLACE BEGIN HR HERE

figure6631

PLACE END HR HERE


next up previous contents
Next: Example: Parallelizing ``axpy'' for Up: Vector-Vector Operations Previous: PLAPACK calls

rvdg@cs.utexas.edu