good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^4: How to use my two processorsby remzak (Acolyte) |
on Jan 19, 2010 at 15:55 UTC ( [id://818228]=note: print w/replies, xml ) | Need Help?? |
I completed the project (as complete as it will ever be). I ended up using one child thread with a queue to create two parallel processes. It was exactly what I wanted, and it was extremely simple to implement. The main process created the valid numbers; the child process paired them up. The two ran very much in parallel since the pairing algorithm actually ran more efficiently working on a growing list of numbers. If I had more processors, I'm not sure how I'd partition the logic.
I think I'd have to re-framed the overall algorithm to take advantage of many processors; then, it may have been more efficient to multi-thread and partition like you suggested. The time dropped to 44% of the original (2.25 times faster). Some of the speed came not from the threading, but just learning how to write more efficient perl statements. I learned that there are expensive operations in perl and some very fast operations... I ended up tweaking many, and changing how I was storing the data to take advantage of these realities. I am sure the program could be made even faster once I understand perl a bit better. Thank you to everyone for your help!
In Section
Seekers of Perl Wisdom
|
|