Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.misc Subject: Re: Fortran vs. C for numerical work Message-ID: <4337:Dec422:52:4890@kramden.acf.nyu.edu> Date: 4 Dec 90 22:52:48 GMT References: <1990Nov30.163613.9562@alchemy.chem.utoronto.ca> <26349:Dec404:38:5790@kramden.acf.nyu.edu> <764@ubbpc.UUCP> Organization: IR Lines: 32 In article <764@ubbpc.UUCP> wgh@ubbpc.UUCP (William G. Hutchison) writes: [ vectorizing in Fortran versus C ] > In C, on the other hand, my impression is that the programmer must do his/her > vectorizing "by hand"; that compilers cannot do as much of the work > automatically. The Convex compiler easily recognizes all the standard loop idioms. With -va it treats all formal array parameters as unaliased; I've never had to use any directives other than this. > Would you please post a page or so of a representative sample of your > vectorized C so we can look at the coding techniques? Thanks! There's nothing really special... Here's a slightly interesting example. The compiler knows that x and y are unaliased. neg() is a vectorizable operation. #ifdef VECTOR for (i = 0; i < k; i++) y[i] = neg(x[i + r - k]); for (i = k; i < r; i++) y[i] = x[i - k]; for (i = 0; i < r; i++) x[i] = y[i]; #else for (i = 0; i < k; i++) y[i] = x[i + r - k]; for (i = r - 1; i >= k; i--) x[i] = x[i - k]; for (i = 0; i < k; i++) x[i] = neg(y[i]); #endif In this ANSIfied age I should set up a third version, like the second but based on memmove(); but I doubt that'll be faster than the first on most vector machines. ---Dan Brought to you by Super Global Mega Corp .com