Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Another problem with COMMON

davidgraham
Beginner
451 Views
I have a common block to define a number of coordinates 'coords.gcb'
------------------------------------
integer*4 e(800000),n(800000),h(800000)
------------------------------------
common /coords/e,n,h
In my program I have an include
--------------------------------------
include 'coords.gcb'! e,n,h
------------------------------------
I then refer to the variables and it works fine.
This is old code and I want to improve it and have one rather than 3 arrays with a type definition for e,n,h.
I declared a type
----------------------------------
type CoordsType
integer*4 e! easting
integer*4 n! northing
integer*4 h! height
end type CoordsType
----------------------------------
added this before the definition of the array:
------------------------------------
type CoordsType
integer*4 e! easting
integer*4 n! northing
integer*4 h! height
end type CoordsType
type (CoordsType) :: coords(800000)
common /ccoords/coords
------------------------------------------
This wouldn't work, so I took the type definition out as a Module, but this didn't work.
I'm getting the error message:
Error: If a common-block-object is of a derived type, it must be of a sequence type (R549.f)
Any ideas what what this means, what I have done wrong and how I can get it to work?
Thanks,
David
0 Kudos
2 Replies
jim_dempsey
Beginner
451 Views

Try inserting "sequence" into your type definition

Code:

type CoordsType
  sequence
  integer*4 e ! easting
  integer*4 n ! northing
  integer*4 h ! height
end type CoordsType


I have experimented with this somewhat and found that changing from individual arrays to a defined type may exhibit a performance hit. The IA32 and IA64 processors instructions can scale at 1, 2, 4, and 8 but not 12 as your declared type requires. If you have performance requirements then I would suggest you keep the arrays seperate.

An alternate approach is to add an additional integer*4 padd variable into CoordsType to make the structure 16 bytes long. Then using the !DEC$ features you can declare 16 byte alignment and then require SSE3 instruction formats in your properties. With this all 4 elements can be moved and sometimes processed in one instruction. e.g

do I=1,size(coords)

coords(I) = coords(I) + coordsOffset

end do

where coordsOffset is of CoordsType

If properly setup, the compiler can generate code to process all 4 elements of the CoordsType in parallel using SSE3 instructions. You will get a significant boost in performance (at the expense of some memory).

Jim Dempsey

0 Kudos
davidgraham
Beginner
451 Views

Thanks, I added the SEQUENCE statement and it's OK.

The actual record was more complex being 23 bytes long, the longest being 8 bytes.

There was a message to say that the total bytes was not a multiple of the largest elemt. The largest element was 8 bytes so I added a 1 byte packing element and it is OK.

Thanks again,

David

0 Kudos
Reply