2
array-profile-main.c: program for profiling simple array operations
4
Copyright (C) 2007, 2008, David Harvey
6
This file is part of the zn_poly library (version 0.8).
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.
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.
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/>.
27
#include "zn_poly_internal.h"
31
char* type_str[3] = {"add", "sub", "bfly"};
32
char* speed_str[2] = {"safe", "slim"};
35
void prof_main(int argc, char* argv[])
38
double result, spread;
42
// profile various butterfly loops
43
for (type = 0; type < 3; type++)
44
for (speed = 0; speed < 2; speed++)
50
result = profile(&spread, NULL, profile_bfly, arg, 1.0) / 1000;
52
printf(" %4s %s, cycles/coeff = %6.2lf (%.1lf%%)\n",
53
type_str[type], speed_str[speed], result, 100 * spread);
56
// profile mpn_add_n and mpn_sub_n
57
for (type = 0; type < 2; type++)
62
result = profile(&spread, NULL, profile_mpn_aors, arg, 1.0) / 1000;
64
printf(" mpn_%s_n, cycles/limb = %6.2lf (%.1lf%%)\n",
65
type_str[type], result, 100 * spread);
68
// profile zn_array_scalar_mul
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);
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);
84
// profile zn_array_scalar_mul with REDC
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);
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);
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);
110
// end of file ****************************************************************