mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > PrimeNet > GPU to 72

Reply
 
Thread Tools
Old 2012-08-17, 16:43   #12
Brain
 
Brain's Avatar
 
Dec 2009
Peine, Germany

5138 Posts
Default

Quote:
Originally Posted by chalsall View Post
I'm particularly interested in those who run ActiveState's Perl, and/or cygwin's.
Me ActiveState.
Code:
This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x64-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2011, Larry Wall

Binary build 1402 [295342] provided by ActiveState http://www.ActiveState.com
Built Oct  7 2011 15:19:36
Code:
C:\Computing>perl -w fork.pl
Entering TestFork...
Entering pipe_from_fork...
No output at all in your version. I added some prints, find attached.
Attached Files
File Type: txt fork.pl.txt (920 Bytes, 152 views)

Last fiddled with by Brain on 2012-08-17 at 16:47 Reason: added Perl version info
Brain is offline   Reply With Quote
Old 2012-08-17, 16:55   #13
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

2·5·7·139 Posts
Default

Quote:
Originally Posted by Brain View Post
Me ActiveState.
Code:
C:\Computing>perl -w fork.pl
Entering TestFork...
Entering pipe_from_fork...
No output at all in your version. I added some prints, find attached.
Thank you very much Brain. Important data.

So it is dying (or freezing) in pipe_from_fork.

Could I ask you to change the pipe_from_fork subroutine to this, and then run again?

Code:
sub pipe_from_fork ($) {
   my $parent = shift;
print "pipe_from_fork - 1 -- $$\n";
   pipe $parent, my $child or die;
print "pipe_from_fork - 2 -- $$\n";

   my $pid = fork();
print "pipe_from_fork - 3 -- $$\n";
   die "fork() failed: $!" unless defined $pid;
print "pipe_from_fork - 4 -- $$ -- PID: $pid\n";

   if ($pid) {
print "pipe_from_fork - 5 -- $$ -- PID: $pid\n";
      close $child;
print "pipe_from_fork - 5.1 -- $$ -- PID: $pid\n";
   } else {
print "pipe_from_fork - 6 -- $$\n";
      close $parent;
print "pipe_from_fork - 6.1 -- $$\n";
      open(STDOUT, ">&=" . fileno($child)) or die;
print "pipe_from_fork - 6.2 -- $$\n";
   }
print "pipe_from_fork - 7 -- $$\n";
   $pid;
}

Last fiddled with by chalsall on 2012-08-17 at 17:11
chalsall is online now   Reply With Quote
Old 2012-08-17, 17:03   #14
Brain
 
Brain's Avatar
 
Dec 2009
Peine, Germany

331 Posts
Default

Ready.
Code:
Entering TestFork...
Entering pipe_from_fork...
pipe_from_fork - 1 -- 3440
pipe_from_fork - 2 -- 3440
pipe_from_fork - 3 -- 3440
pipe_from_fork - 4 -- 3440
pipe_from_fork - 5 -- 3440
pipe_from_fork - 7 -- 3440
pipe_from_fork - 3 -- -5324
pipe_from_fork - 4 -- -5324
pipe_from_fork - 6 -- -5324
Not terminating on its own.
Attached Files
File Type: txt fork.pl.txt (1.2 KB, 145 views)

Last fiddled with by Brain on 2012-08-17 at 17:09 Reason: attachment fixed
Brain is offline   Reply With Quote
Old 2012-08-17, 17:14   #15
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

2·5·7·139 Posts
Default

Quote:
Originally Posted by Brain View Post
Ready.
Code:
Entering TestFork...
Entering pipe_from_fork...
pipe_from_fork - 1 -- 3440
pipe_from_fork - 2 -- 3440
pipe_from_fork - 3 -- 3440
pipe_from_fork - 4 -- 3440
pipe_from_fork - 5 -- 3440
pipe_from_fork - 7 -- 3440
pipe_from_fork - 3 -- -5324
pipe_from_fork - 4 -- -5324
pipe_from_fork - 6 -- -5324
Not terminating on its own.
OK. Thanks.

