using OpenMp. Could anyone give me a helping hand?
I'm running Leopard, XCode 3.0, GCC (4.0.1 ?), on an Intel based MacBook Pro.
so please forgive my confusion. I couldn't find any instructions on
looks roughly as follows... any help or advice would
// Assign FxBitmap info to local variables (to make subsequent code more generic)
UInt32 outMapWidth = [outMap width];
UInt32 outMapHeight = [outMap height];
UInt32 outRowBytes = [outMap rowBytes];
char *outData = (char *)[outMap dataPtr];
UInt32 inMapWidth = [inMap width];
UInt32 inMapHeight = [inMap height];
UInt32 inRowBytes = [inMap rowBytes];
char *inData = (char *)[inMap dataPtr];
UInt32 outPixelSizeInBytes = [outMap bytes] * [outMap numActiveChannels];
// Vars to handle possibility of input image being smaller than output image
UInt32 minWidth = (outMapWidth > inMapWidth) ? inMapWidth : outMapWidth;
UInt32 numBytesToCopy = minWidth * outPixelSizeInBytes;
// Loop variables
UInt32 y, x, xStart, fillerOffset;
char *inScanline, *outScanline, *outPixel;
#pragma omp parallel num_threads(2) private(y, x, inScanline, outScanline, xStart, fillerOffset, outPixel)
#pragma omp for
#pragma warning(disable:4700)
for (y = 0, inScanline = inData, outScanline = outData,
xStart = minWidth, fillerOffset = numBytesToCopy;
y < outMapHeight;
y++, inScanline += inRowBytes, outScanline += outRowBytes )
{
if (y < inMapHeight)
{
// Copy pixels from inMap to outMap
memcpy(outScanline, inScanline, numBytesToCopy);
}
else
{
xStart = 0;
fillerOffset = 0;
}
// If outMap is bigger than inMap, fill extra pixels with a fill color.
for ( x = xStart, outPixel = outScanline + fillerOffset;
x < outMapWidth;
x++, outPixel += outPixelSizeInBytes )
{
memcpy(outPixel, fillColor, outPixelSizeInBytes);
}
}
#pragma end for
#pragma end parallel
Everything compiles and runs without errors. Works on 8 & 32 bit images.
But, it isn't running the code in parallel on 2 cpus.
Any advice or hints are greatly appreciated.
-- Brian