[Beowulf] Re: A start in Parallel Programming?

David Mathog mathog at caltech.edu
Tue Mar 13 17:07:39 PDT 2007

> Jim Lux <James.P.Lux at jpl.nasa.gov> wrote
> it's easy to write without GOTOs in FORTRAN...
>          IF (0) 902,902,902

Spaghetti code goto was evil, but I miss computed goto.  So long as
one was careful to exit every section with a goto to the same
exit point it was well structured and it was fast, even when there
were many destinations.  Sure, in C you can do "the same thing" with a
switch/case construct, but you have to trust that the compiler
will recognize that the cases are 1,2,3,...N and optimize
with a look up table accordingly.  I checked only once, about 15
years ago, and the resultant code was doing the equivalent of this:

  else if(i==2){}

Hopefully things have improved since then. It is possible to force a 
sort of computed goto in C (transfer control staying
within a function) but it involves pre-storing addresses of labels in
an array and then transferring control via a pointer retrieved
via an index into that array.  It's too hideous to contemplate,
but if you must, look for "Audric" in this link:


Does any C compiler offer something like this:

  switch (i){
    case 1:
    case 2:


David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech

More information about the Beowulf mailing list