Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 5 Data types and data objects

Resolving issues with unaligned data

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

The following suggestions will aid with issues regarding unaligned data:

For Itanium®—based applications

As a quick fix, add the following call to the main program:

call allow_unaligned_data_access( )

Then, link in an additional library that fixes these alignment issues at runtime:

-lunalign

Longer term, try compiling with the following flag:

+allow_unaligned

An example would be:

PROGRAM bs30
INTEGER*2 i2(10)
INTEGER*4 i4
EQUIVALENCE (i2(2), i4)
DATA I4 /z’FFFF0000’/
i4=12
    call allow_unaligned_data_access()

print *,i4
END

Then compile with:

/opt/fortran90/bin/f90 foo.f -lunalign +noppu

If you need to drop the +noppu, then add an alias directive as follows:

!$HP$ALIAS allow_unaligned_data_access=’allow_unaligned_data_access’

PROGRAM bs30
INTEGER*2 i2(10)
INTEGER*4 i4
EQUIVALENCE (i2(2), i4)
DATA I4 /z’FFFF0000’/
i4=12
    call allow_unaligned_data_access()

print *,i4
END

Then compile with:

/opt/fortran90/bin/f90 foo.f -lunalign

NOTE: Nothing new is required to use the aforementioned -lunalign runtime fix approach; however, you do need the latest patch for the +allow_unaligned compile flag.

If the misaligned data might be passed to routines which are not compiled with +allow_unaligned (for example, Fortran runtime IO and F90 libraries), then having the call will allow the runtime fixes to happen which will prevent bus errors in your application.

To realize optimum performance, try and measure the following two options:

1. Compile with +allow_unaligned and insert the call to allow_unaligned_data_access()
2. Only insert the call to allow_unaligned_data_access()

Option #1 may perform faster with very few references to misaligned data and a handler is invoked for these misaligned references. #2 may perform faster with many references.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.