Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: altivec/velocity engine examples



> That includes links to sample code here: http://developer.apple.com/hardware/ve/downloads/fortran_sample.tar.gz
> The code looks like it depends on C stubs to wrap the vector datatypes, but I (thankfully) don't understand enough
> FORTRAN to know if that is required or not or what the issues are that cause the need for the C wrappers. If I had
> to guess, I would assume datatype manipulations and/or compiler support.



Yes, the issue here is that there was never a language extension added on to FORTRAN to use AltiVec.  Motorola did define one for C however:


 http://www.freescale.com/files/32bit/doc/ref_manual/ALTIVECPIM.pdf

Happily, C is callable from FORTRAN, as long as you observe FORTRAN's function calling conventions.  Largely this boils down to everything is passed by address, not value, and some matrix storage order convention issues. If you are lazy in your C code and don't handle misalignment, then you'll have to make sure your fortran arrays are 16 byte aligned. This can be done by creating them with allocate(). 

Some of Accelerate.framework is callable directly from FORTRAN. The rest can be called if you make small C wrapper functions that convert function parameters passed by value to those passed by address.  This should be three lines of code for each one, so the only difficulty here is for people who don't really understand C or pointers. 

I'm not aware of any particular reason why there could not be a AltiVec/VMX/Velocity Engine extension to FORTRAN, though there might be some difficulties since the loads, stores and prefetch hints seem to require pointers.  This would probably be something to take up with the IBM XLF compiler team. They have support for PPC intrinsics in xlf, and experience with the C programming interface extensions in xlc already so I suspect they already have some features resident in the compiler that could be turned towards this goal.

Ian
    
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Scitech mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/scitech/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.