[Beowulf] Re: A start in Parallel Programming?

David Mathog mathog at caltech.edu
Tue Mar 13 20:07:39 EDT 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:

  if(i==1){}
  else if(i==2){}
  etc.

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:

  http://www.allegro.cc/forums/print-thread/589282

Does any C compiler offer something like this:

  #pragma FORCE_LOOKUP_TABLE
  switch (i){
    case 1:
    case 2:
    etc.
  }
?

Regards,

David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech
_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf

!DSPAM:45f73cec256761901610295!



More information about the Beowulf mailing list