I wrote a serial code for a matrix-vector multiplication in a Coordinate
Storage Format(COO). COO method has already made a big speed-up. My matrix
is in a tridiagonal form. I want to parallelize the code and see how the
parallelizm improves the code. My matrix could grow up to
2.000.000*2.000.000. Any efficient parallelization approach doesn't come to
my mind (I have written some basic mpi programs but not much more. So my
experience is limited.) Could you give me some headstart?
Thanks.
Özhan Fenerci
#include
#include
#include <vector>
#include <iostream>
#include "mpi.h"
#include
int main(int argc, char *argv[] ) {
using namespace boost::numeric::ublas;
using std::cout;
using std::endl;
int numprocs, rank, chunk_size, i,j;
int max, mymax,rem;
int totalNonZeros; //totalNonZeros of TriDiagonal Matrix
MPI_Status status;
//b=A*x
banded_matrix<double> A (10, 10, 1, 1);
//vector<double> x(10);
//vector<double> b(10);
int* x = new int[10];
int* b = new int[10];
/* Initialize MPI */
MPI_Init( &argc,&argv);
MPI_Comm_rank( MPI_COMM_WORLD, &rank);
MPI_Comm_size( MPI_COMM_WORLD, &numprocs);
//MPI_Status status;
if (rank == 0) {
for (signed i = 0; i < signed (A.size1 ()); ++ i) {
for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed
(A.size2 ())); ++j)
A (i, j) = i + j;
x[i]= 1;
}
}
if(rank == 0) {
cout << A <