~ubuntu-branches/ubuntu/wily/libzn-poly/wily

« back to all changes in this revision

Viewing changes to array-profile-main.c

  • Committer: Bazaar Package Importer
  • Author(s): Tim Abbott
  • Date: 2008-05-27 20:23:43 UTC
  • Revision ID: james.westby@ubuntu.com-20080527202343-ufcb3fwj2as0edoz
Tags: upstream-0.8
ImportĀ upstreamĀ versionĀ 0.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   array-profile-main.c:  program for profiling simple array operations
 
3
   
 
4
   Copyright (C) 2007, 2008, David Harvey
 
5
   
 
6
   This file is part of the zn_poly library (version 0.8).
 
7
   
 
8
   This program is free software: you can redistribute it and/or modify
 
9
   it under the terms of the GNU General Public License as published by
 
10
   the Free Software Foundation, either version 2 of the License, or
 
11
   (at your option) version 3 of the License.
 
12
 
 
13
   This program is distributed in the hope that it will be useful,
 
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
   GNU General Public License for more details.
 
17
 
 
18
   You should have received a copy of the GNU General Public License
 
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 
 
21
*/
 
22
 
 
23
 
 
24
#include <math.h>
 
25
#include "support.h"
 
26
#include "profiler.h"
 
27
#include "zn_poly_internal.h"
 
28
#include "zn_poly.h"
 
29
 
 
30
 
 
31
char* type_str[3] = {"add", "sub", "bfly"};
 
32
char* speed_str[2] = {"safe", "slim"};
 
33
 
 
34
 
 
35
void prof_main(int argc, char* argv[])
 
36
{
 
37
   ulong type, speed;
 
38
   double result, spread;
 
39
   
 
40
   printf("\n");
 
41
 
 
42
   // profile various butterfly loops
 
43
   for (type = 0; type < 3; type++)
 
44
   for (speed = 0; speed < 2; speed++)
 
45
   {
 
46
      ulong arg[2];
 
47
      arg[0] = type;
 
48
      arg[1] = speed;
 
49
      
 
50
      result = profile(&spread, NULL, profile_bfly, arg, 1.0) / 1000;
 
51
      
 
52
      printf(" %4s %s, cycles/coeff = %6.2lf (%.1lf%%)\n",
 
53
             type_str[type], speed_str[speed], result, 100 * spread);
 
54
   }
 
55
   
 
56
   // profile mpn_add_n and mpn_sub_n
 
57
   for (type = 0; type < 2; type++)
 
58
   {
 
59
      ulong arg[1];
 
60
      arg[0] = type;
 
61
 
 
62
      result = profile(&spread, NULL, profile_mpn_aors, arg, 1.0) / 1000;
 
63
   
 
64
      printf(" mpn_%s_n, cycles/limb  = %6.2lf (%.1lf%%)\n",
 
65
             type_str[type], result, 100 * spread);
 
66
   }
 
67
 
 
68
   // profile zn_array_scalar_mul
 
69
   {
 
70
      ulong arg[2];
 
71
      arg[1] = 0;
 
72
   
 
73
      arg[0] = ULONG_BITS - 1;
 
74
      result = profile(&spread, NULL, profile_scalar_mul, arg, 1.0) / 1000;
 
75
      printf("scalar_mul (> half-word), cycles/coeff = %6.2lf (%.1lf%%)\n",
 
76
             result, 100 * spread);
 
77
 
 
78
      arg[0] = ULONG_BITS/2 - 1;
 
79
      result = profile(&spread, NULL, profile_scalar_mul, arg, 1.0) / 1000;
 
80
      printf("scalar_mul (< half-word), cycles/coeff = %6.2lf (%.1lf%%)\n",
 
81
             result, 100 * spread);
 
82
   }
 
83
 
 
84
   // profile zn_array_scalar_mul with REDC
 
85
   {
 
86
      ulong arg[2];
 
87
      arg[1] = 1;
 
88
 
 
89
      arg[0] = ULONG_BITS;
 
90
      result = profile(&spread, NULL, profile_scalar_mul, arg, 1.0) / 1000;
 
91
      printf("scalar_mul (> half-word, non-slim, REDC), "
 
92
             "cycles/coeff = %6.2lf (%.1lf%%)\n",
 
93
             result, 100 * spread);
 
94
 
 
95
      arg[0] = ULONG_BITS - 1;
 
96
      result = profile(&spread, NULL, profile_scalar_mul, arg, 1.0) / 1000;
 
97
      printf("scalar_mul (> half-word, REDC), "
 
98
             "cycles/coeff = %6.2lf (%.1lf%%)\n",
 
99
             result, 100 * spread);
 
100
 
 
101
      arg[0] = ULONG_BITS/2 - 1;
 
102
      result = profile(&spread, NULL, profile_scalar_mul, arg, 1.0) / 1000;
 
103
      printf("scalar_mul (< half-word, REDC), "
 
104
             "cycles/coeff = %6.2lf (%.1lf%%)\n",
 
105
             result, 100 * spread);
 
106
   }
 
107
}
 
108
 
 
109
 
 
110
// end of file ****************************************************************