One last code change (above) which I'd love if you could run.

I suspect that 6 will return, but 6.1 might not, and 6.2 won't. I don't understand why yet.

Thanks for your help with this.
chalsall is online now   Reply With Quote
Old 2012-08-17, 17:22   #16
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

961010 Posts
Default

Nice experiment here. Strawberry, 5.16, 64 bits.

I added few prints into it:
Code:
#!/usr/bin/perl -w

TestFork(1);
TestFork(2);
exit;


sub TestFork {
   ($Test) = @_;

   print "one ${Test}\n";
   if (pipe_from_fork('BAR')) {
      # parent
      print "two ${Test}\n";
      while (<BAR>) { print; }
      print "three ${Test}\n";
      close BAR;
      print "\n\nTest completed.  Was output seen from the child?\n\n\n";
   } else {
      # child
      print "four ${Test}\n";
      if ($Test == 1) {
         print "five ${Test}\n";
         for ($Cnt = 0; $Cnt<5; $Cnt++) {
            print "We're here!  Cnt: ${Cnt}\n";
            sleep(1);
         }
         print "six ${Test}\n";
         exit(0);
      } else {
         print "seven ${Test}\n";
         exec("dir");
         print "eight ${Test}\n";
      }
   }
}


sub pipe_from_fork ($) {
   print "inside 1\n";
   my $parent = shift;
   pipe $parent, my $child or die;

   print "inside 2\n";
   my $pid = fork();
   die "fork() failed: $!" unless defined $pid;

   print "inside 3\n";
   if ($pid) {
      close $child;
      print "inside 4\n";
   } else {
      close $parent;
      open(STDOUT, ">&=" . fileno($child)) or die;
      print "inside 5\n";
   }
   print "outside\n";
   $pid;
}
The output:
Code:
>perl chalsall.pl
Statement unlikely to be reached at chalsall.pl line 33.
        (Maybe you meant system() when you said exec()?)
one 1
inside 1
inside 2
inside 3
inside 4
outside
inside 3
two 1
Terminating on signal SIGINT(2)
(it does not terminate by itself, need ctrl+c).
The blue lines, "outside" and the second "inside 3" lines, are sometime exchanged, if i run it many times, this means he is really multitasking there, the blue "inside 3" is print by the forked process which is faster sometimes. What else is doing, no idea...
LaurV is offline   Reply With Quote
Old 2012-08-17, 17:29   #17
Brain
 
Brain's Avatar
 
Dec 2009
Peine, Germany

331 Posts
Default

Quote:
Originally Posted by chalsall View Post
OK. Thanks.

One last code change (above) which I'd love if you could run.

I suspect that 6 will return, but 6.1 might not, and 6.2 won't. I don't understand why yet.

Thanks for your help with this.
Not terminating...
Code:
Entering TestFork...
Entering pipe_from_fork...
pipe_from_fork - 1 -- 2344
pipe_from_fork - 2 -- 2344
pipe_from_fork - 3 -- 2344
pipe_from_fork - 4 -- 2344 -- PID: -6040
pipe_from_fork - 5 -- 2344 -- PID: -6040
pipe_from_fork - 3 -- -6040
pipe_from_fork - 4 -- -6040 -- PID: 0
pipe_from_fork - 5.1 -- 2344 -- PID: -6040
pipe_from_fork - 7 -- 2344
pipe_from_fork - 6 -- -6040
pipe_from_fork - 6.1 -- -6040
Attached Files
File Type: txt fork.pl.txt (1.3 KB, 155 views)
Brain is offline   Reply With Quote
Old 2012-08-17, 17:31   #18
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

100101100010102 Posts
Default

with my main and your function:

