Slashdot Mirror


Goto Leads to Faster Code

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?

15 of 462 comments (clear)

  1. 30%+ Improvement by bateleur · · Score: 1, Insightful

    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

    Which is certainly good, but to me says more about the previous implementation than it does about Goto's work.

    1. Re:30%+ Improvement by Surt · · Score: 5, Insightful

      Considering the number of scientists who have been looking at this over a number of years, I think it really is a credit to Goto's work. Optimizing at this level is very challenging work on modern processors.

      --
      "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
    2. Re:30%+ Improvement by roystgnr · · Score: 4, Insightful

      Which is certainly good, but to me says more about the previous implementation than it does about Goto's work.

      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...)

  2. Re:Psssh. by XXIstCenturyBoy · · Score: 2, Insightful

    I like to see people replying to a post after reading the name subject line and then express an opinion that 1) Everyone knows and no one would argue with and 2) Has pretty much nothing to do with the article beside a easy pun.

  3. Re:This was a test, aimed at slashdot readers... by Virak · · Score: 2, Insightful

    I think you mean the summary. Anyone who read more than a few words into it would've realized they're talking about a person.

  4. Re:goto is obsolete by ciroknight · · Score: 2, Insightful

    Point taken, but in the early days goto still made a lot of sense, but a lot of conventional, old practices have gone the wayside with compilers that are smarter and better optimizing, and with better standardization in languages overall.

    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 using functions is simply another way of getting around labeling a routine.

    --
    "Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is." G.W.Bush
  5. Its better if you have a f***ing clue by everphilski · · Score: 1, Insightful

    And people who "meticulously hand optomize" their code annoy the crap out of me. Run it, tweak it, run it again. Was the second run faster? Then tweak some more.

    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-

  6. Re:If true... by ciroknight · · Score: 2, Insightful

    The thing is, "Goto" isn't logical.

    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 anymore. It should be a pre-req to learning higher level languages.

    --
    "Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is." G.W.Bush
  7. Re:GOTO Considered Harmful since at least 1968 by mrsbrisby · · Score: 1, Insightful
    Agreed. GOTO is excellent for exception handling. People are often taught to do blocks like this:
    done = 0;
    for (i = 0; i < 100; i++) {
      for (j = 0; j < 100; j++) {
        if (sc[i][j] == ch) {
          done = 1;
          break;
        }
      }
      if (done) {
        break;
      }
    }
    Goto simply makes it more readable:
    for (i = 0; i < 100; i++) {
      for (j = 0; j < 100; j++) {
        if (sc[i][j] == ch) goto DONE;
      }
    }
    goto FAIL;
    DONE:
    ...
    FAIL:
    ...
    ... and lo, compilers will often produce better code with this construct. So you get more readable, faster code.

    In general, I find it easy to follow as long as gotos always go the same direction (down)- and that we only have one or two labels in a function- we're fine.

    Although, also in general, people who use gotos going up, or have more than two labels in their functions, or that otherwise avoid goto like it's some sort of plague tend to have other problems.

  8. Re:I failed a coding test because of this guy by CastrTroy · · Score: 4, Insightful

    Obviously this prof was wrong. If he wanted you to code it in as few lines as possible, then he should have expected everyone's code to be completely unreadable, goto's or not. If he wanted your code to be understandable, then he should have asked to make the code as clear as possible, by using as many lines as you may need.

    --

    Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
  9. Well Done Slashdotters by Linker3000 · · Score: 4, Insightful

    We have given birth to a new acronym: RPFH Read Past the F**king Headline.

    --
    AT&ROFLMAO
  10. Libgoto is fast but not open-source by poszi · · Score: 4, Insightful
    Maybe I should not complain because the guy did a great job and his library is available free of charge but I hesitate to use this library because it is closed-source. I benchmarked it and found it fast and started to use it in my scientific codes. I once found a strange problem in a parallel code I was developing. The program crashed for one specific system I was calculating. It was something weird because it worked for many other systems I tested before. I spent a lot of time trying to find the bug in my program when finally I replaced libgoto with standard blas and the problem disapeared. I knew that the crash was when entering blas but I thought it is because I messed with the arrays that are used as parameters. If libgoto were open-source, I would be able to have a version with debugging info compiled and debug the program and the library. I would probably not fix the bug but I would likely figure out more quickly the problem is in the library and not in my code. After I had known the problem is in libgoto, I dowloaded a new version of libgoto and it worked so the bug has been fixed. There is no changelog on libgoto web page so I don't know what was the problem and how it affacted my previous caclulations.

    Atlas is open-source and is a pretty good alternative. It is only a few percent slower than libgoto in most cases.

    --

    Save the bandwidth. Don't use sigs!

  11. Re:I failed a coding test because of this guy by Smidge204 · · Score: 2, Insightful

    You do realise that GOTO command translated to a JMP isntruction, which any compiler produces in abundance anyway, right?

    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=

  12. Read The Freaking BLURB! by Anonymous Coward · · Score: 1, Insightful

    Speaking of compiler optimizations, if simply replacing control structures with goto made the function 30% faster, then either the compiler truly sucks, or the previous implementation was something horrible.

    I don't mean to pick on you in particular, since half of the comments in this article are equally retarded, but what the hell? I know Slashdot's "early posts get modded up more" system discourages Reading The Fine Article, but are there really this many people who can't spare enough time to read the front page blurb before commenting?

    Goto BLAS is not a BLAS implementation which replaces control structures with goto statements - Goto BLAS is a BLAS implementation written by a man named Kazushige Goto! Just in case anyone didn't catch that, Hemos even points it out again with "Ever get the feeling someone wrote an article merely for the pun?"

    There's still at least ten Slashdot users here who actually understand the subject of conversation. If you're not one of them, would you please just read their comments, try to catch up, and stay silent until you're sure you aren't the "noise" in "signal to noise ratio"?

  13. Re:Computed goto by ChadN · · Score: 3, Insightful

    Yuck! For this example, it'd be much clearer (to me), to simply initialize a function pointer to either foo or bar, and call that in a loop. I'd imagine it is just as fast. Jumping into loops can be clever, but is seriously non-intuitive, IMO.

    --
    "It's overkill, of course. But you can never have too much overkill." - Anonymous Slashdot Coward