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?


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;
} /* loop within frame overlap */


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,
Posts: 746
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.

Posts: 603
Joined: Wed Feb 10, 2010 2:44 pm

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 4 guests