Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Congratulations on the PDL parallelisation effort.

Thank you for sharing the article. I'm trying to run the demonstration, beginning on page 6, and encountered a C build failure. See issue on GitHub. Thanks to @mohawk2, this is working.

Update: Remove the size args to pgswin. Thanks, etj.
Update: Display the compute time.

use strict; use warnings; use PDL; use PDL::Graphics::Simple; use Time::HiRes 'time'; no PDL::NiceSlice; # prevents interference use Inline Pdlpp => <<'EOPP'; pp_def('pp_mandel', # Pars (signature) specs threadable arguments. Pars => 'c(n=2); [o]o()', # OtherPars specs scalar arguments. OtherPars => 'int max_it', Code => <<'EOC', // All this code gets wrapped automagically in a thread loop. // It starts a fresh C block, so you can declare stuff up top. // The $GENERIC() macro is the overall expression type. int i; // Iterator $GENERIC() rp0 = $c(n=>0), ip0 = $c(n=>1); // Copy the initial val +ue to rp0/ip0 $GENERIC() rp = rp0, ip = ip0; // Copy again for the i +nitial iteration $GENERIC() rp2 = rp*rp, ip2 = ip*ip; // Find RP^2 and IP^2 f +or magnitude and z^2 // The OtherPars are in the $COMP macro. for(i=$COMP(max_it); rp2+ip2 < 4 && i; i--) { ip *= 2 * rp; rp = rp2 - ip2; // Calculate M_i(z)^2 rp += rp0; ip += ip0; // Add z rp2 = rp*rp; ip2 = ip*ip; // Calculate rp^2 and ip^2 for n +ext time } $o()= i; // Assign the iterator to the output value EOC ); EOPP my $cen = pdl(-0.74897,0.05708); my $coords = $cen + (ndcoords(501,501)/250 - 1) * 0.001; my $w = pgswin(); my $start = time(); $w->image( $coords->using(0,1), $coords->pp_mandel(2500), {title=>"Man +delbrot"} ); print "Compute time: ", time() - $start, $/; print "Press the enter key to exit\n"; <STDIN>;

In reply to Re^2: [OT] Merry Christmas and gift of love by marioroy
in thread [OT] Merry Christmas and gift of love by marioroy

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-29 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found