Log In | Not a Member? | Support | |
Using AltiVecFor Panther (MacOS X.3) and earlier releases of MacOS X, Apple does not provide FORTRAN compilers, though high performance FORTRAN compilers are available from third party software developers, such as GNU (g77), Absoft, Numerical Algorithms Group (NAG), and the high performance FORTRAN compiler from IBM (xlf). If you choose to use the free GNU g77 compiler, please be aware that there is an incompatibility between the gcc 3.3 based assembler in the 2003 developer tools, and version 3.1 and earlier of g77. You will need to either install an older set of gcc-3.1 based developer tools (AltiVec performance is not as good with gcc-3.1 or lower), or install a gcc-3.4 or better based version of g77. Writing AltiVec in FORTRANCompiler support for the high level AltiVec language extensions is common for C family languages, but may be missing for FORTRAN. There is no standard for how a AltiVec extensions should be added to a language outside of C/C++/Objective C. If you are interested in writing AltiVec code directly in FORTRAN, please contact your compiler vendor to find out how best to do this. It is likely that you will need to write C functions that adhere to FORTRAN calling conventions. (All arguments need to be passed by address rather than by value. Matrices need to be in the FORTRAN column-major storage order.) LibrariesThe BLAS and LAPACK vectorized libraries in vecLib.framework are directly callable from FORTRAN. Both the g77 style naming convention (all lowercase name, underscore suffix) and the "classical" naming scheme (all uppercase, no underscores) are supported. The header cblas.h provides prototypes for the standard C interface to the BLAS. The header, clapack.h, provides prototypes to the LAPACK entry points. These use the FORTRAN calling conventions since there is no industry standard C binding for LAPACK. New for MacOS X.4, Tiger, vForce is callable from FORTRAN. Linking to vecLibTo link against vecLib.framework, add the following compile line option:
Some compilers do not understand the -framework flag. A common workaround is to use the following modified compile line instead. This will usually pass -framework vecLib through to the linker unmodified. The linker should understand what a framework is even if the compiler doesn't: There is no space after the commas. The second character is a lowercase L.
As a last resort, you may try linking directly to the vecLib binary as a dynamically linked library. It is to be found here:
Example: Integrating AltiVec into a FORTRAN appThis example was prepared using the MacOS X public beta of xlf. The test application (contained in test.f90) does performance benchmarking of three different ways to applyexp() over a small array of single precision floating point values. It begins by using the standard math library exp() function call. It then repeats the benchmark using the vecLib vexpf() function. That function is written to take AltiVec vectors by value, which means it only works for C. So, for this case, we show how to write a small C wrapper function to make it suitable for use with FORTRAN. Finally, there is an example that uses the AltiVec vexptefp instruction to do a limited precision estimate of exp() . It is written entirely in C using the AltiVec C language extension and calls no outside code.
Both C functions are in a file, You may download the example here. If your browser does not automatically uncompress the tar.gz file, you may do so from the command line as follows:
Next, compile the inputs:
To run, simply type:
On a 800 MHz G4 Powerbook, running MacOS X.3, Panther, we saw the following output:
|