[patch, libfortran] Implement KIND specific floating point formatted output

Jerry DeLisle jvdelisle@verizon.net
Wed Aug 22 07:42:00 GMT 2007


Hi all,

I was hesitating to submit this because I wanted to make sure there is at least 
some benefit.

The attached patch re-factors the formatted write_float and associated functions 
to not use GFC_REAL_LARGEST and to use KIND specific functions for each of the 
four KINDs supported, 4,8,10, and 16.

I folded most of this into a new file 'write_float.def' which is included by 
write.c.  I factored as much code as I could that was not KIND dependent into 
separate functions and then used macros to build KIND specific functions where 
needed.

Performance for KIND=4 is improved some as would be expected.  Larger KIND 
performance remains about the same.  I am concerned that there are some cases 
where formatted output is a tad slower.  I was using gfortran 4.2 unpatched for 
comparison so that may be a difference between 4.2 and 4.3. (hmm is that a 
performance regression?).

I have no way to test this on any system that supports KIND=16, though it should 
be OK. This patch could be useful for resolving PR23138.  Also the factoring 
(re-organizing the code) may be useful toward later performance improvements.

Regression tested on x86-64-Gnu-Linux.  No new test cases.

OK for trunk.

Regards,

Jerry

2007-08-21  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	* io/write.c (stdbool.h): Add include. (sign_t): Move typedef to
	new file write_float.def. Include write_float.def.
	(extract_real): Delete. (calculate_sign): Delete.
	(calculate_exp): Delete. (calculate_G_format): Delete.
	(output_float): Delete. (write_float): Delete.
	* io/write_float.def (calculate_sign): Added.
	(output_float): Refactored to be independent of kind and added to this
	file for inclusion. (write_infnan): New function to write "Infinite" or
	"NaN" depending on flags passed, independent of kind.
	(CALCULATE_EXP): New macro to build kind specific functions. Use it.
	(OUTPUT_FLOAT_FMT_G): New macro, likewise. Use it.
	(DTOA, DTOAL): Macros to implement "decimal to ascii".
	(WRITE_FLOAT): New macro for kind specific write_float functions.
	(write_float): Revised function to determine kind and use WRITE_FLOAT
	to implement kind specific output.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: write_float.diff
Type: text/x-patch
Size: 37271 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070822/c048c718/attachment.bin>


More information about the Fortran mailing list