£okì has asked for the wisdom of the Perl Monks concerning the following question:

Ok, I've got a program that is going to require massive CPU time thus I would like to do symetrical multiprocessing to make use of my duel processor server. Does anyone know of anywhere I could go to learn more about this and perl? Does Perl do this on it's own? is there no way I can do this? anythig at ALL would help greatly.

Replies are listed 'Best First'.
Re: SMP and Perl
by ejf (Hermit) on Apr 10, 2002 at 17:23 UTC

    Perl doesn't "do" this on its own; at least not if you don't use threads, and even then I doubt that Perl itself would do it (anyway, I've been given to understand that Perl's current threading implementation isn't considered production-quality, yet) ...

    That does not mean that you cannot make use of your two processors, however. If your problem can be split up into two parts, you can just fork your perl process and let each process run on a different processor (as to how exactly you make different processes use different processors depends on your OS and whether it can do this automatically for you). If the processes need to exchange (limited) amounts of data, you can do this through pipes or shared memory/Inter Process Communication.

    If your problem can not be split up, you are at a loss anyway, since SMP is not going to help you one bit then in any case.

    BTW, please at least reread your question next time (and cut down on the errors), and use some better formatting :)

Re: SMP and Perl
by tachyon (Chancellor) on Apr 10, 2002 at 19:07 UTC

    There are of course several approaches to big problems. Throw more processing power at it is one approach. Optimise you code is another. Cynics might liken this to the difference between Windows and *nix. Optimising code takes many forms but Benchmark and Devel::DProf will help you see where the cycles are going. Writing bottle neck bits in C may be beneficial as may utilising fork() for parallel processing.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      I just have a LOT of data to parse. it's a SIMPLE code relativly just takes a lot of power to run through that much data and I was hoping to speed it up. I think I have solved the problem thou. I'm going to rewrite it in c. Yes, I still love perl, just gonna do this one in c plus then I can compile it with more ease. Thanks guys.

        If you post some data and sample code you may be able to save yourself a rewrite. I believe the perlmonks record for recreational optimisation stands at several orders of magnitude. Good Perl can be extremely fast (in some cases only half the speed of C) and has some top notch optimisation tools.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: SMP and Perl
by vladb (Vicar) on Apr 10, 2002 at 17:19 UTC
    To learn about SMP on Linux in general, I'd suggest an informative article here:

    http://www.heise.de/ct/english/98/13/140/

    I can't recall now, but I believe it does mention Perl somewhere in there.

    Other than that, unfortunately, I'm not aware of Perl specific modules that would implement an SMP mechanism. You might look at pure C libraries (and probably even think of writing an interface module in perl?.. crazy, but ;)

    "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith
      If only I was master pfunk like you guys and could do that. ... .. . alas, perl is a hobby for me thus I am nowhere near that advanced.