use strict; use warnings; die "Not UNIX OS\n" if $^O eq 'MSWin32'; # usage: script.pl > out use Inline 'C' => Config => CCFLAGSEX => '-O2'; use Inline 'C' => <<'END_C'; #include void c_fput_float(float value, char c, FILE *stream) { static char buf[] = "0.0\n"; int whole = (int) value; int frac = (int) ((value - whole) * 10); buf[0] = '0' + whole; buf[2] = '0' + frac; buf[3] = c; fputs(buf, stream); } unsigned long c_repetition (int fd, float p0) { unsigned long count = 0; FILE *stream = fdopen(fd, "wb"); float p1,p2,p3,p4,p5,p6,p7,p8,p9,p10; for (p1=0; p1<=1; p1+=0.2) { for (p2=0; p2<=1; p2+=0.2) { for (p3=0; p3<=1; p3+=0.2) { for (p4=0; p4<=1; p4+=0.2) { for (p5=0; p5<=1; p5+=0.2) { for (p6=0; p6<=1; p6+=0.2) { for (p7=0; p7<=1; p7+=0.2) { for (p8=0; p8<=1; p8+=0.2) { for (p9=0; p9<=1; p9+=0.2) { for (p10=0; p10<=1; p10+=0.2) { c_fput_float(p0, '\t', stream); c_fput_float(p1, '\t', stream); c_fput_float(p2, '\t', stream); c_fput_float(p3, '\t', stream); c_fput_float(p4, '\t', stream); c_fput_float(p5, '\t', stream); c_fput_float(p6, '\t', stream); c_fput_float(p7, '\t', stream); c_fput_float(p8, '\t', stream); c_fput_float(p9, '\t', stream); c_fput_float(p10, '\t', stream); c_fput_float(1.0, '\t', stream); c_fput_float(1.0, '\n', stream); count++; } } } } } } } } } } fflush(stream); fclose(stream); return count; } END_C # Run on UNIX machines with 48+ GiB of RAM. # Otherwise, remove the -use_dev_shm argument. # Beware, consumes 18 GiB in temp dir. use MCE::Signal qw[ $tmp_dir -use_dev_shm ]; use Time::HiRes qw[ time ]; use MCE::Loop; use MCE::Shared; my $start = time; my $c_shared = MCE::Shared->scalar(0); MCE::Loop::init { max_workers => 6, chunk_size => 1 }; # loop through desired combinations mce_loop_s { my $p0 = $_; open my $fh, ">", "$tmp_dir/".MCE->chunk_id(); my $c = c_repetition(fileno($fh), $p0); close $fh; $c_shared->incrby($c); } 0.0, 1.0, 0.2, '%0.1f'; # p0: seq_beg, seq_end, seq_step, format MCE::Loop::finish(); system("cat $tmp_dir/[1-6]; rm -fr $tmp_dir"); printf STDERR "Took: %0.3f seconds [%ld]\n", time() - $start, $c_shared->get();