|
List Info
Thread: First cut not the deepest?
|
|
| First cut not the deepest? |
  Australia |
2007-03-23 01:36:31 |
Does Windows cause brain damage?
Runnng timing comparisons under Windows is always a
trifle dodgy, but the anomaly I am seeing is
particularly baffling.
The test is simple enough. Repeat some non-trivial
operation R times, report the time taken. Do that that
N times.
Using either a static or shared library built for a
Pentium 4 under MinGW, I am consistently getting a
series of times that increase fairly quickly, then
seem to stabilise at just under twice the time taken
for the first set.
For example, here the test program is mpz_mul-ing two
arguments of about 8K limbs, 1000 times a set:
> test -p 8192 -r 1000 -n 10
16:48:38 start test, ops/set = 1000, nreps = 10
16:48:47 time = 8.625000
16:48:58 time = 11.672000
16:49:11 time = 12.734000
16:49:24 time = 13.282000
16:49:38 time = 13.734000
16:49:52 time = 14.109000
16:50:06 time = 14.250000
16:50:21 time = 14.453000
16:50:35 time = 14.500000
16:50:50 time = 14.579000
16:50:50 avg = 13.193800
The test program records the real-time clock as well
as the calculated times, because I had to convince
myself that the calculated times were right!
This same trend is produced, regardless of whether I
hammer mpz_mul, or mpf_div, or mpfr_cos.
Has my obtuseness become acute (so to speak!), or is
there something going on in there?
Cheers
Jim White
ANU, Canberra
-------------------------------------------
> type test.c
#include <stdio.h>
#include <time.h>
#include "gmp_static.h"
mpz_t X1, X2, Y;
int TSTART, TNOW;
double GetClock() {return ((double)(TNOW -
TSTART)/1000.0);}
char timenow[32];
char *dclock() { // time-of-day ("hh:mm:ss")
time_t etime; time(&etime);
char *tnow = (char *) ctime(&etime);
strncpy (timenow, tnow, 20);
timenow[20] = 0;
return (&timenow[11]);
}
//----------------------
int main (int argc, char *argv[]) {
int i, p;
int k = 1;
int r = 1000;
int nreps = 1;
while (k < argc) {
if (strcmp(argv[k],"-p") == 0) { k++;
p =
atoi(argv[k]); }
if (strcmp(argv[k],"-r") == 0) { k++;
r =
atoi(argv[k]); }
if (strcmp(argv[k],"-n") == 0) { k++;
nreps =
atoi(argv[k]); }
k++;
}
mpz_init2 (X1, 32*p);
mpz_init2 (X2, 32*p);
mpz_init2 (Y, 32*p);
double xtime, rtime;
// Set test operands
mpz_set_ui (X1, 3); mpz_set_ui (X2, 3);
while (X1->_mp_size < (p/2)) {
mpz_add_ui (X2, X2, 2);
mpz_mul (X1, X1, X2);
}
mpz_mul (X2, X1, X1);
mpz_add_ui (X1, X1, 1);
// Timing tests
rtime = 0.0;
printf ("%s start test, ops/set = %d, nreps =
%dn", dclock(), r, nreps);
for (k = 0; k < nreps; k++) {
TSTART = clock();
for (i=0; i < r; i++) mpz_mul (Y, X1, X2);
TNOW = clock();
xtime = GetClock();
rtime += xtime;
printf ("%s time = %fn", dclock(),
xtime);
}
rtime /= nreps;
printf ("%s avg = %fn", dclock(), rtime);
}
_______________________________________________
gmp-discuss mailing list
gmp-discuss swox.com
http://s
wox.com/mailman/listinfo/gmp-discuss
|
|
| Re: First cut not the deepest? |
  Australia |
2007-03-23 02:54:22 |
----- Original Message -----
From: "Jim White" <mathimagics yahoo.co.uk>
To: <gmp-discuss swox.com>
Sent: Friday, March 23, 2007 5:36 PM
Subject: First cut not the deepest?
>
> Does Windows cause brain damage?
>
> Runnng timing comparisons under Windows is always a
> trifle dodgy, but the anomaly I am seeing is
> particularly baffling.
>
> The test is simple enough. Repeat some non-trivial
> operation R times, report the time taken. Do that that
> N times.
>
> Using either a static or shared library built for a
> Pentium 4 under MinGW, I am consistently getting a
> series of times that increase fairly quickly, then
> seem to stabilise at just under twice the time taken
> for the first set.
>
> For example, here the test program is mpz_mul-ing two
> arguments of about 8K limbs, 1000 times a set:
>
>> test -p 8192 -r 1000 -n 10
> 16:48:38 start test, ops/set = 1000, nreps = 10
> 16:48:47 time = 8.625000
> 16:48:58 time = 11.672000
> 16:49:11 time = 12.734000
> 16:49:24 time = 13.282000
> 16:49:38 time = 13.734000
> 16:49:52 time = 14.109000
> 16:50:06 time = 14.250000
> 16:50:21 time = 14.453000
> 16:50:35 time = 14.500000
> 16:50:50 time = 14.579000
> 16:50:50 avg = 13.193800
>
For the script you posted - using a static build of GMP on
an AMD 64 box
with Vista64 (but using a MinGW-built 32-bit GMP-4.2.1) I
get sane results:
C:_32C>bench_gmp -p 8192 -r 1000 -n 10
18:39:34 start test, ops/set = 1000, nreps = 10
18:39:38 time = 4.548000
18:39:43 time = 4.519000
18:39:48 time = 4.545000
18:39:52 time = 4.510000
18:39:57 time = 4.517000
18:40:01 time = 4.511000
18:40:06 time = 4.513000
18:40:10 time = 4.510000
18:40:15 time = 4.511000
18:40:19 time = 4.507000
18:40:19 avg = 4.519100
On a Win32 box (Windows 2000, P-III, ~1GHz), again with a
static MinGW build
of GMP-4.2.1, I still get sane results. (Only difference is
that the time
blows out to ~13.9 seconds.)
Unfortunately, I don't have a P-IV box with Windows.
Cheers,
Rob
_______________________________________________
gmp-discuss mailing list
gmp-discuss swox.com
http://s
wox.com/mailman/listinfo/gmp-discuss
|
|
| Re: First cut not the deepest? |
  United Kingdom |
2007-03-23 03:57:46 |
----- Original Message -----
From: "Jim White" <mathimagics yahoo.co.uk>
To: <gmp-discuss swox.com>
Sent: Friday, March 23, 2007 6:36 AM
Subject: First cut not the deepest?
>
> Does Windows cause brain damage?
>
> Runnng timing comparisons under Windows is always a
> trifle dodgy, but the anomaly I am seeing is
> particularly baffling.
>
> The test is simple enough. Repeat some non-trivial
> operation R times, report the time taken. Do that that
> N times.
>
> Using either a static or shared library built for a
> Pentium 4 under MinGW, I am consistently getting a
> series of times that increase fairly quickly, then
> seem to stabilise at just under twice the time taken
> for the first set.
>
> For example, here the test program is mpz_mul-ing two
> arguments of about 8K limbs, 1000 times a set:
>
>> test -p 8192 -r 1000 -n 10
> 16:48:38 start test, ops/set = 1000, nreps = 10
> 16:48:47 time = 8.625000
> 16:48:58 time = 11.672000
> 16:49:11 time = 12.734000
> 16:49:24 time = 13.282000
> 16:49:38 time = 13.734000
> 16:49:52 time = 14.109000
> 16:50:06 time = 14.250000
> 16:50:21 time = 14.453000
> 16:50:35 time = 14.500000
> 16:50:50 time = 14.579000
> 16:50:50 avg = 13.193800
>
> The test program records the real-time clock as well
> as the calculated times, because I had to convince
> myself that the calculated times were right!
>
> This same trend is produced, regardless of whether I
> hammer mpz_mul, or mpf_div, or mpfr_cos.
>
> Has my obtuseness become acute (so to speak!), or is
> there something going on in there?
>
> Cheers
> Jim White
> ANU, Canberra
>
> -------------------------------------------
>> type test.c
>
> #include <stdio.h>
> #include <time.h>
> #include "gmp_static.h"
>
> mpz_t X1, X2, Y;
> int TSTART, TNOW;
>
> double GetClock() {return ((double)(TNOW -
> TSTART)/1000.0);}
> char timenow[32];
> char *dclock() { // time-of-day
("hh:mm:ss")
> time_t etime; time(&etime);
> char *tnow = (char *) ctime(&etime);
> strncpy (timenow, tnow, 20);
> timenow[20] = 0;
> return (&timenow[11]);
> }
> //----------------------
>
> int main (int argc, char *argv[]) {
> int i, p;
> int k = 1;
> int r = 1000;
> int nreps = 1;
>
> while (k < argc) {
> if (strcmp(argv[k],"-p") == 0) { k++;
p =
> atoi(argv[k]); }
> if (strcmp(argv[k],"-r") == 0) { k++;
r =
> atoi(argv[k]); }
> if (strcmp(argv[k],"-n") == 0) { k++;
nreps =
> atoi(argv[k]); }
> k++;
> }
> mpz_init2 (X1, 32*p);
> mpz_init2 (X2, 32*p);
> mpz_init2 (Y, 32*p);
>
> double xtime, rtime;
>
> // Set test operands
>
> mpz_set_ui (X1, 3); mpz_set_ui (X2, 3);
> while (X1->_mp_size < (p/2)) {
> mpz_add_ui (X2, X2, 2);
> mpz_mul (X1, X1, X2);
> }
> mpz_mul (X2, X1, X1);
> mpz_add_ui (X1, X1, 1);
>
> // Timing tests
> rtime = 0.0;
> printf ("%s start test, ops/set = %d, nreps =
> %dn", dclock(), r, nreps);
> for (k = 0; k < nreps; k++) {
> TSTART = clock();
> for (i=0; i < r; i++) mpz_mul (Y, X1, X2);
> TNOW = clock();
> xtime = GetClock();
> rtime += xtime;
> printf ("%s time = %fn", dclock(),
xtime);
> }
> rtime /= nreps;
> printf ("%s avg = %fn", dclock(),
rtime);
> }
I get consistent results on a 1.8GHz P4 machine running a
Microsoft compiled
32-bit version of GMP:
test -p 8192 -r 1000 -n 10
08:48:54 start test, ops/set = 1000, nreps = 10
08:49:06 time = 11.306000
08:49:17 time = 11.136000
08:49:28 time = 11.086000
08:49:39 time = 11.076000
08:49:50 time = 11.056000
08:50:01 time = 11.086000
08:50:12 time = 11.076000
08:50:23 time = 11.055000
08:50:34 time = 11.066000
08:50:46 time = 11.066000
08:50:46 avg = 11.100900
Brian Gladman
_______________________________________________
gmp-discuss mailing list
gmp-discuss swox.com
http://s
wox.com/mailman/listinfo/gmp-discuss
|
|
| Re: First cut not the deepest? |
  Germany |
2007-03-23 08:38:23 |
On Fri, 23 Mar 2007, Jim White wrote:
> Using either a static or shared library built for a
> Pentium 4 under MinGW, I am consistently getting a
> series of times that increase fairly quickly, then
> seem to stabilise at just under twice the time taken
> for the first set.
>
Pentium IV? Probably a thermal problem, where the processor
is throttled
to prevent overheating. Check the processor and case fans;
one of them
might be stuck.
Holger
_______________________________________________
gmp-discuss mailing list
gmp-discuss swox.com
http://s
wox.com/mailman/listinfo/gmp-discuss
|
|
[1-4]
|
|