Reduction with unsupported structures

General OpenMP discussion

Reduction with unsupported structures

Postby chameleon » Wed May 30, 2012 2:23 pm

The structures:
Code: Select all
class SparseVector : public vector<SparseElement>;
class SparseMatrix : public vector<SparseVector>;  //(vectors are rows)

I want to do this:
Code: Select all
SparseVector result = (SparseVector) vector * (SparseMatrix) matrix;  // 1xN = 1xM * MxN

So, the code is:
Code: Select all
SparseVector result;
for (size_t z = 0; z < M; z++)
   result += (SparseElement) vector[z] * (SparseVector) matrix[z];

How can parallelize this code, especially operator += ???

I must add a critical section, or is better to create many vectors (huge memory cost) and add them in pairs?
chameleon
 
Posts: 8
Joined: Mon Jan 23, 2012 6:37 pm

Re: Reduction with unsupported structures

Postby chameleon » Wed May 30, 2012 2:39 pm

Hmmm....
I believe, one result per working thread to avoid critical sections, and then reduction in pairs.
chameleon
 
Posts: 8
Joined: Mon Jan 23, 2012 6:37 pm


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 11 guests