BeeJ
2/9/2012 11:34:00 PM
Karl E. Peterson submitted this idea :
> BeeJ explained :
>> Karl E. Peterson laid this down on his screen :
>>> I'm fishing for thoughts and/or ideas here. I have a pretty complex set
>>> of calculations that I'd really like to spread out amongst a few cores.
>>> The general structure of the situation is like this...
>>>
>>> Everything's currently contained within a single console mode application.
>>> Output is directed to both the console window and a log file.
>>>
>>> The preliminary phase takes about 4 minutes to calculate and write to disk
>>> approximately 4GB of disposable working data.
>>>
>>> This is currently followed by seven sequential processing phases that use
>>> this working data to produce various results based on different models.
>>> Each of these phases can take between 3 and 12 minutes! In addition to
>>> CPU, they are obviously very disk i/o intensive.
>>>
>>> Total model run (prelim + 7) takes about an hour, run sequentially.
>>>
>>> So it seems to me the logical direction to take it is to perform that
>>> preliminary phase, then spawn off the seven other phases in parallel,
>>> monitoring each, and deleting the working data upon completion of the
>>> last.
>>>
>>> I'm not opposed to each parallel phase being its own process. And I
>>> wonder if that might be not only the simplest, but effectively darn near
>>> the most elegant, approach to take? (This is my current inclination.)
>>>
>>> If threads seem to anyone to be the better way to go, I'd like to hear
>>> why? And by what mechanism?
>>>
>>> To me, the big issues are:
>>>
>>> * I need a console for each phase,
>>> * The console would ideally remain open after completion, to be closed
>>> by the user after review,
>>> * the main "controller" needs to know when all is done, necessitating a
>>> series of signals from the workers.
>>>
>>> If it matters, the whole thing will ultimately be initiated through a
>>> batch file. And the code is currently segregated so that any of the seven
>>> calc phases can be triggered from command line switches. (I'd just need
>>> to get the part about the prelim data precalc'd.)
>>>
>>> I guess the idea of threads just seems *oh so slightly* less fragile when
>>> it comes to knowing about the completion of each phase.
>>>
>>> Thoughts?
>>
>> From this junior coding guy.
>> I have an app that starts multiple ActiveX EXEs.
>> AxEXE1 does intensive graphic screen work. I usually have four AxEXE1
>> running at a time.
>> AxEXE2 does movies (running a the same time as AxEXE1) multiple
>> instantiation. Had two of these and four of AxEXE1 running together.
>> AxEXE3 talks to USB device. AxEXE3 has time sensitive DAC step outputs.
>> AxEXE4 talks to DMX device. This one is pretty relaxed compared to the
>> others.
>> AxEXE5 talks to X10 device. Kind of slow stuff here.
>> All run together.
>> They all talk to the main app at regular intervals: get new commands to run
>> and return data and status.
>>
>> I was amazed that they all ran smoothly together on a dual core laptop.
>> I have not tried it on my quad code desktop yet.
>>
>> Previously I tried running all methods in the main app and they all
>> stuttered and sputtered. Looked terrible.
>>
>> The ActiveX EXEs really work.
>>
>> What is amazing too me is that with all of that and only two cores it was
>> all smooth.
>
> Heh, the wonders of pre-emptive multitasking! :-)
>
>> Once I got the hang of an ActiveX EXE I rapidly built them all.
>> Unfortunately I was never able to find an all encompassing book about
>> ActiveX EXE. Usually it is just a chapter in the middle of ActiveX
>> Controls so I found it difficult to get all the stuff together but now I
>> have and it is just too much fun. And thanks again to some in this group
>> that gave me valuable inputs.
>
> Yeah, they (axEXE) are one of the Greater Mysteries of COM, it seems. I'm
> not all that sure the model code I'm dealing with is all that amenable to
> being refactored like that, though. Each of the seven main phases are
> extremely linear in nature. Although they are written to manipulate a fairly
> complex (axDLL) object model that abstracts the model building blocks.
Have you fiddled with Affinity and Priority?
I tried Priority on one of my apps but did not see any difference.
Might just be that the processing it was doing was not all that
intensive to see any difference.
Could be useful on a quad.
I would like to know if you have seen any improvement using either.
I have not been able to devote any time to Affinity and don't know
where to start on that one. Maybe some day.