OpenMP中关于共享和私有的定义适用于指针变量吗? 比如下面一段代码
unsigned char *pBlockImg = NULL;
int i,j;
unsigned short StartX = 0;
unsigned short StartY = 0;
#pragma omp parallel for private(StartX,StartY,j)
for (i = 0; i < nYBlocks; ++i)
{
StartY = i * nYBlockSize;
for (j = 0; j < nXBlocks; ++j)
{
StartX = j * nXBlockSize;
int nXValid = 0; int nYValid = 0; nXValid = nXBlockSize<(nSrcImgWidth - StartX)?nXBlockSize:(nSrcImgWidth-StartX);
nYValid = nYBlockSize<(nSrcImgHeight - StartY)?nYBlockSize:(nSrcImgHeight - StartY);
pBlockImg = new unsigned char[nXValid*nYValid];
// 操作
if (pBlockImg)
{
delete []pBlockImg;
pBlockImg = NULL;
}
}
}
请问上面这段代码中pBlockImg是共享的还是私有的,多个线程操作时,会不会产生混乱?
------解决方案--------------------------------------------------------
并行区内未经说明的,缺省都是共享的。唯一的例外是循环下标变量