Click here to Skip to main content
15,890,609 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhelp Pin
ramina sen1-Jun-09 8:33
ramina sen1-Jun-09 8:33 
QuestionRe: help Pin
David Crow1-Jun-09 9:35
David Crow1-Jun-09 9:35 
AnswerRe: help Pin
Michael Schubert1-Jun-09 22:00
Michael Schubert1-Jun-09 22:00 
QuestionCView::OnFilePrintPreview Pin
Software20071-Jun-09 7:35
Software20071-Jun-09 7:35 
QuestionAdd a scrollbar when I StrechtBlt() an image? Pin
Episodio11-Jun-09 6:44
Episodio11-Jun-09 6:44 
QuestionAfter response WM_DRAWITEM message , how to make a function that it is similar to CMemu::SetMenuItemBitmaps [modified] Pin
bdwzz1-Jun-09 5:53
bdwzz1-Jun-09 5:53 
Questionthreading differences VC6 v VS2005 Pin
Chris Losinger1-Jun-09 4:29
professionalChris Losinger1-Jun-09 4:29 
AnswerRe: threading differences VC6 v VS2005 Pin
Luc Pattyn1-Jun-09 4:52
sitebuilderLuc Pattyn1-Jun-09 4:52 
Hi Chris,

I don't think the IDE is fundamentally involved in the difference of the results. IMO you either are unfortunate or made some major mistake.

Here are some possible mistakes:
- a total disregard of "locality of reference": in the ideal case all data ever gets loaded only once in the data cache(s); having two or more threads working somewhat independently may make that harder to achieve.
- too much need for synchronization;
- an overall alignment problem, e.g. when both threads need new cache loads at the same time, they both sit idle waiting for main memory to respond. At best memory accesses should be staggered somehow by design.
- cache trashing for shared data (when the same data resides in the data cache of two distinct CPU chips and gets written by one processor, it needs updating in the other cache, a very expensive operation); the extreme case is when synchronization is based on spin locks, and two or more spin lock variables reside in the same cache line. (There is an interesting Intel Application Note on keeping no more than one sync variable in a cache line, applicable to dual processor chips, not Core2Duo).

Image processing generally is quite vulnerable to all kinds of such phenomena, mainly because there is a rather high transport/calculation ratio, where data streaming can work well (making the job entirely compute bound) and can work very badly (making it bus bandwidth bound); and the difference may be minor and accidental, as well as major by a faulty approach.

I would suggest you research this case starting with a simple experiment: ignore the middle border pixels, i.e. let one thread handle the left 45% of the image, the other the rightside 45% of the image, and ignore the middle 10%. Have it run on both IDE; if you did everything right you should notice it runs about twice as fast as a single-threaded solution, and it is IDE independent. Then all you have to do is look into the way you handle the middle 10% of the image.
BTW: don't forget to observe CPU load in Task Manager for both the 1 and 2-threaded attempts.

If OTOH the two-thread solution isn't really twice as fast as the single-threaded one, forget about the middle 10% (and all sync stuff) until you got the threading right for the independent image areas.

If you were to want more specific advice, please provide detailed information on the task: system hardware, typical image size, kind of image operation (e.g. filter size, is it inherently sequential?), etc.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

GeneralRe: threading differences VC6 v VS2005 Pin
Chris Losinger1-Jun-09 5:10
professionalChris Losinger1-Jun-09 5:10 
GeneralRe: threading differences VC6 v VS2005 Pin
Luc Pattyn1-Jun-09 5:49
sitebuilderLuc Pattyn1-Jun-09 5:49 
GeneralRe: threading differences VC6 v VS2005 Pin
Chris Losinger1-Jun-09 6:15
professionalChris Losinger1-Jun-09 6:15 
GeneralRe: threading differences VC6 v VS2005 Pin
Randor 1-Jun-09 7:14
professional Randor 1-Jun-09 7:14 
GeneralRe: threading differences VC6 v VS2005 Pin
ZelionThunder2-Jun-09 17:43
ZelionThunder2-Jun-09 17:43 
GeneralRe: threading differences VC6 v VS2005 Pin
Luc Pattyn1-Jun-09 6:03
sitebuilderLuc Pattyn1-Jun-09 6:03 
GeneralRe: threading differences VC6 v VS2005 Pin
Chris Losinger1-Jun-09 6:16
professionalChris Losinger1-Jun-09 6:16 
AnswerRe: threading differences VC6 v VS2005 Pin
Joe Woodbury1-Jun-09 7:50
professionalJoe Woodbury1-Jun-09 7:50 
GeneralRe: threading differences VC6 v VS2005 Pin
Chris Losinger1-Jun-09 7:53
professionalChris Losinger1-Jun-09 7:53 
QuestionGadjet integration with IE toolbar? Pin
ritz12341-Jun-09 4:16
ritz12341-Jun-09 4:16 
QuestionIn Window forms application C++ Pin
wael_r1-Jun-09 3:33
wael_r1-Jun-09 3:33 
AnswerRe: In Window forms application C++ Pin
David Crow1-Jun-09 3:45
David Crow1-Jun-09 3:45 
AnswerRe: In Window forms application C++ Pin
fanronghua1-Jun-09 19:25
fanronghua1-Jun-09 19:25 
QuestionTyping in Unicode language Pin
Benjamin Bruno1-Jun-09 3:32
Benjamin Bruno1-Jun-09 3:32 
QuestionSNMP development Pin
Jim Crafton1-Jun-09 3:25
Jim Crafton1-Jun-09 3:25 
AnswerRe: SNMP development Pin
Joe Woodbury1-Jun-09 8:19
professionalJoe Woodbury1-Jun-09 8:19 
GeneralRe: SNMP development Pin
Jim Crafton1-Jun-09 8:26
Jim Crafton1-Jun-09 8:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.