A computer components & hardware forum. HardwareBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » HardwareBanter forum » Processors » Intel
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

AMD "long mode" deficiencies ( Of what use 64-bit "General Purpose" registers?)



 
 
Thread Tools Display Modes
  #11  
Old June 25th 03, 08:11 AM
Nick Maclaren
external usenet poster
 
Posts: n/a
Default


In article ,
(bill davidsen) writes:
| In article ,
| Carlo Razzeto wrote:
|
| | The more I ponder the principles of language design, and the techniques
| | which put them into practice, the more is my amazement and admiration of
| | ALGOL 60. Here is a language so far ahead of its time, that it was not
| | only an improvement on its predecessors, but also on nearly all its
| | successors.
| | -- C.A.R. Hoare, "Hints on Programming Language Design", 1974
|
| Having done large (20k lines of code or more) projects in Ada and PL/I,
| I'll take PL/I thanks. I agree with Hoare on Algol-60, my first language
| after FORTRAN-II.

As with many of Hoare's aphorisms, it is blatantly false as stated
but true in essence. I have used only a few languages to write
new code of that size, but have a good dozen to write thousands of
lines (often as part of hundreds of thousand line projects). And
those languages include Algol 60, Fortran II and Algol 68!

Algol 60 was, indeed, way ahead of its time in many respects, and
IN THOSE RESPECTS his statement is true. But it was seriously
behind them in others, so much so that it was immensely painful for
even describing many of the classes of algorithm for which it was
intended. A prime example of that is the complete lack of any
matrix slicing facilities, which means that many linear algebra
algorithms are clearer in Fortran II than in Algol 60.

Pascal, of course, followed a similar path, which was why it never
made any serious inroads into the Fortran community, despite being
propagandised to hell and back again.


Regards,
Nick Maclaren.
  #12  
Old June 25th 03, 05:31 PM
Brian Hurt
external usenet poster
 
Posts: n/a
Default

Eric Smith wrote in message ...
(Brian Hurt) writes:
The solution (to this problem) is automatic bounds checking on array
accesses.


OK. Here's some C code that is a simplified version of real code I've
seen in an application that runs on Linux. The actual code was considerably
more complicated, having more arguments and doing various calculations in
each function, but I've shown the part that's problematic. It can be
argued that the code is simply poorly written, however that was less
obvious in the original version than in this simplified version. Anyhow,
the point of proposing protection mechanisms is that they should catch
cases where the code is poorly written.


In one source file:

void foo (char *s)
{
char s2 [40];
bar (s2, s);
}


In another source file:

void bar (char *a, char *b)
{
sprintf (a, "bar: %s\n", b);
}


How is the compiler (or linker, or run time system) going to perform
automatic bounds checking to solve this problem?


In C, you basically can't. You need to store the length of the array
in the array itself.

And in this case, you do take a branch. A single branch. A single,
highly predictable, *cheap* branch (remember, it's mispredictions
which are expensive. You only mispredict bounds checking branchs when
you fail the bounds check, at which point you are into error recovery
anyways, and performance is less of a concern).

In many cases, the branch can be eliminated via strength reduction.
Consider the following Java-esque code, as an example:
for (i = 0; i n; ++i) {
a[i] = 0;
}

Obviously initializing the array a. A naive implementation of bounds
checking might look like:
for (i = 0; i n; ++i) {
if (i a.length) then {
a[i] = 0;
} else {
throw BoundsCheckException; /* or whatever */
}
}

Do we need to take a branch every loop? No. We can strength reduce
the above code to instead look like:
limit = min(n, a.length);
for (i = 0; i limit; ++i) {
a[i] = 0; /* always safe */
}
if (n a.length) then
throw BoundsCheckException;
}

Now we're only taking two branchs for the entire loop (one for the
min, one to see if we need to throw an exception). We're doing n
bounds checks with only 2 branchs, meaning we only need 2/n branches
per loop- which approaches zero. Doesn't get there for real code, but
it gets there.

Note that intelligent C code is already paying much of the cost of
strength-reduced bounds checking anyways. Smart C programmers use
strncpy and snprintf instead of strcpy and sprintf for exactly these
reasions- they *insert* by hand the bounds checking.


I still maintain that C and C++ are terrible languages for constructing
large scale software systems.


I agree. They are not the only languages on the planet, however.

Brian
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie: OC Advice: AMDXP2200 CPU Donald Bock Overclocking AMD Processors 2 March 12th 05 01:14 AM
Promise PDC20276 in ATA133 mode: High CPU usage? Will Dormann Gigabyte Motherboards 2 May 18th 04 02:52 AM
Finding a fast matrix printer in graphics mode Andrew Mayo Printers 0 April 15th 04 02:35 PM
only certain Linux distros can use AMD 64 bit processor Daeron General 33 February 11th 04 03:52 PM
Get the Serial Number with Visual Basic Michael Wittmann Storage (alternative) 15 November 15th 03 07:03 PM


All times are GMT +1. The time now is 04:09 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 HardwareBanter.
The comments are property of their posters.