when generating lots of permutations.... Is there a way I can use the power of all my processsors?

It depends how you are generating your permutations?

Assuming your permutations are (or can be) derived from a linear range of integers, then partitioning that range into sub-ranges and running each in a separate thread brings almost linear gains for cpu-bound processing.

This is a contrived example, but could be representative of the type of processing you're doing based on what you've said:

#! perl -slw use strict; use Data::Dump qw[ pp ]; use threads; use Time::HiRes qw[ time ]; sub thread { my $tid = threads->tid; my( $start, $end ) = @_; warn "$tid: processing $start to $end\n"; my $count = 0; for my $mon ( $start .. $end ) { $count += unpack '%32b*', pack 'N', $mon; } return $count; } our $T //= 1; our $M //= 1e6; my( $step, $s, @ranges ) = ( int $M / $T, 0 ); push( @ranges, [ $s, $s+$step -1] ), $s+=$step for 1 ..$T; $ranges[ -1][1] = $M; my $start = time; my @threads = map{ threads->create( \&thread, @$_ ); } @ranges; my $total = 0; $total += $_->join for @threads; printf "Total = %d (in %f seconds using $T threads)\n", $total, time() +-$start; __END__ C:\test>888714 -M=100e6 -T=1 1: processing 0 to 100e6 Total = 1314447116 (in 46.340000 seconds using 1 threads) C:\test>888714 -M=100e6 -T=2 1: processing 0 to 49999999 2: processing 50000000 to 100e6 Total = 1314447116 (in 23.269000 seconds using 2 threads) C:\test>888714 -M=100e6 -T=3 1: processing 0 to 33333332 2: processing 33333333 to 66666665 3: processing 66666666 to 100e6 Total = 1314447116 (in 15.878000 seconds using 3 threads) C:\test>888714 -M=100e6 -T=4 1: processing 0 to 24999999 2: processing 25000000 to 49999999 3: processing 50000000 to 74999999 4: processing 75000000 to 100e6 Total = 1314447116 (in 12.960000 seconds using 4 threads)

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Multi-kernel processors. by BrowserUk
in thread Multi-kernel processors. by latejita

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.