![]() |
|
|
#1 |
|
Oct 2004
Austria
9B216 Posts |
I am attempting to code a pearl script which launches multiple threads of ECM.exe: (configured to use 7 threads of my i7 here, as the 8th thread is busy with an msieve poly select)
Code:
use Math::BigInt;
use Math::BigFloat;
$NUM_CPUS=7;
$NUM_THREADS=$NUM_CPUS;
$ECHO_CMDLINE=1;
### ECM parameters ###
$B1=43000000;
$NUM_CURVES=777; #total number of curves
$MAXMEM=900; #max. memory used per thread
$INPUTFILE="alq10212.2315.txt";
$ECM_OUTPUTNAME="alq10212.2315_43e6.out";
############# nothing configurable below here! #######################
$CNUM=int($NUM_CURVES)/$NUM_THREADS; #note: this will cause rounding errors if $NUM_CURVES is not divisible by $NUM_THREADS
if ($NUM_THREADS != 1) {
use Config;
if (!($Config{usethreads})) {
printf "This version of Perl doesn't support multiple threads. Only using 1 thread.";
$NUM_THREADS=1;
}
else {
use Thread qw(async);
}
}
# statements below copied from factmsieve.pl and modified for running ecm
if ($NUM_THREADS==1) {
# It's very important to call like this, so that if the user CTRL-C's,
# or otherwise kills the process, we see it and terminate as well.
unlink($ECM_OUTPUTNAME);
$cmd="ecm -nn -maxmem $MAXMEM -c $CNUM <$INPUTFILE $B1 >>$ECM_OUTPUTNAME";
print "=>$cmd\n" if($ECHO_CMDLINE);
$res=system($cmd);
}
else {
@thd = (1 .. $NUM_THREADS);
for ($j=1;$j<=$NUM_THREADS;$j++) {
unlink("$ECM_OUTPUTNAME.T$j");
$cmd="ECM -nn -maxmem $MAXMEM -c $CNUM <$INPUTFILE $B1 >>$ECM_OUTPUTNAME.T$j";
print "=>$cmd\n" if($ECHO_CMDLINE);
$thd[$j]=async{system($cmd)};
}
# $res=0;
# for ($j=1;$j<=$NUM_THREADS;$j++) {
# $res+=eval{$thd[$j]->join()};
# }
# for ($j=1;$j<=$NUM_THREADS;$j++) {
# if ($LATSIEVE_SIDE) {
# unlink <$JOBNAME.T$j.afb.1> if ($sieverRL == ($Q0-1));
# }
# else {
# unlink <$JOBNAME.T$j.afb.0> if ($sieverAL == ($Q0-1));
# }
# $cmd="\"$CAT\" $SIEVER_OUTPUTNAME.T$j >> $SIEVER_OUTPUTNAME";
# print "=>$cmd\n" if($ECHO_CMDLINE);
# concat("$SIEVER_OUTPUTNAME.T$j", ">>", "$SIEVER_OUTPUTNAME");
# unlink "$SIEVER_OUTPUTNAME.T$j";
# }
}
Code:
=>ECM -nn -maxmem 900 -c 111 <alq10212.2315.txt 43000000 >>alq10212.2315_43e6.out.T1
=>ECM -nn -maxmem 900 -c 111 <alq10212.2315.txt 43000000 >>alq10212.2315_43e6.out.T2
=>ECM -nn -maxmem 900 -c 111 <alq10212.2315.txt 43000000 >>alq10212.2315_43e6.out.T3
=>ECM -nn -maxmem 900 -c 111 <alq10212.2315.txt 43000000 >>alq10212.2315_43e6.out.T4
=>ECM -nn -maxmem 900 -c 111 <alq10212.2315.txt 43000000 >>alq10212.2315_43e6.out.T5
=>ECM -nn -maxmem 900 -c 111 <alq10212.2315.txt 43000000 >>alq10212.2315_43e6.out.T6
=>ECM -nn -maxmem 900 -c 111 <alq10212.2315.txt 43000000 >>alq10212.2315_43e6.out.T7
Perl exited with active threads:
7 running and unjoined
0 finished and unjoined
0 running and detached
Last fiddled with by Andi47 on 2010-08-24 at 15:08 |
|
|
|
|
|
#2 | |
|
Oct 2004
Austria
2·17·73 Posts |
Quote:
Code:
$res=0;
for ($j=1;$j<=$NUM_THREADS;$j++) {
$res+=eval{$thd[$j]->join()};
}
|
|
|
|
|
|
|
#3 |
|
Oct 2004
Austria
2·17·73 Posts |
Current version (with the line mentioned in post #2 NOT commented out):
Code:
use Math::BigInt;
use Math::BigFloat;
# Bah, this causes a fatal error if GMP BigInt is not available.
# use Math::BigInt lib => 'GMP';
$NUM_CPUS=7;
$NUM_THREADS=$NUM_CPUS;
$ECHO_CMDLINE=1;
### ECM parameters ###
$B1=26e7;
$NUM_CURVES=91; #total number of curves
$MAXMEM=900; #max. memory used per thread
#$INPUTFILE="alq10212.2351.txt";
#$ECM_OUTPUTNAME="alq10212.2351_3e6.out";
$INPUTFILE="alq4788.2549.txt";
$ECM_OUTPUTNAME="alq4788.2549_h_26e7.out";
############# nothing configurable below here! #######################
$CNUM=int($NUM_CURVES)/$NUM_THREADS; #note: this will cause rounding errors if $NUM_CURVES is not divisible by $NUM_THREADS
if ($NUM_THREADS != 1) {
use Config;
if (!($Config{usethreads})) {
printf "This version of Perl doesn't support multiple threads. Only using 1 thread.";
$NUM_THREADS=1;
}
else {
use Thread qw(async);
}
}
if ($NUM_THREADS==1) {
# It's very important to call like this, so that if the user CTRL-C's,
# or otherwise kills the process, we see it and terminate as well.
unlink($ECM_OUTPUTNAME);
$cmd="ecm -nn -maxmem $MAXMEM -c $CNUM <$INPUTFILE $B1 >>$ECM_OUTPUTNAME";
print "=>$cmd\n" if($ECHO_CMDLINE);
$res=system($cmd);
}
else {
@thd = (1 .. $NUM_THREADS);
for ($j=1;$j<=$NUM_THREADS;$j++) {
unlink("$ECM_OUTPUTNAME.T$j");
$cmd="ECM -nn -maxmem $MAXMEM -c $CNUM <$INPUTFILE $B1 >>$ECM_OUTPUTNAME.T$j";
print "=>$cmd\n" if($ECHO_CMDLINE);
$thd[$j]=async{system($cmd)};
}
$res=0;
for ($j=1;$j<=$NUM_THREADS;$j++) {
$res+=eval{$thd[$j]->join()};
}
}
|
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple threads per assignment? | f0rteOC | Hardware | 3 | 2016-02-29 06:08 |
| using multiple threads on an LL assignment | tha | Software | 4 | 2016-02-02 13:49 |
| Question: Multiple sequences in NewPGen format | Xentar | Conjectures 'R Us | 3 | 2008-01-20 15:56 |
| Multiple threads efficiency... | Xyzzy | Linux | 1 | 2004-12-31 21:03 |
| multiple computer question | yankeesmarc923 | Software | 13 | 2003-12-13 20:39 |