Go to main content
Oracle® Developer Studio 12.6: Performance Library User's Guide

Exit Print View

Updated: July 2017
 
 

C Interfaces

The Oracle Developer Studio Performance Library routines can be called from within a FORTRAN 77, Fortran 95, or C program. However, C programs must still use the FORTRAN 77 calling sequence.

Oracle Developer Studio Performance Library contains native C interfaces for each of the routines contained in LAPACK, BLAS, FFTPACK, VFFTPACK, SPARSE BLAS, and SPSOLVE. The Oracle Developer Studio Performance Library C interfaces have the following features:

  • Function names have C names

  • Function interfaces follow C conventions

  • C interfaces do not contain redundant or unnecessary arguments for a C function

The following example compares the standard LAPACK Fortran interface and the Oracle Developer Studio Performance Library C interfaces for the DGBCON routine.

CALL DGBCON (NORM, N, NSUB, NSUPER, DA, LDA, IPIVOT, DANORM,
	DRCOND, DWORK, IWORK2, INFO)
void dgbcon(char norm, int n, int nsub, int nsuper, double *da,
	int lda, int *ipivot, double danorm, double drcond, 
	int *info)

Note that the names of the arguments are the same and that arguments with the same name have the same base type. Scalar arguments that are used only as input values, such as NORM and N, are passed by value in the C version. Arrays and scalars that will be used to return values are passed by reference.

The Oracle Developer Studio Performance Library C interfaces improve on CLAPACK, available on Netlib, which is an f2c translation of the standard libraries. For example, all of the CLAPACK routines are followed by a trailing underscore to maintain compatibility with Fortran compilers, which often postfix routine names in the object (.o) file with an underscore. The Oracle Developer Studio Performance Library C interfaces do not require a trailing underscore.

Oracle Developer Studio Performance Library C interfaces use the following conventions:

  • Input-only scalars are passed by value rather than by reference. Complex and double complex arguments are not considered scalars because they are not implemented as a scalar type by C.

  • Complex scalars can be passed as either structures or arrays of length 2.

  • Types of arguments must match even after C does type conversion. For example, be careful when passing a single precision real value, because a C compiler can automatically promote the argument to double precision.

  • Arrays are stored columnwise. For Fortran programmers, this is the natural order in which arrays are stored. For C programmers, this is the transpose of the order in which they usually work. In the documentation and man pages, references to rows refer to columns and vice versa.

  • Array indices are based at one, in conformance with Fortran conventions, rather than being zero as in C.

    For example, the Fortran interface to IDAMAX, which C programs access as idamax_, would return 1 to indicate the first element in a vector. The C interface to idamax, which C programs access as idamax, would also return a 1 to indicate the first element of a vector. This convention is observed in function return values, permutation vectors, and anywhere else that vector or array indices are used.


    Note - Some Oracle Developer Studio Performance Library routines use malloc internally, so user codes that make calls to Oracle Developer Studio Performance Library and to sbrk might not work correctly.

The SPARC version of the Oracle Developer Studio Performance Library uses global integer registers %g2, %g3, and %g4 in 32-bit mode and %g2 through %g5 in 64-bit mode as scratch registers. User code should not use these registers for temporary storage, and then call a Oracle Developer Studio Performance Library routine. The data will be overwritten when the Oracle Developer Studio Performance Library routine uses these registers.