cvsuser     03/07/06 02:25:14

  Modified:    .        MANIFEST
  Added:       examples/benchmarks arriter.imc arriter_o1.imc arriter.pl
  Log:
  new arriter benchmark
  
  Revision  Changes    Path
  1.365     +3 -0      parrot/MANIFEST
  
  Index: MANIFEST
  ===================================================================
  RCS file: /cvs/public/parrot/MANIFEST,v
  retrieving revision 1.364
  retrieving revision 1.365
  diff -u -w -r1.364 -r1.365
  --- MANIFEST  4 Jul 2003 15:43:23 -0000       1.364
  +++ MANIFEST  6 Jul 2003 09:25:12 -0000       1.365
  @@ -221,6 +221,9 @@
   examples/assembly/trace.pasm                      [main]doc
   examples/assembly/uniq.pasm                       [main]doc
   examples/assembly/xml_parser.pasm                 [main]doc
  +examples/benchmarks/arriter.imc                   [main]doc
  +examples/benchmarks/arriter_o1.imc                [main]doc
  +examples/benchmarks/arriter.pl                    [main]doc
   examples/benchmarks/bench_newp.pasm               [main]doc
   examples/benchmarks/gc_alloc_new.pasm             [main]doc
   examples/benchmarks/gc_alloc_reuse.pasm           [main]doc
  
  
  
  1.1                  parrot/examples/benchmarks/arriter.imc
  
  Index: arriter.imc
  ===================================================================
  # hand crafted PIR code of arriter.pl
  # as it might come out of a compiler
  
  .sub _main
      new_pad 0
      .local PerlHash ha
      ha = new PerlHash
      store_lex -1, "ha", ha
      .local PerlHash hb
      ha = new PerlHash
      store_lex -1, "hb", hb
      .local PerlUndef i
      i = new PerlUndef
      store_lex -1, "i", i
      .local PerlArray k
      k = new PerlArray
      store_lex -1, "k", k
      .local PerlArray nk
      nk = new PerlArray
      store_lex -1, "nk", nk
      .local PerlUndef s
      s = new PerlUndef
      store_lex -1, "s", s
  
      find_lex $P0 , "i"
      $P1 = new PerlUndef
      $P1 = 10
  for_1_start:
      if $P0 >= $P1 goto for_1_end
        find_lex $P2 , "s"
        $P3 = new PerlUndef
        $P3 = 65
        $P4 = new PerlUndef
        add $P4, $P3, $P0
        set $I0, $P4
        chr $S0, $I0
        $P2 = new PerlUndef
        $P2 = $S0
        push k, $P2
        inc $P0
        branch for_1_start
  for_1_end:
  
      .local PerlUndef e
      e = new PerlUndef
      store_lex -1, "e", e
      find_lex $P0 , "e"
      $P0 = 0
      $P1 = new PerlUndef
      $P1 = 3
  for_2_start:
      if $P0 > $P1 goto for_2_end
        find_lex $P2 , "i"
        $P2 = 0
        $P3 = new PerlUndef
        $P3 = 10
      for_3_start:
        if $P2 >= $P3 goto for_3_end
            find_lex $P5 , "k"
            $P4 = new Iterator, $P5
            $P4 = 0
        iter_1_start:
            unless $P4 goto iter_1_end
                $P6 = new PerlUndef
                $P6 = 65
                $P7 = new PerlUndef
                $P8 = new PerlUndef
                find_lex $P11, "nk"
                add $P7, $P6, $P2       # 65 + $i
                $I0 = $P7
                chr $S0, $I0
                $P8 = $S0
                shift $P9, $P4          # $s
                # $P10 goes into the aggregate and can not be
                # pulled out of loop
                $P10 = new PerlUndef
                concat $P10, $P9, $P8
                push $P11, $P10
                branch iter_1_start
        iter_1_end:
            inc $P2
            branch for_3_start
      for_3_end:
        find_lex $P12 , "nk"
        clone $P13, $P12
        store_lex -1, "k", $P13
        $P12 = 0
        inc $P0
        branch for_2_start
  for_2_end:
  
      find_lex $P14 , "k"
      $I0 = $P14
      print $I0
      print "\n"
  
      $P15 = new Iterator, $P14
      $P15 = 0
      find_lex $P16 , "ha"
      $I1 = 0
  iter_2_start:
      unless $P15 goto iter_2_end
          inc $I1
        shift $P17, $P15
        $S0 = $P17
        $P16[$S0] = 1
        branch iter_2_start
  iter_2_end:
  
      print $I1
      print "\n"
      $I0 = $P16
      print $I0
      print "\n"
      $I0 = defined $P16["AAAAA"]
      print $I0
      $I0 = defined $P16["ABCDE"]
      print $I0
      $I0 = defined $P16["BBBBB"]
      print $I0
      $I0 = defined $P16["CCCCC"]
      print $I0
      $I0 = defined $P16["HHHHH"]
      print $I0
      $I0 = defined $P16["IIIII"]
      print $I0
      print "\n"
      end
  .end
  
  
  
  1.1                  parrot/examples/benchmarks/arriter_o1.imc
  
  Index: arriter_o1.imc
  ===================================================================
  # hand crafted PIR code of arriter.pl
  # optimizations:
  # - pull somecode out of the inner loop, s. opt below
  
  .sub _main
      new_pad 0
      .local PerlHash ha
      ha = new PerlHash
      store_lex -1, "ha", ha
      .local PerlHash hb
      ha = new PerlHash
      store_lex -1, "hb", hb
      .local PerlUndef i
      i = new PerlUndef
      store_lex -1, "i", i
      .local PerlArray k
      k = new PerlArray
      store_lex -1, "k", k
      .local PerlArray nk
      nk = new PerlArray
      store_lex -1, "nk", nk
      .local PerlUndef s
      s = new PerlUndef
      store_lex -1, "s", s
  
      find_lex $P0 , "i"
      $P1 = new PerlUndef
      $P1 = 10
  for_1_start:
      if $P0 >= $P1 goto for_1_end
        find_lex $P2 , "s"
        $P3 = new PerlUndef
        $P3 = 65
        $P4 = new PerlUndef
        add $P4, $P3, $P0
        set $I0, $P4
        chr $S0, $I0
        $P2 = new PerlUndef
        $P2 = $S0
        push k, $P2
        inc $P0
        branch for_1_start
  for_1_end:
  
      .local PerlUndef e
      e = new PerlUndef
      store_lex -1, "e", e
      find_lex $P0 , "e"
      $P0 = 0
      $P1 = new PerlUndef
      $P1 = 3
  for_2_start:
      if $P0 > $P1 goto for_2_end
        find_lex $P2 , "i"
        $P2 = 0
        $P3 = new PerlUndef
        $P3 = 10
      for_3_start:
        if $P2 >= $P3 goto for_3_end
            find_lex $P5 , "k"
            $P4 = new Iterator, $P5
            $P4 = 0
                # opt, out of loop
                # scalar results may go out of loop
                $P6 = new PerlUndef
                # invariant
                $P6 = 65
                $P7 = new PerlUndef
                $P8 = new PerlUndef
                find_lex $P11, "nk"
                # end opt
        iter_1_start:
            unless $P4 goto iter_1_end
                add $P7, $P6, $P2       # 65 + $i
                $I0 = $P7
                chr $S0, $I0
                $P8 = $S0
                shift $P9, $P4          # $s
                # $P10 goes into the aggregate and can not be
                # pulled out of loop
                $P10 = new PerlUndef
                concat $P10, $P9, $P8
                push $P11, $P10
                branch iter_1_start
        iter_1_end:
            inc $P2
            branch for_3_start
      for_3_end:
        find_lex $P12 , "nk"
        clone $P13, $P12
        store_lex -1, "k", $P13
        $P12 = 0
        inc $P0
        branch for_2_start
  for_2_end:
  
      find_lex $P14 , "k"
      $I0 = $P14
      print $I0
      print "\n"
  
      $P15 = new Iterator, $P14
      $P15 = 0
      find_lex $P16 , "ha"
      $I1 = 0
  iter_2_start:
      unless $P15 goto iter_2_end
          inc $I1
        shift $P17, $P15
        $S0 = $P17
        $P16[$S0] = 1
        branch iter_2_start
  iter_2_end:
  
      print $I1
      print "\n"
      $I0 = $P16
      print $I0
      print "\n"
      $I0 = defined $P16["AAAAA"]
      print $I0
      $I0 = defined $P16["ABCDE"]
      print $I0
      $I0 = defined $P16["BBBBB"]
      print $I0
      $I0 = defined $P16["CCCCC"]
      print $I0
      $I0 = defined $P16["HHHHH"]
      print $I0
      $I0 = defined $P16["IIIII"]
      print $I0
      print "\n"
      end
  .end
  
  
  
  1.1                  parrot/examples/benchmarks/arriter.pl
  
  Index: arriter.pl
  ===================================================================
  #!/usr/bin/perl -w
  use strict;
  
  my (%ha, %hb, $i, @k, @nk, $s);
  for ($i = 0; $i < 10; $i++) {
      $s = chr(65 + $i);
      push @k, $s;
  }
  for my $e (0..3) {
      for ($i = 0; $i < 10; $i++) {
        for $s (@k) {
            my $nk = $s . chr(65 + $i);
            push @nk, $nk;
        }
      }
      @k = @nk;
      @nk = ();
  }
  print scalar(@k), "\n";
  
  my $j = 0;
  for $s (@k) {
      ++$j;
      $ha{$s} = 1;
  }
  print "$j\n";
  print scalar keys(%ha), "\n";
  print $ha{"AAAAA"};
  print $ha{"ABCDE"};
  print $ha{"BBBBB"};
  print $ha{"CCCCC"};
  print $ha{"HHHHH"};
  print $ha{"IIIII"};
  print "\n"
  
  
  

Reply via email to