[PATCH] Cray Pointers

Asher Langton langton2@llnl.gov
Fri Jul 29 22:25:00 GMT 2005


Hi,

Here is a beta of the Cray pointer patch.

Some notes:

1) The flags are -fcray-pointer and -fbyte-type.  fbyte-type is added 
for compatibility with old LRLTRAN code.  It enables a BYTE type that 
is equivalent to INTEGER(1).

2) The main things added are cray_pointee and cray_pointer bits to 
the symbol_attribute, a pointer from pointee symbols to pointer 
symbols, code to parse pointer statements, code to translate pointee 
expressions and the loc intrinsic code.  (The cray_pointer bit so far 
has proved unnecessary, but I've left it in for now.)  The pointee 
translation is done entirely in the front end; that is, the pointees 
disappear by the time the code is translated into GENERIC.

3) The attributes of pointees are not thoroughly checked.  This won't 
be hard to add, but I need to figure out which attributes might be in 
conflict.  So far, I've been mostly concerned with compiling our 
existing (valid) code.

4)  The implementation allows a user to explicitly declare the type 
and kind of a pointer.  For example:

	integer ipt
	pointer (ipt, pointee)

However, this code isn't portable.  It is safer to omit the 'integer 
ipt' line and let the pointer statement declare ipt to have 
kind=gfc_index_integer_kind.  On Itaniums and Opterons, where 
sizeof(int) != sizeof(void *), this code requires -fdefault-integer-8 
to run correctly.  We could force the kind of the pointer to match 
the hardware pointer size, but for now I leave that up to the user.

5) I don't yet have any tests included in the patch.  I'll try to 
figure out the dejagnu framework today.  We have a nice Cray pointer 
testsuite here at LLNL, but I can't release it yet; we're trying to 
get it GPL'd, though.  In its place, I've attached a test program 
that hits all of the problems we found during internal testing.  It's 
pretty long, but I'll try to convert it into something useable for 
the test suite.  (Regarding other Fortran compilers: ifort passes 
this test as is; xlf90 and pathscale pass a version without the 
derived type pointees; and pgf90 fails, probably due to aggressive 
optimization.)

-Asher


2005-07-29  Asher Langton  <langton2@llnl.gov>

	PR fortran/17031
	PR fortran/22282
	* check.c (gfc_check_loc) : New function

	* decl.c (variable_decl): New variables cp_as and sym.  Added 
a check for variables that
	have already been declared as Cray Pointers, so we can get 
the necessary attributes
	without adding a new symbol.
	(match_type_spec): Added code for BYTE type
	(attr_decl1):  Added code to catch pointee symbols and "fix" 
their array specs
	(cray_pointer_decl): New method
	(gfc_match_cray_pointer): New method
  	(gfc_match_derived_decl): Added check for derived type called BYTE
	(gfc_mod_pointee_as): New method

	* expr.c (gfc_check_assign): added a check to catch 
vector-type assignments
  	to pointees with an unspecified final dimension.

	* gfortran.h: (GFC_ISYM_LOC): New
	(symbol_attribute): Added cray_pointer and cray_pointee bits
	(gfc_array_spec): Added cray_pointee and cp_was_assumed bools
	(gfc_symbol): Added gfc_symbol *cp_pointer
	(gfc_option): Added flag_cray_pointer and flag_byte_type
	(gfc_add_cray_pointee): Declare
	 gfc_add_cray_pointer ): Declare

	* intrinsic.c (add_functions): add code for loc() intrinsic

	* intrinsic.h (gfc_check_loc): Declare
	(gfc_resolve_loc): Declare

	* iresolve.c (gfc_resolve_loc): New

	* lang.opt: Added fcray-pointer flag and fbyte-type flags

	* match.h (gfc_match_cray_pointer): Declare

	* options.c (gfc_init_options): Intialized 
gfc_match_option.flag_cray_pointer and
	gfc_match_option.flag_byte_type
	(gfc_handle_option): deal with -fcray-pointer and fbyte-type flags

	* parse.c (decode_statement): added code to detect statements 
starting with
	 "pointer ("

	* resolve.c (check_dimension): added code to prevent bounds 
checking for Cray
  	Pointee arrays.

	* symbol.c (gfc_add_cray_pointer): New
	(gfc_add_cray_pointee): New
	(gfc_copy_attr): New code for Cray pointers and pointees

	* trans-array.c (gfc_trans_auto_array_allocation): added code 
to prevent space from
  	being allocated for pointees
	(gfc_conv_array_parameter): added code to catch pointees and
  	correctly set their base address.

	* trans-decl.c (gfc_finish_var_decl):  added code to prevent 
pointee declarations from making
	it to the back end.
	(gfc_create_module_variable):  same

	* trans-expr.c
	(gfc_conv_variable): added code to detect and translate pointees

	* trans-intrinsic.c (gfc_conv_intrinsic_loc): New
	(gfc_conv_intrinsic_function): added entry point for loc translation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cp_patch_7_29b.diff
Type: application/octet-stream
Size: 31495 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050729/d8ab5031/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cp_test.f90
Type: application/octet-stream
Size: 85956 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050729/d8ab5031/attachment-0001.obj>


More information about the Fortran mailing list