Clean up benchmarks; support uarch-specific counters
[riscv-tests.git] / benchmarks / vec-cmplxmult / cmplxmult_gendata.pl
1 #!/usr/bin/perl -w
2 #==========================================================================
3 # vvadd_gendata.pl
4 #
5 # Author : Christopher Batten (cbatten@mit.edu)
6 # Date : April 29, 2005
7 #
8 (our $usageMsg = <<'ENDMSG') =~ s/^\#//gm;
9 #
10 # Simple script which creates an input data set and the reference data
11 # for the vvadd benchmark.
12 #
13 ENDMSG
14
15 use strict "vars";
16 use warnings;
17 no warnings("once");
18 use Getopt::Long;
19
20 #--------------------------------------------------------------------------
21 # Command line processing
22 #--------------------------------------------------------------------------
23
24 our %opts;
25
26 sub usage()
27 {
28
29 print "\n";
30 print " Usage: vvadd_gendata.pl [options] \n";
31 print "\n";
32 print " Options:\n";
33 print " --help print this message\n";
34 print " --size size of input data [1000]\n";
35 print " --seed random seed [1]\n";
36 print "$usageMsg";
37
38 exit();
39 }
40
41 sub processCommandLine()
42 {
43
44 $opts{"help"} = 0;
45 $opts{"size"} = 1000;
46 $opts{"seed"} = 1;
47 Getopt::Long::GetOptions( \%opts, 'help|?', 'size:i', 'seed:i' ) or usage();
48 $opts{"help"} and usage();
49
50 }
51
52 #--------------------------------------------------------------------------
53 # Helper Functions
54 #--------------------------------------------------------------------------
55
56 sub printArray
57 {
58 my $arrayName = $_[0];
59 my $arrayRefReal = $_[1];
60 my $arrayRefImag = $_[2];
61
62 my $numCols = 20;
63 my $arrayLen = scalar(@{$arrayRefReal});
64
65 print "struct Complex ".$arrayName."[DATA_SIZE] = \n";
66 print "{\n";
67
68 print " ";
69 for ( my $i = 0; $i < $arrayLen; $i++ ) {
70 print sprintf("{%3.2f, %3.2f}",$arrayRefReal->[$i], $arrayRefImag->[$i]);
71 if ( $i != $arrayLen-1 ) {
72 print ",\n ";
73 }
74 }
75
76 print "\n};\n\n";
77 }
78
79 #--------------------------------------------------------------------------
80 # Main
81 #--------------------------------------------------------------------------
82
83 sub main()
84 {
85
86 processCommandLine();
87 srand($opts{"seed"});
88
89 my @values_real1;
90 my @values_imag1;
91 my @values_real2;
92 my @values_imag2;
93 my @product_real;
94 my @product_imag;
95 for ( my $i = 0; $i < $opts{"size"}; $i++ ) {
96 my $value_real1 = (rand(9.0));
97 my $value_imag1 = (rand(9.0));
98 my $value_real2 = (rand(9.0));
99 my $value_imag2 = (rand(9.0));
100 push( @values_real1, $value_real1 );
101 push( @values_imag1, $value_imag1 );
102 push( @values_real2, $value_real2 );
103 push( @values_imag2, $value_imag2 );
104 push( @product_real, ($value_real1 * $value_real2) - ($value_imag1 * $value_imag2));
105 push( @product_imag, ($value_imag1 * $value_real2) + ($value_real1 * $value_imag2));
106 }
107
108
109 print "\n\#define DATA_SIZE ".$opts{"size"}." \n\n";
110 printArray( "input1_data", \@values_real1, \@values_imag1 );
111 printArray( "input2_data", \@values_real2, \@values_imag2 );
112 printArray( "verify_data", \@product_real, \@product_imag );
113
114 }
115
116 main();
117