in reply to Re: how to multiply an array of number as fast as posible
in thread how to multiply an array of number as fast as posible

the overhead in starting a thread exceeds the performance boost.

What performance boost could you possibly get? The CPU is already working at 100% calculating the number. That's why threads makes no sense in this case.

  • Comment on Re^2: how to multiply an array of number as fast as posible

Replies are listed 'Best First'.
Re^3: how to multiply an array of number as fast as posible
by kennethk (Abbot) on Sep 02, 2010 at 16:15 UTC
    The CPU is already working at 100% calculating the number.

    Yes, one core is working at 100% to calculate the product. By splitting the list in half, two cores are working at 100% - the OP cites having a dual core. It just so happens that in this case:

    loop_overhead + n*multiplication < thread_overhead + loop_overhead + (n/2)*multiplication

    as I would expect for this kind of simple operation. But throw in transcendental functions and maybe the balance shifts.

Re^3: how to multiply an array of number as fast as posible
by BrowserUk (Patriarch) on Sep 02, 2010 at 16:40 UTC
    What performance boost could you possibly get? The CPU is already working at 100% calculating the number. That's why threads makes no sense in this case.

    Ahem! From the OP.

    i have a dual core proc

    If he decided to calculate this in arbitrary precision, using both his CPU's would make a huge difference.

      I am under the impression that Perl threads are bound to one CPU. Is that wrong?
        I am under the impression that Perl threads are bound to one CPU. Is that wrong?

        Yes. That is wrong.

        Perl's threads are kernel threads, and kernel threads run on any available cpu.