Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

HP OpenVMS Systems

Ask the Wizard
» 

HP OpenVMS Systems

OpenVMS information

» What's new on our site
» Upcoming events
» Configuration and buying assistance
» Send us your comments

HP OpenVMS systems

» OpenVMS software
» Supported Servers
» OpenVMS virtualization
» OpenVMS solutions and partners
» OpenVMS success stories
» OpenVMS service and support
» OpenVMS resources and information
» OpenVMS documentation
» Education and training

Evolving business value

» Business Systems Evolution
» AlphaServer systems transition planning
» Alpha RetainTrust program

Related links

» HP Integrity servers
» HP Alpha systems
» HP storage
» HP software
» HP products and services
» HP solutions
» HP support
disaster proof
HP Integrity server animation
Content starts here

Ask the Wizard Questions

Restricted pointers in DEC C

The Question is:

Dear Wizard:

This is a really C question, but as it concerns a #pragma (or rather
the lack of one) it is specific to DEC C.

Consider the following function definition

    void f(float * a, const float * const b)
    {
        *++a = *b;
        *++a = *b;
    }

for which DEC C V5.0-003 (with /OPTIMIZE=LEVEL=4) produces the
following code:

        ADDL    a, 4, a
        LDF     F0, (R17)
        STF     F0, (R16)
        ADDL    a, 4, R16
        LDF     F1, (R17)
        STF     F1, (R16)
        RET     R26

Observe that *b is loaded twice, as it must be because according the C
semantics b and a could point to the same location. There is
apparently no way to tell DEC C that a and b will always point at
disjoint regions of memory; it is not expressible within the language
itself, although some compilers provide a #pragma to do so.

It is of course very easy to rewrite the trivial example above to
avoid the problem, but there are many more interesting examples where
it seems harder to find such a solution. For instance, consider matrix
multiplication where I would like to tell the compiler that the result
matrix is disjoint from the argument matrices. At present the
generated code contains lots of unnecessary loads which reduces the
performance considerably, which is especially galling as the result
obtained using the obvious algorithm (without a matrix temporary) is
wrong if the result and arguments are not disjoint anyhow!

I could copy the arguments into local temporaries, but then I run into
a whole lot of problems, such as that I might inhibit optimizations
like loop unrolling and instruction scheduling, and that I need to
allocate the memory for the temporaries somewhere (which is not so
easy if the number of temporaries is not known at compile time).

I welcome your suggestions, as I find that this problem makes it hard
approach the peak floating point performance of an Alpha processor
using DEC C.


The Answer is:

What you are asking for is a feature known as "restricted pointers".  We have
no firm plans to implement this, but it is on our wishlist.  Thanks for your
interest in DEC C.


 

** About PDF files: The PDF files on this Web site can be read online or printed using Adobe® Acrobat® Reader. If you do not have this software installed on your system, you may download it from the Adobe Web site.
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2008 Hewlett-Packard Development Company, L.P.