#! /usr/bin/perl 
## Make several runs of an n-body gravitation simulator
## and display the results.

@BODIES = (" 400", " 800", "1600", "3200");
@THREADS = (" 1", " 2", " 4", " 8", "16", "32", "64");
$steps = 3;

$num_bodies  = $BODIES[1];

`./nbody $num_bodies $steps`;	# run once to throw out startup costs

for $num_threads (@THREADS) {
  $ENV{'OMP_NUM_THREADS'} = $num_threads;
  print "($num_threads threads) ";
  for $num_bodies (@BODIES) {
    $rate = `./nbody $num_bodies $steps | tail -1`;
    chomp($rate);
    print "$num_bodies: $rate; ";
  }
  print "\n";
}
