This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fortran inquire statement mask


On Sun, Feb 19, 2006 at 05:29:23PM -0600, Erik Schnetter wrote:
> Does this mask provide any advantages?  Presumably, this structure 

Yes.  The parameter structures are huge (e.g. ATM st_parameter_inquire
is 296 bytes on 64-bit arches, st_parameter_open 168 bytes).
Most of the time only very few fields are actually set.

Before my patch, there was a global structure (even bigger) that
was cleared up after every single call by libgfortran.  bzeroing 300
bytes and filling the required fields per every single IO call is
IMHO far more costly than writing a flag word and filling the
required fields.  Also, on the library side, you don't need
to read many fields from memory to see what has been set,
you just read the flag word and only fetch from memory the fields
that were actually set.

As for inquire, changing the flag field to long int wouldn't help
on 32-bit arches, plus it would be an ABI change.
AFAIK only INQUIRE is going to run out of the bits RSN, OPEN has still
almost half of the bits left and others even more.
The solution for INQUIRE I had in mind was to use one bit in
st_parameter_inquire's common.flag for IOPARM_INQUIRE_HAS_FLAG2 and
add unsigned int flag2; to the end of the struct, which adds another
32-bit flag bits.
So, all code that uses INQUIRE as well as new code that doesn't set
any of the new (F2003) fields would just set common.flag field (without
IOPARM_INQUIRE_HAS_FLAG2 in it) and the fields as usual, new INQUIRE
call that uses them would set the IOPARM_INQUIRE_HAS_FLAG2 bit in
common.flag in addition to the other usual bits and also fill in
flag2 field plus fields that it wants to set.
libgfortran side would do:
  GFC_INTEGER_4 cf = iqp->common.flags, cf2 = 0;

  if ((cf & IOPARM_INQUIRE_HAS_FLAG2) != 0)
    cf2 = iqp->flag2;

and after doing the current cf & IOPARM_INQUIRE_* tests also
have some cf2 & IOPARM_INQUIRE2_* tests.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]