shared 1d array c++ intel

General OpenMP discussion

shared 1d array c++ intel

Postby hich » Thu Nov 08, 2007 5:31 am

hello
I am trying to parallelize this

0 1 2 3 4 5 6 ... N
X X X X 0
X X X 1
X X 2
.
X N

Where node (i,j) depends on (i+1,j) and (i+1,j+1)
I have an array double A[(N+1)*nbrThreads]

double *const A = new double[(N+1)*nbrThreads]
#pragma omp parallel shared(A)
{
for (...)
for (...) {
A[i*nbrThreads + currentThreadNUmber] = A[ i*nbrThreads + otherThread ] + A[ (i+1)*nbrThreads + otherThread ] ;
cout << A[i*nbrThreads + currentThreadNUmber] ;
}

}

within the parallel region, if i write to the shared array , do I need to do some sort of flushing ? if i reread that cell straight away after,
shoud i see what i just written to it?

rds,
hich
 
Posts: 8
Joined: Thu Nov 08, 2007 5:17 am

Re: shared 1d array c++ intel

Postby lfm » Thu Nov 15, 2007 2:35 am

The barrier at the end of the parallel construct implies a flush, so after the parallel construct, the master thread sees all the new data, and in any following parallel region every thread will see the new data. If you read data inside the parallel region on the same thread that wrote the data, then you will see the new data; however, if you read data that was written by a different thread you may not see the new data.
lfm
 
Posts: 135
Joined: Sun Oct 21, 2007 4:58 pm
Location: OpenMP ARB


Return to Using OpenMP

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests