Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I could take you through the first one in a similar way,

I have enough time on a hades hot afternoon to do a lazy write-up for the first pi script from examples for Sub::Genius, that, on my terminal, is tripped up at run_any which calls run_once . I think this frames the issue:

$ cat 5.pi.txt b 10 c n s n n v b 283 c v s #save 5.pi.txt $ perl -d pi.pl Loading DB routines from perl5db.pl version 1.55 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(pi.pl:8): my $NUM_THREADS = 5; DB<1> source 5.pi.txt + >> b 10 >> c main::(pi.pl:10): my $preplan = q{ main::(pi.pl:11): ( main::(pi.pl:12): step0 main::(pi.pl:13): & main::(pi.pl:14): step1 main::(pi.pl:15): & main::(pi.pl:16): step2 main::(pi.pl:17): & main::(pi.pl:18): step3 main::(pi.pl:19): & main::(pi.pl:20): step4 main::(pi.pl:21): & main::(pi.pl:22): step5 main::(pi.pl:23): ) main::(pi.pl:24): reduce >> n main::(pi.pl:27): my $final_scope = Sub::Genius->new( preplan => $p +replan )->run_any( scope => { sum => 0.0, num_steps => 1_000_000, pi +=> undef } ); >> s Sub::Genius::new(/usr/local/share/perl/5.30.0/Sub/Genius.pm:15): 15: my $pkg = shift; >> n Sub::Genius::new(/usr/local/share/perl/5.30.0/Sub/Genius.pm:16): 16: my %self = @_; >> n Sub::Genius::new(/usr/local/share/perl/5.30.0/Sub/Genius.pm:17): 17: my $self = \%self; >> v 14 sub new { 15: my $pkg = shift; 16: my %self = @_; 17==> my $self = \%self; 18: bless $self, $pkg; 19: die qq{'preplan' parameter required!\n} if not defined $sel +f->{preplan}; 20 21 # set to undef to disable preprocessing 22: if ( not exists $self->{preprocess} ) { 23: $self->{preprocess} = 1; >> b 283 >> c Sub::Genius::run_once(/usr/local/share/perl/5.30.0/Sub/Genius.pm:283): 283: die $@ if $@; # be nice and die for easier debu +ggering >> v 280: local $@; 281: foreach my $sub (@seq) { 282: eval sprintf( qq{%s%s(\$opts{scope});}, $opts{ns}, + $sub ); 283==>b die $@ if $@; # be nice and die for easier d +ebuggering 284 } 285 } 286: return $opts{scope}; 287 } 288 289 # >> s Undefined subroutine &main::step called at (eval 38)[/usr/local/share/ +perl/5.30.0/Sub/Genius.pm:282] line 1. at /usr/local/share/perl/5.30.0/Sub/Genius.pm line 283. Sub::Genius::run_once(Sub::Genius=HASH(0x5643068207b0), "scope", H +ASH(0x564306ab08c0)) called at /usr/local/share/perl/5.30.0/Sub/Geniu +s.pm line 245 Sub::Genius::run_any(Sub::Genius=HASH(0x5643068207b0), "scope", HA +SH(0x564306ab08c0)) called at pi.pl line 27 Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. >> #save 5.pi.txt DB<5> q + $ cat pi.pl #!/usr/bin/env perl use strict; use warnings; use Sub::Genius; my $NUM_THREADS = 5; my $preplan = q{ ( step0 & step1 & step2 & step3 & step4 & step5 ) reduce }; my $final_scope = Sub::Genius->new( preplan => $preplan )->run_any( sc +ope => { sum => 0.0, num_steps => 1_000_000, pi => undef } ); printf qq{pi = %f\n}, $final_scope->{pi}; sub step0 { my $scope = shift; my $step_id = 0; $scope->{sum} = _do_calc( $step_id, $scope ); return $scope; } sub step1 { my $scope = shift; my $step_id = 1; $scope->{sum} = _do_calc( $step_id, $scope ); return $scope; } sub step2 { my $scope = shift; my $step_id = 2; $scope->{sum} = _do_calc( $step_id, $scope ); return $scope; } sub step3 { my $scope = shift; my $step_id = 3; $scope->{sum} = _do_calc( $step_id, $scope ); return $scope; } sub step4 { my $scope = shift; my $step_id = 4; $scope->{sum} = _do_calc( $step_id, $scope ); return $scope; } sub step5 { my $scope = shift; my $step_id = 5; $scope->{sum} = _do_calc( $step_id, $scope ); return $scope; } sub reduce { my $scope = shift; my $num_steps = $scope->{num_steps}; my $step = 1 / $num_steps; $scope->{pi} = $scope->{sum} * $step; return $scope; } sub _do_calc { my ( $id, $scope ) = @_; my $sum = $scope->{sum}; my $num_steps = $scope->{num_steps}; my $step = 1 / $num_steps; for ( my $i = $id ; $i < $num_steps ; $i += $NUM_THREADS ) { my $x = ( $i + 0.5 ) * $step; $sum += 4.0 / ( 1 + $x * $x ); } return $sum; } $

Even with the number of threads bumped to 6, it goes no farther. I must say I'm puzzled, because I do not see how this source differs from what Brett shows to compile and behave on his screen at the one hour mark of his second youtube presentation.


In reply to Re^3: a look at Sub::Genius with the debugger, and use v in 2021 by Aldebaran
in thread a look at Sub::Genius with the debugger, and use v in 2021 by Aldebaran

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 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? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2022-05-21 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (78 votes). Check out past polls.

    Notices?