|
|
||||||||||||||||||||||||||
About VSIPL++
Manuals
Mailing Lists
|
Comparing Sourcery VISPL++ to MPISourcery VSIPL++ provides support for data-parallel programming using multiple processors. The Message Passing Interface (MPI) API is an alternative API that also supports data-parallel programming. Many signal-processing applications are presently built using low-level math libraries on individual CPUs, with MPI used to communicate data between processors. Sourcery VSIPL++ unifies mathematical operations with communication operations; you no longer need to explicitly manage communication. Sourcery VSIPL++ also provides a global view of arrays; in contrast, MPI forces you to treat what a single array as a collection of local data objects. The Sourcery VSIPL++ approach allows you to write much less code. And, Sourcery VSIPL++'s high-level view of data allows it to automatically perform optimizations that would require substantial additional effort when programming directly with MPI. This page shows how to implement a "corner-turn" using both Sourcery VSIPL++ and MPI. A corner-turn is useful in algorithms where some computations are performed along the rows of a matrix while others are performed along the columns. (For example, a row-wise FFT might be followed by a column-wise FFT.) When using multiple processors, it efficient to distribute the matrix by rows (so that each processor has one or more complete rows) when performing the row-wise operations. Then, the matrix is redistributed by columns before performing the column-wise operations. The redistribution operation is called a corner-turn.
Sourcery VSIPL++ ImplementationIn the VSIPL++ API, every matrix has an associated "map" which describes how the matrix is distributed across processors. If you assign a matrix with one distribution to a matrix with another, Sourcery VSIPL++ will automatically reorganize the data. (On a system using MPI, Sourcery VSIPL++ will use MPI to do this for you, but you will not need to directly make use of MPI.) The following seven-statement example shows how easy it is to implement a corner turn with Sourcery VSIPL++. You just declare maps that correspond to the row-wise and column-wise distributions, create matrices using those maps, and then assign one matrix to the other. // Define the input matrix type. Map<> map_in (num_processors(), 1); typedef Matrix<float, Dense<2, float, row2_type, Map<> > > view_in_type; // Define the output matrix type. Map<> map_out(1, num_processors()); typedef Matrix<float, Dense<2, float, col2_type, Map<> > > view_out_type; // Create the matrices. view_in_type in (rows, cols, map_in); view_out_type out(rows, cols, map_out); // Perform the corner turn. out = in; MPI ImplementationThe MPI implementation is far more complicated. MPI does not have a global picture of the data layout; instead, each node manages its own local slice of a global object. Therefore, in order to perform the corner-turn, MPI dataypes must be manually created for the input and output of the operation. The construction of these datatypes is complex. Furthermore, the datatypes must be manually allocated and deallocated. Therefore, the example below requires 29 statements to perform the corner-turn.
Sourcery VSIPL++ AdvantagesSourcery G++ has other advantages, beyond requiring significantly less code:
|
|||||||||||||||||||||||||
|
||||||||||||||||||||||||||