Hi, I have this function which i want to parallelize using openmp sections. I broke the function into various sections and applied #pragma omp sections but it gives segmentation fault. Can somebody please explain why and a solution to it. Should i use some clause with sections. Which one and how please.
/*!
***********************************************************************
* \brief
* calculation of SAD for larger blocks on the basis of 4x4 blocks // function 4
***********************************************************************
*/
void SetupLargerBlocks (int list, int refindex, int max_pos)
{
#define ADD_UP_BLOCKS() _o=*_bo; _i=*_bi; _j=*_bj; for(pos=0;pos<max_pos;pos++) _o[pos] = _i[pos] + _j[pos];
#define INCREMENT(inc) _bo+=inc; _bi+=inc; _bj+=inc;
int pos, **_bo, **_bi, **_bj;
register int *_o, *_i, *_j;
//#pragma omp parallel
#pragma omp sections
{
#pragma omp section
{//--- blocktype 6 ---
_bo = BlockSAD[list][refindex][6];
_bi = BlockSAD[list][refindex][7];
_bj = _bi + 4;
ADD_UP_BLOCKS(); INCREMENT(1);
ADD_UP_BLOCKS(); INCREMENT(1);
ADD_UP_BLOCKS(); INCREMENT(1);
ADD_UP_BLOCKS(); INCREMENT(5);
ADD_UP_BLOCKS(); INCREMENT(1);
ADD_UP_BLOCKS(); INCREMENT(1);
ADD_UP_BLOCKS(); INCREMENT(1);
ADD_UP_BLOCKS();
}
#pragma omp section
{
//--- blocktype 5 ---
_bo = BlockSAD[list][refindex][5];
_bi = BlockSAD[list][refindex][7];
_bj = _bi + 1;
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS();
}
#pragma omp section
{
//--- blocktype 4 ---
_bo = BlockSAD[list][refindex][4];
_bi = BlockSAD[list][refindex][6];
_bj = _bi + 1;
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS(); INCREMENT(6);
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS();
}
#pragma omp section
{
//--- blocktype 3 ---
_bo = BlockSAD[list][refindex][3];
_bi = BlockSAD[list][refindex][4];
_bj = _bi + 8;
ADD_UP_BLOCKS(); INCREMENT(2);
ADD_UP_BLOCKS();
}
#pragma omp section
{
//--- blocktype 2 ---
_bo = BlockSAD[list][refindex][2];
_bi = BlockSAD[list][refindex][4];
_bj = _bi + 2;
ADD_UP_BLOCKS(); INCREMENT(8);
ADD_UP_BLOCKS();
}
#pragma omp section
{
//--- blocktype 1 ---
_bo = BlockSAD[list][refindex][1];
_bi = BlockSAD[list][refindex][3];
_bj = _bi + 2;
ADD_UP_BLOCKS();
}
}
}