×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Multithreaded code runs slow

Multithreaded code runs slow

Multithreaded code runs slow

(OP)
I wrote two versions of a small test program that calculates sin(x) using a Taylor series expansion.  The single thread version calculates each term of the expansion sequentially and then adds them up for the final result.  The multi thread version calculates each term in a separate thread then adds them up when all threads have completed.  The programs calculate a million values just so I can time them with a stopwatch.  On my XP machine with a quad core processor the multi thread version runs much faster than the single thread version.  When I moved the programs to a Windows 7 machine with a quad core processor the multi thread version runs SLOWER than the single thread version!  Has anyone else seen this type behavior? I have tried changing various Windows parameters, such as processor affinity and thread priority, but to no avail.  Thanks in advance.

RE: Multithreaded code runs slow

- check using Task Manager or Process Explorer if it's actually using all CPU's
- does the code release cycles to other processes (cooperative multitasking)?
- Is the Win7 system actually a quad-core or a dual-core with hyper threading? (and idem for the XP system?)

RE: Multithreaded code runs slow

(OP)
The Win7 system is a true quad core processor.  I have tried it with hyperthreading on and off and it makes no significant difference.  Looking at the performance graphs in process manager it appears that the single thread version uses a large percentage of one of the cores.  The multi thread version splits its activity between four cores but at a much reduced percentage.  I really wanted it to use the highest percentage of each core as possible.  My ultimate goal would be to start a big calculation and let it crunch numbers till it's done.  In this case I wouldn't really care about how fast the rest of the OS is running.

I wrote no specific code to release cycles to other processes.  My code is written using National Instruments LabWindows CVI2010 integrated development envirnoment.  I used their multithreading libraries so I can't be sure what's going on beneath the surface.  The NI tech reps are also looking into the problem.  I have sent them my code and they see the same behavior.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close