• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
FxPlug-in project set up for dual-processor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FxPlug-in project set up for dual-processor


  • Subject: FxPlug-in project set up for dual-processor
  • From: Brian Gardner <email@hidden>
  • Date: Sat, 9 Feb 2008 09:24:34 -0800

I'm having trouble getting my first FxPlug-in to use multiple cpus,
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.
I've tried setting the following compiler flag:

Edit Project Settings -> Build -> GCC 4.0 - Language -> Other C Flags: -openmp

Do I need to set something else, additionally (or instead)?
I'm trying to learn FxPlugs, XCode, and OpenMP at the same time,
so please forgive my confusion. I couldn't find any instructions on
setting up an FxPlug-in project for use with OpenMP. 

My simple copy in->out code, with openmp pragmas, 
looks roughly as follows... any help or advice would 
be GREATLY appreciated!

  // 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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: FxPlug-in project set up for dual-processor
      • From: Garrick Meeker <email@hidden>
  • Prev by Date: Re: FxPlugin context awareness
  • Next by Date: Re: FxPlug-in project set up for dual-processor
  • Previous by thread: Re: FxPlugin context awareness
  • Next by thread: Re: FxPlug-in project set up for dual-processor
  • Index(es):
    • Date
    • Thread