/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this Perl program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
500Failed  551   

Read the ↓ make, command line, and program output logs to see how this program was run.

Read spectral-norm benchmark to see what this program should do.

 notes

This is perl 5, version 18, subversion 0 (v5.18.0) built for x86_64-linux

Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
                        PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL
                        USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF

 spectral-norm Perl #4 program source code

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org/
#
# Contributed by Andrew Rodland
# modified by R. Jelinek
# multicore by Mykola Zubach

use strict;
use threads;

my $cpus = num_cpus();

my $n = shift || 500;
my @v = multiplyAtAv(
    multiplyAtAv(
        multiplyAtAv((1) x $n)
    )
);

my @u = multiplyAtAv(@v);

my ($vBv, $vv);
my $i = 0;
for my $v (@v) {
    $vBv += $u[$i++] * $v;
    $vv += $v ** 2;
}

printf "%0.9f\n", sqrt($vBv / $vv);

sub multiplyAtAv {
    return multiplyAtv(multiplyAv(@_));
}

sub eval_A {
    use integer;
    my $div = (($_[0] + $_[1]) * ($_[0] + $_[1] + 1) >> 1) + $_[0] + 1;
    no integer;
    1 / $div;
}

sub multiplyAv {
    my($begin, $end, @threads);
    my $chunk = int($#_ / $cpus) + 1;
    
    for($begin = 0; $begin < $#_; $begin = $end + 1) {
        $end = $begin + $chunk;
        $end = $#_ if $end > $#_;
        push @threads, threads->create( sub {
            my $begin = shift;
            my $end = shift;
            return map {
                my ($i, $sum) = ($_);
                $sum += eval_A($i, $_) * $_[$_] for (0 .. $#_);
                $sum;
            } ($begin .. $end);
       }, $begin, $end, @_);
    }
    return map $_->join, @threads;
}

sub multiplyAtv {
    my($begin, $end, @threads);
    my $chunk = int($#_ / $cpus) + 1;
    
    for($begin = 0; $begin < $#_; $begin = $end + 1) {
        $end = $begin + $chunk;
        $end = $#_ if $end > $#_;
        push @threads, threads->create( sub {
            my $begin = shift;
            my $end = shift;
            return map {
                my ($i, $sum) = ($_);
                $sum += eval_A($_, $i) * $_[$_] for (0 .. $#_);
                $sum;
            } ($begin .. $end);
       }, $begin, $end, @_);
    }
    return map $_->join, @threads;
}

sub num_cpus {
    open my $fh, '</proc/cpuinfo' or return 4;
    my $cpus;
    while (<$fh>) {
        $cpus ++ if /^processor\s+:/;
    }
    return $cpus;
}

 make, command-line, and program output logs

Tue, 07 Jan 2014 02:19:38 GMT

COMMAND LINE:
/usr/local/src/perl-5.18.0_no_ithreads_no_multi/bin/perl spectralnorm.perl-4.perl 500

PROGRAM FAILED 


PROGRAM OUTPUT:

This Perl not built to support threads
Compilation failed in require at spectralnorm.perl-4.perl line 9.
BEGIN failed--compilation aborted at spectralnorm.perl-4.perl line 9.

Revised BSD license

  Home   Conclusions   License   Play