Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!samsung!caen!news.cs.indiana.edu!ariel.unm.edu!triton.unm.edu!prentice From: prentice@triton.unm.edu (John Prentice) Newsgroups: comp.lang.fortran Subject: vectorization question reposed Message-ID: <1991Mar30.142903.5225@ariel.unm.edu> Date: 30 Mar 91 14:29:03 GMT Organization: University of New Mexico, Albuquerque Lines: 54 Originator: prentice@triton.unm.edu My thanks to those people who responsed to my query about how to collapse a three tier array into one. Unforunately, none of the responses were quite what I needed (I neglected to specify the constraints: 1) Fortran 77, 2) clean, 3) portable, 4) must calculate i,j,k, and 5) vectorizeable). The most serious of my ommissions was to neglect to say that I need the i,j,k indices. A solution I came up with that is vectorizeable is: program test parameter (imax=100,jmax=150,kmax=200) dimension a(imax,jmax,kmax) do 10 n=1,imax*jmax*kmax i=mod(n,imax) if(i.eq.0) i=imax j=n/imax+1 if(j*imax.gt.n) j=j-1 k=n/(imax*jmax)+1 if(k*imax*jmax.gt.n) k=k-1 a(i,j,k)= some function of i,j,k 10 continue end I would now appreciate it if people would tell me any pitfalls they see to this. In particular, is the compiler (cft77 4.0.2 is what I am using on a YMP) smart enough to realize that my stride is 1 here and therefore not do a gather/scatter operation when it is not necessary? One other question. What is the size of the memory banks on the YMP and hence what strides should you avoid? Also, suppose you have the following code: subroutine ralph (a,b,c,indx) dimension a(100),b(100),c(100),indx(100) do 10 n=1,100 a(n)=b(indx(n))*c(indx(n)) 10 continue end where indx(n) maps into 1 to 100. To vectorize this, the system has to do a gather/scatter. If indx(i) and indx(i+1) happen to point to locations in the same memory bank, will the system do anything to reorder the references or will this indeed cause a bank conflict? What about cache? Does the YMP have a cache and if so, what rules are there for maximizing performance with it? Many thanks. John -- 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