omp crash

General OpenMP discussion

omp crash

Postby smarchesini » Tue Aug 14, 2012 6:40 pm

Hi, I am a novice to OpenMP...
I have this code -below- that crashes if I uncomment the line
#pragma omp parallel for reduction(+: Sumr, Sumi)
is there something I am doing wrong? (is it gcc 4.2)?
also, since I have 3 loops, is there a simple way to do this all parallel?

Thanks,
S.


static void dotp(
double framedpr[],
double framedpi[],
double Ar[],
double Ai[],
double Br[],
double Bi[],
size_t dx[],
size_t dy[],
mwSize N,
mwSize M,
mwSize nframes,
size_t bcol0[],
size_t brow0[],
size_t ptr0[],
mwSize nptr
)
{

size_t row_ii;
/* loop over frames -- row index */
for (row_ii=1; row_ii<nptr; row_ii++)
{
size_t row00=brow0[ptr0[row_ii]-1]-1;
/* loop over frames -- column index */
long long int col_ii;
for (col_ii=ptr0[row_ii-1]; col_ii<ptr0[row_ii]; col_ii++)
{

size_t col00=bcol0[col_ii]-1;
size_t dxi=dx[row00+col00*nframes];
size_t dyi=dy[row00+col00*nframes];
size_t Dx=(N-abs(dxi)); /*integration width */
size_t Dy=M-abs(dyi); /*integration height */
/*offset, including row...*/
size_t DD=row00*N*M+(dxi+abs(dxi))/2*M+(dyi+abs(dyi))/2;
/* offset between frame1 and frame2 (stack) */
size_t Dij=(-dxi)*M-dyi+(col00-row00)*N*M;
long long int pos; /*if I use size_t it complains that it is unsigned otherwise */

double Sumr=0;
double Sumi=0;
size_t ii1,ii2;

// #pragma omp parallel for reduction(+: Sumr, Sumi) private(pos,ii1,ii2)

/* loop within frame overlap */
for(pos=0; pos<(Dx*Dy); pos++)
{
ii1 = pos/Dy*M+pos%Dy+DD;
ii2=ii1+Dij;
Sumr+=Ar[ii1]*Br[ii2]+Ai[ii1]*Bi[ii2];
Sumi+=Ar[ii1]*Bi[ii2]-Ai[ii1]*Br[ii2];
} /* loop within frame overlap */

framedpr[col_ii]=Sumr;
framedpi[col_ii]=Sumi;
}
}
return;
}
smarchesini
 
Posts: 1
Joined: Tue Aug 14, 2012 4:42 pm

Re: omp crash

Postby MarkB » Wed Aug 15, 2012 2:37 am

Hi S,

I see nothing wrong with your OpenMP: it would be worth trying a more recent version of gcc (4.2 is pretty ancient in terms of the OpenMP implementation!).

It looks like you could parallelise the outermost (row_ii) loop, provided the iterations of this loop do not write to overlapping parts of the framepdr and framedpi arrays.

Hope that helps,
Mark.
MarkB
 
Posts: 450
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: omp crash

Postby ftinetti » Wed Aug 15, 2012 3:38 am

Hi S.,

I'd include in a shared clause every scalar which is used and not changed, i.e. Dx, Dy, M, DD, Dij (maybe I'm missing some). And I think it's good idea to use a newer gcc version too.

Fernando.
ftinetti
 
Posts: 582
Joined: Wed Feb 10, 2010 2:44 pm


Return to Using OpenMP

Who is online

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