Coffeehouse Thread

9 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

2 Xeon Processors and .NET Code

Back to Forum: Coffeehouse
  • User profile image
    Red5

    I recently wrote some .NET code to convert some 4-bit TIFF images to 2-bit.  The TIFF images are full page (8.5" x 11") scans.  The test converts 395 images.  I use a 3rd party library for .NET from LEADTools for this.

    I ran my code on a few different machines to establish some time-to-process benchmarks.

    One of the machines is a loaner from HP that has 2 XEON 3.0 processors (4MB/1333).  SAS harddrive and 4GB RAM. It is not a server, it is a workstation. Running WinXP SP2.

    When I ran the test with both processors, it took around 3 minutes.  I had Task Manager open and watched the performance; I noticed only 2 of the 4 processor windows were being utilized.

    I removed the 2nd processor and reran the test.  This time it finished about 3 seconds quicker. Both (2 of 2) of the processor windows in Task Manager were working

    Question: Is there any way for me to indicate in my code to utilize more than one processor?  Or is this something the OS decides for me?

    I did a lame attempt at gooling on this and came up empty.  I have very little knowlegde on how the hardware works in situations like this as it relates to processors.

  • User profile image
    nlondon

    This is just an idea... try creating a 4-thread threadpool... Then set up each thread to pop the next image off a stack and process it or terminate if no images are left in the stack...  Then start each thread.  I bet that will optimize appropriately for 4 processors.  If so, you can have your program detect the number of processors and set up an appropriately sized threadpool.  Make sure you appropriately manage concurrency to ensure each image is processed only once.

  • User profile image
    cheong

    Red5 wrote:
    Question: Is there any way for me to indicate in my code to utilize more than one processor?  Or is this something the OS decides for me?

    You can use Process.GetCurrentProcess() then use Process.ProcessorAffinity property to set it. It uses a "mask style" value to specify the processor(s) your process wants to run on. The default is to run on all processors available so you can use the initial value to mask out the processors that you don't want it to run.

    More details on MSDN.

    Recent Achievement unlocked: Code Avenger Tier 4/6: You see dead program. A lot!
    Last modified
  • User profile image
    JPeless

    Without explicitly creating code that will process your images on more than one thread there isn't any magic solution any OS provides for utilizing every processor in a multi-processor machine.

    Not knowing exactly what your code looks like at the moment I would suggest something like cheong suggested, except I wouldn't mess around with processor affinity unless you have a very good reason to.  If you use the built in thread pool, based on the potential CPU usage of converting TIFF images, you will likely want to put an upper limit on the max number of thread, but testing is the only way to reveal what actually works best.

    Your built in thread pool size will default to 100 (25x#CPU cores).

  • User profile image
    RichardRudek

    When you say more than one processor, I think you'll find that each "processor" (package) is actually a dual-core.

    Anyway, it sounds like the LEADTools library, by default, only uses two cores - perhaps optimised for just two cores. In which case, either talk with LEADTools to confirm this, or try running two separate threads.

  • User profile image
    Deactivated User

    Comment removed at user's request.

  • User profile image
    cheong

    JPeless wrote:
    except I wouldn't mess around with processor affinity unless you have a very good reason to.

    I origionally think in your way, but seeing the remarks in the MSDN page I refered to make me think that it's possible for the OS to schedule your process to run on another processor your process is running on, so I guess it'll be better (and simplier) to make sure it run on only one of them.

    Recent Achievement unlocked: Code Avenger Tier 4/6: You see dead program. A lot!
    Last modified
  • User profile image
    kettch

    I just had thoughts of the CCR pop into my head. It's been a while since I got a chance to play with it, but this is exactly the sort of thing that I think it would rock at.

    EDIT: I should define CCR, or rather C9 can: here, and here

  • User profile image
    Red5

    Thanks everyone for your comments.

    I found a series of articles here that have helped somewhat, along with the author's downloadable example program.

    I am going to educate myself and give it a go. I'll try working on multiple threads and see if I can't get some positive results.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.