Code:
one 1
pipe_from_fork - 1 -- 2652
pipe_from_fork - 2 -- 2652
pipe_from_fork - 3 -- 2652
pipe_from_fork - 4 -- 2652 -- PID: -4404
pipe_from_fork - 5 -- 2652 -- PID: -4404
pipe_from_fork - 3 -- -4404
pipe_from_fork - 5.1 -- 2652 -- PID: -4404
pipe_from_fork - 4 -- -4404 -- PID: 0
pipe_from_fork - 7 -- 2652
pipe_from_fork - 6 -- -4404
two 1
pipe_from_fork - 6.1 -- -4404
Terminating on signal SIGINT(2)
LaurV is offline   Reply With Quote
Old 2012-08-17, 17:35   #19
schickel
 
schickel's Avatar
 
"Frank <^>"
Dec 2004
CDP Janesville

2×1,061 Posts
Default

I'm running ActivePerl 5.10.1 Build 1006 and get the same result as Brain:
Code:
C:\Aliquot\Data>perl fork.pl
Entering TestFork...
Entering pipe_from_fork...
pipe_from_fork - 1 -- 5272
pipe_from_fork - 2 -- 5272
pipe_from_fork - 3 -- 5272
pipe_from_fork - 4 -- 5272 -- PID: -4680
pipe_from_fork - 5 -- 5272 -- PID: -4680
pipe_from_fork - 5.1 -- 5272 -- PID: -4680
pipe_from_fork - 7 -- 5272
pipe_from_fork - 3 -- -4680
pipe_from_fork - 4 -- -4680 -- PID: 0
pipe_from_fork - 6 -- -4680
pipe_from_fork - 6.1 -- -4680
Also with no termination....
schickel is offline   Reply With Quote
Old 2012-08-17, 17:36   #20
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

260216 Posts
Default

Quote:
Originally Posted by Brain View Post
Not terminating...
OK. Thanks Brain and LaurV and schickel.

So the Perl statement "open(STDOUT, ">&=" . fileno($child)) or die;" doesn't work under Windows. Even though it is supposed to.

Hmmmm....

Last fiddled with by chalsall on 2012-08-17 at 17:38 Reason: s/Thanks Brain and LuarV/Thanks Brain and LaurV and schickel/
chalsall is online now   Reply With Quote
Old 2012-08-17, 18:26   #21
kjaget
 
kjaget's Avatar
 
Jun 2005

3·43 Posts
Default

How about using the piped version of open? Here's something I whipped up a while back to run mfaktc from Perl. Works on activestate and cygwin.

Code:
      open (MFAKTC, "$mfaktc_bin -tf $this_exp $this_depth $this_depth_end |");
      my $factor_found = 0;
      my $ok_end = 0;
      while ($line = <MFAKTC>)
      {
	 print LOG $line;
	 if ($line =~ /found \d+ factor\(s\) for M/)
	 {
	    $factor_found = 1;
	 }
	 elsif ($line =~ /cleared assignment/)
	 {
	    $ok_end = 1;
	 }
      }
      close MFAKTC;
Might make it more difficult to run multiple copies of mfaktc, though
kjaget is offline   Reply With Quote
Old 2012-08-17, 18:53   #22
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

2×5×7×139 Posts
Default

Quote:
Originally Posted by kjaget View Post
How about using the piped version of open? Here's something I whipped up a while back to run mfaktc from Perl. Works on activestate and cygwin.
According to the documentation, that's not supposed to work.

But clearly the documentation is wrong. I'll drill down on your example shortly.

Thanks Kevin.
chalsall is online now   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic submit results + fetch assignments for mfaktc? DuskFalls GPU Computing 5 2017-12-02 00:34
Simple Script to get Trial Factoring Work jfamestad PrimeNet 3 2016-11-06 20:32
Why trial factoring work chopped into chunks? lidocorc PrimeNet 4 2008-11-06 18:48
How does the trial factoring work with 15K*2^n-1 jocelynl 15k Search 0 2003-07-11 14:23
How does trial-factoring work? ThomRuley Software 5 2003-05-30 20:34

All times are UTC. The time now is 14:22.


Fri Jul 16 14:22:21 UTC 2021 up 49 days, 12:09, 2 users, load averages: 2.20, 1.77, 1.73

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.