Mark,

The easiest solution is most probably to use OpenMP if you have a serial 
program up and running. it consists "simply" of adding pragmas to the serial 
code. Any compiler should be able to handle this today. This avoids going to 
the basics like pthreads. It's a fast solution, but it's efficiency varies 
considerably on how it is used.

Efficient parallel programming is an art and requires a lot of careful 
planning.
- Your code snippet indicates a very fine grained parallelism. This may lead 
to increased overhead. For example, don't create the threads in every cycle. 
It is best (if possible) to create the threads only once (and to use core 
affinity).
- Cache properties and data access patterns play an important role.
- You wote that your program is a filter. So I would expect it to run in a 
pipe. Here, the properties of the other pipe members may have an important 
influence. Thread migration may become a penalty.

Dont't panic if in a first attempt, your parallel version is slower than the 
serial one.

Best,
Michael

Am Donnerstag, 22. September 2011, 00:21:43 schrieb Mark Heath:
> Hi Guys,
> 
> I'm wondering if anyone has some skeleton C code for writing
> multithreaded filters.
> 
> Similar to this kind of pseudo code;
> 
> while not end of file {
> 
>       read frame
> 
>       create threads (number of CPUs)
> 
>       for y = 1 to height {
> 
>               while no available threads  { wait for a thread to finish; }
> 
>               run in thread { for x = 1 to width { process pixel} }
>       }
>       write frame
> }
> 
> I've written a temporal bilateral filter and an nl-means filter and
> they are slow, so was looking to speed things up on my multi cpu
> machines.
> 
> If not, I'll see if I can generate my own skeleton.
> 
> Thanks
> Mark
> 
> ---------------------------------------------------------------------------
> --- All the data continuously generated in your IT infrastructure contains
> a definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Mjpeg-users mailing list
> Mjpeg-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mjpeg-users

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users

Reply via email to