[comp.os.vms] VAX FORTRAN Structure vs Common Block Performance

phil@dhw68k.cts.com (Phil Suematsu) (02/08/89)

I would like to know if DEC has optimized the code generated by
VAX FORTRAN structure references since the VAX FORTRAN V4.6 version.
We would rather use structures than common blocks, but we have found
that references to structures are much slower than references to
common blocks.  Unfortunately, we cannot upgrade to VMS 5.0 yet
because of version-specific third-party software; however, we will
once the new version of the software is released.  If anyone has
installed VAX FORTRAN under VMS 5.0 or later, I would appreciate it
if you could compile and execute the program that appears below.
Please compile with "FORTRAN/LIST/MACRO".  You can mail me either the
compiler listing or the results generated by the program or both
if you are feeling especially generous.  I will post the results
if anyone is interested in this issue.
 
     Thanks in advance, Phil Suematsu
 
------------------------------- cut ---------------------------------
 
	integer*4	count, handle
	integer*4	test1
	integer*4	test2
	character*16	test3
 
	integer*4	common1
	integer*4	common2(8)
	character*16	common3
 
	common /common_test/	common1, common2, common3
	
	structure /structure_test/
	    integer*4		structure1
	    integer*4		structure2(8)
	    character*16	structure3
	end structure
 
	record /structure_test/ record_test
 
	handle = 0
 
	type *, 'Common Test:'
	type *, 'Adding an integer 10000000 times'
	call lib$init_timer(handle)
	do count = 1, 10000000
	    test1 = test1 + common1
	end do
	call lib$show_timer(handle)
 
	type *, 'Adding a specific integer array element 10000000 times'
	call lib$init_timer(handle)
	do count = 1, 10000000
	    test2 = test2 + common2(7)
	end do
	call lib$show_timer(handle)
 
	type *, 'Adding varying integer array elements 10000000 times'
	call lib$init_timer(handle)
	do count = 1, 10000000
	    test2 = test2 + common2((test2 .and. 7) + 1)
	end do
	call lib$show_timer(handle)
 
	type *, 'Copying 1000000 16-byte strings'
	call lib$init_timer(handle)
	do count = 1, 1000000
	    test3 = common3
	    call modify(test3, common3)
	end do
	call lib$show_timer(handle)
 
	call modify(test1, test2, test3)
 
	type *, ' '
	type *, 'Structure test:'
	type *, 'Adding an integer 10000000 times'
	call lib$init_timer(handle)
	do count = 1, 10000000
	    test1 = test1 + record_test.structure1
	end do
	call lib$show_timer(handle)
 
	type *, 'Adding a specific integer array element 10000000 times'
	call lib$init_timer(handle)
	do count = 1, 10000000
	    test2 = test2 + record_test.structure2(7)
	end do
	call lib$show_timer(handle)
 
	type *, 'Adding varying integer array elements 10000000 times'
	call lib$init_timer(handle)
	do count = 1, 10000000
	    test2 = test2 + record_test.structure2((test2 .and. 7) + 1)
	end do
	call lib$show_timer(handle)
 
	type *, 'Copying 1000000 16-byte strings'
	call lib$init_timer(handle)
	do count = 1, 1000000
	    test3 = record_test.structure3
	    call modify(test3, record_test.structure3)
	end do
	call lib$show_timer(handle)
 
	call modify(test1, test2, test3)
 
	end
 
	subroutine modify
 
	end
-- 
-----------------+------------------------------------------------------
  Phil Suematsu  | InterNet: phil@dhw68k.cts.com or phil@turnkey.tcc.com
Optical Research | or  uucp: ...{trwrb,hplabs}!felix!dhw68k!phil
   Associates    | or  Work: (818) 795-9101  or  Home: (714) 633-0876