A
Alex
I apoligise in advance if this is an os or platform based question, I
don't know.
I was wondering how register integers (and other types of register
variables) are managed by c++. For example, on a pentium 4, there are
8 register integers in the cpu. If you define more than 8, or if there
are other programs using this space, how are the variables allocated.
This is for a simulation program that needs to be very fast.
For example:
int foo()
{
register int a;
register int b;
register int c;
register int d;
register int e;
register int f;
register int g;
register int h;
register int i;
//Code using register ints
return 1;
}
There are 9 register integers defined, and, assuming you have only 8 on
your platform, will, after you have defined more than 8, the first one
be put into normal memory or is there some other system for allocating
them.
Also, in for loops, is the counting variable by default a register int.
I have done several tests and the time for a for loop defined like
this:
for( int n = 0; n < 10000; n++ )
{
//Code
}
for( register int n = 0; n < 10000; n++ )
{
//Code
}
is the same.
Thanks
-Alex
don't know.
I was wondering how register integers (and other types of register
variables) are managed by c++. For example, on a pentium 4, there are
8 register integers in the cpu. If you define more than 8, or if there
are other programs using this space, how are the variables allocated.
This is for a simulation program that needs to be very fast.
For example:
int foo()
{
register int a;
register int b;
register int c;
register int d;
register int e;
register int f;
register int g;
register int h;
register int i;
//Code using register ints
return 1;
}
There are 9 register integers defined, and, assuming you have only 8 on
your platform, will, after you have defined more than 8, the first one
be put into normal memory or is there some other system for allocating
them.
Also, in for loops, is the counting variable by default a register int.
I have done several tests and the time for a for loop defined like
this:
for( int n = 0; n < 10000; n++ )
{
//Code
}
for( register int n = 0; n < 10000; n++ )
{
//Code
}
is the same.
Thanks
-Alex