Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!udel!nigel.ee.udel.edu!mccalpin From: mccalpin@perelandra.cms.udel.edu (John D. McCalpin) Newsgroups: comp.lang.fortran Subject: Re: vectorization question reposed Message-ID: Date: 30 Mar 91 15:43:19 GMT References: <1991Mar30.142903.5225@ariel.unm.edu> Sender: usenet@ee.udel.edu Organization: College of Marine Studies, U. Del. Lines: 54 Nntp-Posting-Host: perelandra.cms.udel.edu In-reply-to: prentice@triton.unm.edu's message of 30 Mar 91 14:29:03 GMT >>>>> On 30 Mar 91 14:29:03 GMT, prentice@triton.unm.edu (John Prentice) said: John> My thanks to those people who responsed to my query about how to John> collapse a three tier array into one. Unforunately, none of the John> responses were quite what I needed (I neglected to specify the John> constraints: 1) Fortran 77, 2) clean, 3) portable, 4) must John> calculate i,j,k, and 5) vectorizeable). The most serious of my John> ommissions was to neglect to say that I need the i,j,k indices. John> A solution I came up with that is vectorizeable is: [omitted] Unless memory is very tight, the following solution is likely to be *much* faster: subroutine foobar real a(imax,jmax,kmax) real xi(imax,jmax,kmax),xj(imax,jmax,kmax),xk(imax,jmax,kmax) logical first save xi,xj,xk,first data first /.true./ * initialize once if (first) then do k=1,kmax do j=1,jmax do xi=1,imax xi(i,j,k) = float(i) xj(i,j,k) = float(j) xk(i,j,k) = float(k) end do end do end do first = .false. endif * now do work (presumably many times?) do k=1,kmax do j=1,jmax do i=1,imax a(i,j,k) = xi(i,j,k) + etc.... end do end do end do etc...... John> One other question. What is the size of the memory banks on the John> YMP and hence what strides should you avoid? The number of banks depends on the machine configuration. Avoid powers of 2 in your strides. 2 and 4 are probably OK, but higher powers of 2 will likely cause performance penalties. -- John D. McCalpin mccalpin@perelandra.cms.udel.edu Assistant Professor mccalpin@brahms.udel.edu College of Marine Studies, U. Del. J.MCCALPIN/OMNET