Posted by Jan Panteltje on May 15, 2009, 10:34 am
The run time in C is 13 seconds here on a 1GHz processor.
Can you specify your 'old HP computer' ?
I can win maybe 1 second by writing the code a bit different.
And a 3GHz would do it in 12 / 4 = 4 seconds...
A bigger cache would help a bit perhaps.
A Cray would be even better.
What does you C code look like? Mine is in the other posting.
Else you goofed a factor 10.
Seems to me anyways :-)
Posted by langwadt@fonz.dk on May 15, 2009, 11:35 am
> The run time in C is 13 seconds here on a 1GHz processor.
> Can you specify your 'old HP computer' ?
> I can win maybe 1 second by writing the code a bit different.
> And a 3GHz would do it in 12 / 4 = 4 seconds...
> A bigger cache would help a bit perhaps.
> A Cray would be even better.
> What does you C code look like? Mine is in the other posting.
> Else you goofed a factor 10.
> Seems to me anyways :-)
I just tried in Matlab, on a 2GHz core2-duo with 2GB
with 32bit signed ints: ~2.5 second
with 16bit signed ints: ~1.0 second
with 64bit floats: ~4.0 second
-Lasse
Posted by Jan Panteltje on May 15, 2009, 12:04 pm
On a sunny day (Fri, 15 May 2009 08:35:25 -0700 (PDT)) it happened
>> The run time in C is 13 seconds here on a 1GHz processor.
>> Can you specify your 'old HP computer' ?
>>
>> I can win maybe 1 second by writing the code a bit different.
>> And a 3GHz would do it in 12 / 4 = 4 seconds...
>> A bigger cache would help a bit perhaps.
>>
>> A Cray would be even better.
>>
>> What does you C code look like? Mine is in the other posting.
>>
>> Else you goofed a factor 10.
>>
>> Seems to me anyways :-)
>I just tried in Matlab, on a 2GHz core2-duo with 2GB
>with 32bit signed ints: ~2.5 second
>with 16bit signed ints: ~1.0 second
>with 64bit floats: ~4.0 second
>-Lasse
Yes, what I think happens is that those core2 duo execute those intructions
a lot faster then my Celeron or whatever it is, so that would gain an other
200%, so Larkin's '''Old''' HP' must be a 3 GHz core?
Maybe I should upgrade to a more recent processor, but luckely I do not need to
add 64M integers :-)
Posted by Tim Williams on May 15, 2009, 12:04 pm
> The run time in C is 13 seconds here on a 1GHz processor.
> Can you specify your 'old HP computer' ?
> I can win maybe 1 second by writing the code a bit different.
> And a 3GHz would do it in 12 / 4 =3D 4 seconds...
> A bigger cache would help a bit perhaps.
> A Cray would be even better.
> What does you C code look like? Mine is in the other posting.
> Else you goofed a factor 10.
> Seems to me anyways :-)
Typing the following into Open Watcom,
-=3D-=3D-
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#define ARRAY_SIZE 64000000
int main(void) {
short *a; int *s; int i;
int startTime, endTime;
a =3D malloc(ARRAY_SIZE * sizeof(short));
s =3D malloc(ARRAY_SIZE * sizeof(int));
if (a =3D=3D NULL || s =3D=3D NULL) {
printf("Memory allocation failed.\n");
return -1;
}
printf("Starting...\n");
startTime =3D GetTickCount();
for (i =3D 0; i < ARRAY_SIZE; i++) {
s[i] +=3D a[i];
}
endTime =3D GetTickCount();
printf("Total time taken adding %i array entries: %f seconds.\n",
ARRAY_SIZE, ((float)(endTime - startTime)) / 1000);
free(a); free(s);
return 0;
}
-=3D-=3D-
and saving as test.c and compiling, I get the typical output:
-=3D-=3D-
E:\WATCOM\Projects>test
Starting...
Total time taken adding 64000000 array entries: 1.453000 seconds.
E:\WATCOM\Projects>test
Starting...
Total time taken adding 64000000 array entries: 1.546000 seconds.
-=3D-=3D-
My computer is an Athalon 2500 at 1.66GHz, 1.1GB PC133 RAM (currently
472MB free, so no problems allocating the test), running Windows XP
SP2. Basically state-of-the-art way back in the year 2001. If your
computers are taking more than a couple seconds, either your compiler
really sucks or your computers suck even more. :-)
Tim
Posted by Jan Panteltje on May 15, 2009, 12:10 pm
On a sunny day (Fri, 15 May 2009 09:04:43 -0700 (PDT)) it happened Tim
>> The run time in C is 13 seconds here on a 1GHz processor.
>> Can you specify your 'old HP computer' ?
>>
>> I can win maybe 1 second by writing the code a bit different.
>> And a 3GHz would do it in 12 / 4 = 4 seconds...
>> A bigger cache would help a bit perhaps.
>>
>> A Cray would be even better.
>>
>> What does you C code look like? Mine is in the other posting.
>>
>> Else you goofed a factor 10.
>>
>> Seems to me anyways :-)
>Typing the following into Open Watcom,
>-=-=-
>#include <stdio.h>
>#include <stdlib.h>
>#include <windows.h>
>#define ARRAY_SIZE 64000000
>int main(void) {
> short *a; int *s; int i;
> int startTime, endTime;
> a = malloc(ARRAY_SIZE * sizeof(short));
> s = malloc(ARRAY_SIZE * sizeof(int));
> if (a == NULL || s == NULL) {
> printf("Memory allocation failed.\n");
> return -1;
> }
> printf("Starting...\n");
> startTime = GetTickCount();
> for (i = 0; i < ARRAY_SIZE; i++) {
> s[i] += a[i];
> }
> endTime = GetTickCount();
> printf("Total time taken adding %i array entries: %f seconds.\n",
>ARRAY_SIZE, ((float)(endTime - startTime)) / 1000);
> free(a); free(s);
> return 0;
>}
>-=-=-
>and saving as test.c and compiling, I get the typical output:
>-=-=-
>E:\WATCOM\Projects>test
>Starting...
>Total time taken adding 64000000 array entries: 1.453000 seconds.
>E:\WATCOM\Projects>test
>Starting...
>Total time taken adding 64000000 array entries: 1.546000 seconds.
>-=-=-
>My computer is an Athalon 2500 at 1.66GHz, 1.1GB PC133 RAM (currently
>472MB free, so no problems allocating the test), running Windows XP
>SP2. Basically state-of-the-art way back in the year 2001. If your
>computers are taking more than a couple seconds, either your compiler
>really sucks or your computers suck even more. :-)
>Tim
Tim, you forgot that I was running >2 loops< inside each other, as Larkin's
original post mentions:
for(j = 0; j < 10; j++)
{
for(i = 0; i < BIG_SIZE; i++)
{
mem[i] += b[i];
}
}
So multiply your result by 10, and you got 15 seconds, even slower then me
on the eeePC with 512 MB ram and 900 MHz celeron in Linux with gcc-4.0 :-)
Sorry 'bout that ;-)
> Can you specify your 'old HP computer' ?
> I can win maybe 1 second by writing the code a bit different.
> And a 3GHz would do it in 12 / 4 = 4 seconds...
> A bigger cache would help a bit perhaps.
> A Cray would be even better.
> What does you C code look like? Mine is in the other posting.
> Else you goofed a factor 10.
> Seems to me anyways :-)