Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!apple!agate!violet.berkeley.edu!jerry From: jerry@violet.berkeley.edu (Jerry Berkman) Newsgroups: comp.lang.fortran Subject: Re: Cray conditional vector merge Message-ID: <1991Mar3.041831.11088@agate.berkeley.edu> Date: 3 Mar 91 04:18:31 GMT References: <1991Feb24.050433.21694@ariel.unm.edu> Sender: usenet@agate.berkeley.edu (USENET Administrator) Organization: University of California, Berkeley Lines: 36 In article <1991Feb24.050433.21694@ariel.unm.edu> john@ghostwheel.unm.edu (John Prentice) writes: >I have a question for the Cray guru's out there. When you execute >a conditional vector merge in Cray Fortran, what is really happening? >For example, consider: > > a=cvmgp(f(x),g(x),h(x)) > > ... >John K. Prentice john@unmfys.unm.edu (Internet) >Dept. of Physics and Astronomy, University of New Mexico, Albuquerque, NM, USA >Computational Physics Group, Amparo Corporation, Albuquerque, NM, USA As others have noted, first all three expressions are computed, then a mask is formed, and then the result is returned (to be stored) depending on the mask. The cvmg* family of functions are all typeless, consider: do i = 1, n x(i) = cvmgt( x(i), i-5, y(i).gt.z ) end do this is almost the same as: do i = 1, n if( y(i).gt.z ) x(i) = i-5 end do except that since cvmgt() is typeless, no type conversion is made when storing i-5 in x(i). In a lot of cases, Cray's CFT77 compiler will compile if()s the same as cvmg*() calls. It's generally better to stay standard and avoid these except when the compiler gets confused and won't vectorize code unless you use them. - Jerry Berkman, U.C. Berkeley