The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: comp.lang.fortran
From: glen herrmannsfeldt <g...@ugcs.caltech.edu>
Date: Wed, 24 Oct 2012 07:42:40 +0000 (UTC)
Local: Wed, Oct 24 2012 3:42 am
Subject: Re: efficiency of arrays memory allocation of derived type with type-bound procedures
Stefano Zaghi <stefano.za...@gmail.com> wrote:
What do you mean by allocated sequentially?
> I am trying to figure out if the use of type-bound procedures could > compromise the efficiency of memory allocation. > Suppose you have e derived type like the following: > type, public:: Type_Vector_Eff > sequence > real:: x,y,z > end type Type_Vector_Eff > type(Type_Vector_Eff):: vec_eff(1:1000,1:1000) > Because of the presence of "sequence" statement the 2D array > "vec_eff" has its own elements allocated sequentially thus the > loops operations over them are efficient. Without SEQUENCE the compiler is allowed to rearrange structure
In the case of members of different size, it might save padding,
There are cases where there is an efficiency (mostly cache)
(There is a story about a C compiler doing it for a SPEC
> Now suppose you want to modify the above derived type and introduce I would be surprised to see it change.
> some type-bound procedures. In this case the "sequence" > statement is not legal: > type, public:: Type_Vector > real:: x,y,z > contains > procedure:: init > end type Type_Vector > type(Type_Vector):: vec(1:1000,1:1000) > Now how are allocated the elements of "vec"? > Is it possible that its elements are not sequentially allocated The structure is small enough that I would be surprised to
> thus the access to them is not efficient into loops operations? see a difference, but it is possible. > Is it possible that the type-bound procedure "init" makes not Possible, yes, but not likely. But you don't say how you are
> efficient the access to the memory of array "vec"? accessing the array, so it is hard to say more. -- glen
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||