JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2000

COMP-FORTRAN-90 2000

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Helping the compiler with INDEPENDENT and ALLOCATABLEs

From:

Aleksandar Donev <[log in to unmask]>

Reply-To:

[log in to unmask]

Date:

Wed, 14 Jun 2000 12:40:43 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (125 lines)

Hello,

I have a few observations/questions about Fortran 95 and in particular
HPF 2.0 concerning array statements with allocatable arrays. Sorry for
the long text, but I think it will be interesting to those using array
features of Fortran.

The array statement I am considering is in a subroutine MULT and has a
very simplified form of:
theta=phi(alpha,:,:)*(phi(beta,:,:)-cshift(phi(beta,:,:),1,1))
where theta and phi are allocatable arrays of (obviously) identical
sizes in the last two dimensions defined in a module that this
subroutine is a part of:
real, dimension(:,:,:), allocatable :: phi
real, dimension(:,:), allocatable :: theta
!hpf$ distribute (block,*,*) :: phi
!hpf$ align (i,j) with phi(i,j,*) :: theta
!hpf$ shadow(0:1,0) :: phi

My HPF compiler (Adaptor 7.0) had problems optimizing the array
assignment (in terms of communication and such) because it complained
about not knowing anything about the global sizes of the allocatables,
i.e. it did not know that somewhere in another subroutine there was a
call:
allocate(phi(N,M,5))
allocate(theta(N,M))

The problem is fixed and very efficient loops are generated if the
arrays are not allocatables:
integer :: N,M
real, dimension(N,M,5) :: phi
real, dimension(N,M) :: theta
(NOTE: N and M should be parameters for the program to run correctly,
say N=M=100).
But this doesn't do me much good since I need allocatable arrays. I am
not sure if this is just Adaptor or general HPF/Fortran 95 behaviour.

I could not figure a way to fix the above problem and help the compiler
figure out that the arrays were globally conformable and it could just
translate the array statement into nested DO's with only shadow
communication and no temporaries. I tried passing the arrays as
arguments (with different dummy names, of course) to the subroutine MULT
and declaring them as:
real, dimension(N,M,5) :: phi_
real, dimension(N,M) :: theta_
but some redundant communication and temporaries were still generated.

I think that according to the HPF 2.0 standard saying:
!hpf$ align (:,:) with psi(:,:) :: theta,phi
instead of:
!hpf$ align (i,j) with psi(i,j) :: theta,phi
should guarantee the compiler that the allocatable arrays have equal
sizes (unfortunately, Adaptor does not allow alignment with : for
allocatables). Am I correct? I am not aware of any such possibility
within Fortran 95, and it seems a useful feature (sort of like
deferred-size arrays, where N and M are not parameters, but just
integers that are assigned values before the routine MULT is called. Is
this an idea that has been looked at? Can pointers maybe help?). Doesn't
the fact that these arrays are used as conformable arrays in an array
statement guarantee this to the compiler?

So I tried another solution. Since all arrays have the same sizes, I put
them in one big array vecs and used my preprocessor to do the
identification (or better use macros):
$macro phi(alpha,range1,range2) vecs(1+alpha,range1,range2)
$define theta vecs(1,:,:)
where vecs is declared as:
real, dimension(:,:,:), allocatable :: vecs
!hpf$ distribute (block,*,*) :: vecs
!hpf$ shadow(1:0,0,0) :: vecs
Althought this is not as stylistically clean, it is a nice solution in
the context of my larger project, since one can use integers
(theta,phi,psi) to identify arrays and only declare a single array vecs,
a convenient feature [NOTE: in the rest of the code, there are other
assignments like this, so that shadows are really needed on both phi and
theta and should be (1:1,0,0)]

Then another problem popped out! Namely, after preprocessing and all,
the final array statement is something like:
vecs(1,:,:)=vecs(1+alpha,:,:)*(vecs(1+beta,:,:)-cshift(vecs(1+beta,:,:),1,1))

and now the same array vecs appears on both sides of the array
statement, so that the compiler generates temporaries and does the
assignment in two steps.
And then it dawned on me that Fortran 95 or HPF do not have a standard
way of letting the compiler know that alpha,beta>0 so that no
temporaries are needed.

Adaptor 7 allows me to add an INDEPENDENT directive to the array
statement:
!hpf$ independent
vecs(1,:,:)=vecs(1+alpha,:,:)*(vecs(1+beta,:,:)-cshift(vecs(1+beta,:,:),1,1))

which fixes the problem and efficient loops are generated.

Why doesn't the HPF 2 standard allow using INDEPENDENTs on array
assignments as well? It seems like a very useful feature, now that I
needed to use it. How about Fortran 95/2000 features in this direction?

I guess some will say that I should simply translate the array
assignment into DO loops my self and stick away from array syntax. This
works, but in that case boundaries have to be handled separately, since
the shadow edges in HPF are not part of the global array, so my DO loops
in global HPF mode can only legally go from 2:N-1 and 2:M-1, not 1:N and
1:M as Adaptor internally translates the above array assignment. Also,
array assignments are nice and easy to work with.

Any comments/ideas would be appreciated,
Aleksandar

--
_____________________________________________
Aleksandar Donev
Physics Department
Michigan State University
East Lansing, MI 48824-1116
E-mail: [log in to unmask]
Work phone: (517) 432-6770
_____________________________________________




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager