|
-
Jul 4th, 2006, 12:56 PM
#1
Thread Starter
PowerPoster
VC++ multi threading
I was interested in hearing VC++ programmers ideas on this. which of the 2 multhithreading methods would be better/faster/safer? This is for a long calculation loop ... entire loop is repeated multiple times (in separate threads).
1) do all the multithreading in VC++ dll
2) just do the loop in the VC++ dll and use VB dot net to start the loops in threads.
I hope this thread doesnt turn into one of those long heated discussions about what multi threading really is ... :-)
Any thoughts greatly appreciated.
-
Jul 5th, 2006, 04:18 AM
#2
Re: VC++ multi threading
Doesn't matter. The main time is spent in the loop; whatever overhead the threading might have is insignificant. If it isn't, you're misusing multithreading.
It's a question of design. Is the multithreading here just a question of how the service of the DLL (calculating something) is implemented? Then do it in the DLL. In other words, let's assume that the DLL does some heavy image computing. If you decide to use multiple CPU cores if they're available and divide the image into parts, letting each part be calculated by its own thread, then do the multithreading in the DLL. It's an implementation issue: to the caller, i.e. the VB.Net app, all that matters is the result.
On the other hand, if the multithreading is not an implementation detail, do it in the app. If the image computation cannot divide the image (for whatever reason; probably heavy cross dependencies in the data) and each computation is forced to be single-threaded, you can still batch-process multiple images and start one thread for each. That's the decision of the app, though, to make multiple calls into the DLL, thus the multithreading should be done by the app.
Hope that helped.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 5th, 2006, 09:58 AM
#3
Thread Starter
PowerPoster
Re: VC++ multi threading
Thanks CornedBee ... very informative.
Here is something to give you an idea of what i want to accomplish (this isnt the actual code, of course):
for i = 1 to 100
do until Finished = True
'much nastiness here ... can take an hour before Finished = True
Loop
next i
since each of the 100 do loops above are independent in their calcs, I am free to put them in multiple threads to take advantage of multiple cpus and dual core cpus. (Ive even noticed performance gains in multithreading on single core single cpu machines so Ive got to think that I would really gain a lot of performance on a new dual core cpu).
once all of the do loops are done, I do process it all together, but this is a relatively simple procedure with insignificant overhead.
Any comments on the best approach to make this as lean and fast as possible?
Thanks again!
-
Jul 5th, 2006, 02:59 PM
#4
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|