Goto Leads to Faster Code 462
pdoubleya writes "There's an article over at the NY Times (registration required) about Kazushige Goto, the author of the Goto Basic Linear Algebra Subroutines (BLAS, see the wiki); his BLAS implementation is used by 4 of the current 11 fastest computers in the world. Goto is known for painstaking effort in hand-optimizing his routines; in one case, "when computer scientists at the University at Buffalo added Goto BLAS to their Pentium-based supercomputer, the calculating power of the system jumped from 1.5 trillion to 2 trillion mathematical operations per second out of a theoretical limit of 3 trillion." To quote Jack Dongarra, from the University of Tennessee, "I tell them that if they want the fastest they should still turn to Mr. Goto."" Ever get the feeling someone wrote an article merely for the pun?
This certainly is news to me. (Score:5, Funny)
Re:This certainly is news to me. (Score:2, Funny)
Re:This certainly is news to me. (Score:3, Interesting)
Throwing bricks in glasshouses, anyone? (Score:5, Funny)
Ever get the feeling someone wrote an article merely for the pun?
Good thing the headline didn't contribute to that at all.
No-registration-required version at CNET (Score:4, Informative)
Now, wait for the next (worst) pun (Score:4, Funny)
Italian.
Pasta.
Specially Spaghetti.
[/me ducks and runs away....]
His code is more stable than Mr. Bluescreen's (Score:5, Funny)
Re:His code is more stable than Mr. Bluescreen's (Score:3, Funny)
(Wow. I'm suddenly getting flashbacks from my BASIC days...)
I failed a coding test because of this guy (Score:5, Funny)
I had the shortest working code in the class but the arse hole teacher failed me for it. Said something like "we don't teach goto for a reason. Yeah, it's in the book, but don't ever use it!"
Jerk. I should post his phone number on slashdot
Re:I failed a coding test because of this guy (Score:2, Redundant)
While I can understand why structrured programming was introduced, I still think it is sort of funny to use like a dozen syntactical constructions, that all can have their own quirks, for flow control, while all those things are do
Re:I failed a coding test because of this guy (Score:5, Insightful)
Re:I failed a coding test because of this guy (Score:3, Informative)
And then there was the famous "'GOTO Considered Harmful' Considered Harmful" by Frank Rubin, and a a decent section in Steve McConnell's Code Complete [stevemcconnell.com] that takes an even-handed view.
Anyway, swingi
And the point is... (Score:2)
The entire point about production code is that it will be used by some else and maintained by someone else. Maintaining code can be much more expensive than initial development. Anything that reduces maintenence costs usually takes precedence over performance, annoyance of the initial programmer(s) and cpu time.
High end customized
Re:I failed a coding test because of this guy (Score:3, Informative)
"Not recommended" and "don't ever use it" are two differenet things. If it was never meant to be used, it wouldn't be in the language. The goal of the test mentioned was to write the shortest possible piece of code, not the most maintainable or most elegant.
Re:I failed a coding test because of this guy (Score:2)
If you don't know who Stroustrap and K&R are, you have no right commenting on C/C++ issues.
I'm sorry, I only know Bjarne Stroustrup... who's that Stroustrap you're talking about ? :-)
And on a more serious note, I think the professor has a valid point... his job is to teach someone C++, and well, like Stroustrup says, goto should only be used in rare cases. At the point that someone reaches this point where he has to perform these kind of optimizations, one can say that he mastered the language eno
Re:I failed a coding test because of this guy (Score:3, Insightful)
There is no performance issue at all. The ONLY reason 'goto' could be considered bad is that it becomes easy to write code that is difficult for humans to follow.
=Smidge=
GOTOs sometimes make the code *more* readable (Score:5, Interesting)
I like everyone else was trained *never* to use the dreaded goto statement. I'll grant that Pascal was more readable than Basic (with unlabeled gotos).
But, sometimes, it is actually better to use a goto to make the code more readable. The Linux Kernel, for example, uses gotos. I was pretty sceptical at first because it had been drilled into my head how unreadable code was with gotos in it. But, reading the code, I have to admitt is is much more readable for exception handeling, for example.
If the goto would not make your code more readable then don't use it. But, in the cases where it would avoid a bunch of sillyness trying to get out of a bunch of nested loops in case some error happened, then it makes a lot of sense.
Linus Torvalds (and others) explain the reasoning for this at:
http://kerneltrap.org/node/553 [kerneltrap.org]
In short, there are both readability and efficiency reasons to use gotos.
This was a test, aimed at slashdot readers... (Score:5, Funny)
Judging from the replies...not many people
Re:This was a test, aimed at slashdot readers... (Score:2, Insightful)
Re:This was a test, aimed at slashdot readers... (Score:5, Funny)
The calls for the obligatory "You must be new here".
Re:This was a test, aimed at slashdot readers... (Score:5, Funny)
Wow. Slashdot article as Turing Test.
GOTO considered harmful (Score:3, Funny)
Seriously, though, how does a guy end up with a name like this in computer programming? It sounds made-up! Then again, I've heard some very, very odd names...
Re:GOTO considered harmful (Score:2)
He doesn't happen to be a hovering black sphere, does he?
Standard disclaimer (Score:3, Informative)
* Note: Pronunciation instruction may only apply if you live in the city of Boston. People living in other localities may need to contact the appropriate authorities for further instruction.
That would mean... (Score:5, Funny)
-Loyal
Re:That would mean... (Score:2)
He has also commented that ... (Score:2)
Computed goto (Score:5, Interesting)
Seriously. Computed goto is very useful for low-level
optimizations in things like high-throughput ethernet
drivers and such. It basically eliminates conditional
checks in cases where the condition stays the same
for a particular set of data. So instead of one would have If the second part is executed in a loop, the savings of
not making an IF comparison accumulate fairly quickly.
Re:Computed goto (Score:4, Insightful)
Clearly Harmful (Score:3, Funny)
DEC Math Library (Score:5, Interesting)
Add to that compilers that were producing top-notch machine language for the target architecture (producing images that ran twice as fast as what gcc gave you at best), CPUs that were spanking the rest of the world as far as floating-point performance was concerned, and you can understand why the scientific community has kept using Alphas for so long.
Re:DEC Math Library (Score:2, Interesting)
Thank you very much (Score:3, Funny)
Re:Thank you very much (Score:2)
oh wait...
Mr. Goto is the one you need! (Score:3, Funny)
This Guy (Score:2)
Obviously he's the GoTo Guy.
For added fun. (Score:3, Funny)
First: take an article which revolves around a pun, just like this one, to deliver a message which has a different meaning than the headline would suggest.
Next: Pick a comment-karma threshold. Two or three ought to do it!
Last: Count how many of the people at that level have completely missed the point of the article: specifically, that the "Goto" in the writeup is not a GOTO statement, but rather the name of a programmer named Kazushige Goto; that this particular distinction is supposed to be considered a bit of ironic humor; and, that this is, in fact, the reason that Hemos posted it "from the we're-punny-this-morning dept."
Hours of fun for everyone!
Where does the slashdot effect come from? (Score:5, Interesting)
I wonder where the slashdot effect comes from then?
Re:Where does the slashdot effect come from? (Score:2)
Pah! (Score:3, Informative)
Slashdot 2000 (Score:2, Funny)
^C^C^C^C^C^C^C^C
Another punny name (Score:5, Funny)
"Robert A. van de Geijin, a computer scientist who works with Mr. Goto at the Texas Center,..."
All right, a Japanese programmer named Goto, working with a non-Japanese guy name Geijin. That's too much.
Re:Another punny name (Score:4, Informative)
Justin.
Story redundant? (Score:3, Funny)
(Apologies for errors, as my issues of CS are in storage and I'm doing this from memory.)
for the pun? (yes) (Score:3, Informative)
There's of course the famous Alpher-Bethe-Gamow paper: http://en.wikipedia.org/wiki/Alpher-Bethe-Gamow_p
Well Done Slashdotters (Score:5, Insightful)
Goto considered harmful... (Score:2)
How are they supposed to sell faster chips when he can make code run faster on them?
BLAS is very helpful for Linpack (Score:2)
We use BLAS for most of our Linpack runs, as it is the fastest set of generic libraries for the purpose. And you can ignore the complexity of coding for a P4, when you consider how much fun it is to code for Itanium, and to do it correctly.
Libgoto is fast but not open-source (Score:5, Insightful)
Atlas [sourceforge.net] is open-source and is a pretty good alternative. It is only a few percent slower than libgoto in most cases.
Re:Libgoto is fast but not open-source (Score:5, Informative)
for more technical info, see goto's personal site (Score:3, Informative)
Why bother with this story? (Score:3, Informative)
Re:Psssh. (Score:2, Insightful)
Its better if you have a f***ing clue (Score:2, Insightful)
When we are talking about math routines (I do simulation programming for engineering applications) its much better if you have a f'ing clue about what you are doing than just *tweaking* and seeing if it works better. And when runs take hours, it often isn't even an option.
-everphilski-
Re:Its better if you have a f***ing clue (Score:2)
Re:Psssh. (Score:2)
I'm one of those guys (sometimes). I have a library that has undergone many small performance improvements and is now 2-3 times as fast as when it started. There's even one little run of inline assembler in the most critical part. The code has gone from fairly easy to understand C++ to much less easy to comprehend, so I'd agree that code optimization all the time is not a good thing - it's a tradeoff. People who think there
Re:Psssh. (Score:2)
If I'm working on an embedded processor, I'm going to spend the extra time and money it takes to get everythin
Re:Psssh. (Score:2)
Yea that is horrible. Faster code who needs it.
Get a clue please. We are not talking about a program to print mailing lables! We are talking about math functions.
Gee a whole second? run a Few million datasets through it and you have a real savings.
There is a place for meticulously hand optomize code. Math functions are a prime example of one of th
Holy crap! (Score:2)
*Pours more coffee*
Mods on crack. I tell ya. Can't believe that made it to 5.
Re:goto is obsolete (Score:2)
Re:goto is obsolete (Score:2)
*rimshot!*
Re:goto is obsolete (Score:2, Informative)
- if your function is small enough and your compiler smart enough, it can inline the routine, removing overhead preserving readability
- nobody can say where the time-critical code is without profiling. Most of the (fortran) code I handle spends 80% of the time zeroing arrays. There's not so much to optimize in this procedure, and optimizing the remaining 20% by filling the code with gotos is only a waste of time
- if the algorithm is slow, optimize. If it's still slow,
Re:goto is obsolete (Score:3, Insightful)
The *first* time I learned C, goto was perfectly acceptible (yay K&R original C material).
But really, my point is that a computer doesn't see things in the sense of functions; it sees things in the sense of labels (memory addresses), and in a sense, programming us
Re:goto is obsolete (Score:2)
You can jump from inside the middle of one nested set of loops and/or tests directly into the middle of another set.
(USE WITH CARE!)
Without goto, you have to set a flag and then test that flag multiple times to do the equivalent. What a waste of time!
That's too bad for Mr. Goto (Score:2)
From TFA:
It is in the same sense that Kazushige Goto's business card says simply "high performance computing."
i.e., Goto is the name of the developer, not the name of the coding practice he's using! -- Paul
Re:goto is obsolete (Score:5, Funny)
I believe you are referring to Kazushige's cousin, Mr. Gosub.
Dear Moderators, (Score:2, Flamebait)
Re:So my professors were lying? (Score:2)
Re:So my professors were lying? (Score:5, Funny)
Re:If true... (Score:2)
Re:If true... (Score:3, Insightful)
Your argument against Goto is even less logical. Goto is a conditional jump, where the condition is always true. It's an if (true) { do; }.
Our brains have plenty of Goto's hardcoded into them; "repeat" is typically implemented through in a "goto" fashion, but you'll want to ignore that if you're a modern computer. The correct way is to instead unroll the loop and have no jump instruction at all (if you can get around it).
Sigh. Why don't they teach assembly anymor
Re:If true... (Score:2)
I disagree with the brain statement as well. There are very few neural functions that have no boundary conditions.
Re:If true... (Score:5, Funny)
If wife has headache, GOTO sleep
If boss is on vacation, GOTO strip bar for long lunch
If in-laws are coming over, GOTO work and pretend there is a critical problem that requires your presence all night
If technical conference is in Vegas, GOTO it
loads of examples.
If work is boring, GOTO slashdot to kill an hour or two
Re:If true... (Score:2)
Re:If true... (Score:2)
A goto is like a derailed thought process. It would be like having a disjoint right in the middle of a sentence telling you to go farther along and do some unrelated thing for a minute, then jerking you back to what you were doing in the first place with another goto statement.
Re:If true... (Score:2)
It might be nice in a high level language to do things like switch, if..then..else, but at the core of it, the processor is just doing a comparison followed by a "jump if equal", "jump if not equal", "jump if greater than", etc, and finally just a "jump".
In every case, jump = goto.
The if..then..else/switch statements are just high level abstractions that lead to the very thing you say is a derailed thought process - jumps/gotos.
Of course, I prefer nice struc
Re:If true... (Score:2)
Re:If true... (Score:2)
So, if Goto is so unlogical, how would you implement
int i;
for ( i = 0; i < 10; ++i ) { }
without a goto statement ? I challenge you... :)
Re:If true... (Score:5, Funny)
Re:If true... (Score:2)
Re:If true... (Score:2)
Re:If true... (Score:3, Funny)
That is o
Re:No you idiots - it's not about GOTO statements (Score:3, Interesting)
Re:No you idiots - it's not about GOTO statements (Score:5, Funny)
Re:No you idiots - it's not about GOTO statements (Score:2, Funny)
Is that anything like camel toe?
a well-positioned goto is quite clear (Score:2)
IMHO, a well-positioned goto is more clear than a structural variable. For example, jumping out of a loop inside a loop is quite nice with a goto. There is no such thing as a double break.
Re:30%+ Improvement (Score:5, Insightful)
Re:30%+ Improvement (Score:2, Informative)
My point is simply that in the field of optimisation, all your gains come from succeeding where the last guy failed. This 30% improvement in performance is not the difference between Goto's approach and his nearest competitor, it is the difference between his work and the previous solution used on that particular machine.
It's the statistic I'm criticising - it simply isn't very meaningful.
(I used to do research into hardware optimi
Re:30%+ Improvement (Score:5, Insightful)
Yeah, that previous implementation must have totally sucked. I know all my linear algebra software is written around an assembly language core, hand tuned for each new version of a half dozen processors, and designed from the start to minimize TLB misses instead of just naively trying to fit a dataset into L1 or L2 cache. I don't know why those retards at the universities and national labs were ever using anything else!
(closing Slashdot, going back to working on my shamefully unoptimized C++ numerics code...)
Re:30%+ Improvement (Score:3, Interesting)
Propably because, being scientists first and programmers second, they simply don't have the time neccessary to learn the characteristics of the pr
Re:30%+ Improvement (Score:5, Interesting)
Which only goes to show that you haven't considered the implications of optimization in modern processors. A Pentium 4 can operate above 3 GHz. This means that light can travel no more than 10 centimeters in the duration of one clock pulse. With the spacing in the motherboard, this isn't enough for a pulse to go from the CPU to the RAM and come back. Even if the memory could operate at the same rate as the CPU, the computation would still be limited by light speed alone.
Optimization to get the full advantage of a Pentium 4 doing floating point calculations is one of the most difficult tasks one can do in computing. A P4 can do, in one clock pulse, four multiplications and four additions. To get 100% of this speed one needs to have a sophisticated handling of cache memory, among other requirements.
Re:This caught me off guard! (Score:2)
-b
Re:GOTO Considered Harmful since at least 1968 (Score:2)
Re:GOTO Considered Harmful since at least 1968 (Score:2)
for (i = 0; i < 100; i++) {
for (j = 0; j < 100; j++) {
if (sc[i][j] == ch) goto DONE;
}
}
FAIL:
DONE:
Ok... (Score:3, Funny)
Re:The Fastest Code of All (Score:3, Funny)
The translator apparently had seen the DIR output "Volume in drive A: has no label" and believed that the "label" is referring to a "volume label" and translated it as "volumenaam" ("volume name").
But when a
When I first got this errormessage running a
Perfect example (Score:2)
Please Moderate me -5 "Idiot, RTFA".
Humor is wasted on you (Score:2)
Re:Duh... (Score:3, Informative)
Theoretical FLOPs per processor = Core(s) * Speed_Per_Core (in Ghz) * 2. So for a Dual 3.6 Ghz Xeon, the theoretrical FLOPS is 2 * 3.6 * 2 = 14.4
An easy way to find out actual number of FLOPS a computer can acheive is to ask it to solve a number of Linear Algebra problems and then look at the
Re:Assembler Leads to Even Faster Code (Score:2, Informative)