3 Replies Latest reply on Jan 2, 2008 2:59 PM by chipf

    Standard C Interface to Blas

      ACML does not have a standard C interface to BLAS Why?

      Fortran is a dying language and many developers prefer to use C and their derivatives even for scientific programming. The BLAS folks long ago have kindly provided us a standard interferace for calling BLAS routines from C. Atlas, MKL GoTo etc. all implement the standard interferace. Legacy code may have hundreds of calls to these routines using the standard CBLAS interface and yet given the tremendous effort to create ACML the interface fails to adhere to the standard at all.

      The standard interface document is provided here:

      Instead for our ACML C interface we have some kind of hybrid derived from the Fortran interface. For example, one of the most commonly used routines dgemm has this cblas interface from the standard:

      void cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
      const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
      const int K, const double alpha, const double *A,
      const int lda, const double *B, const int ldb,
      const double beta, double *C, const int ldc);

      Unfortunately ACML uses this non standard C interface:
      extern void dgemm(char transa, char transb, int m, int n, int k, double alpha, double *a, int lda, double *b, int ldb, double beta, double *c, int ldc);

      Note that it has one less argument and does not use enumerated types. Thus for several routines it is not a matter of dropping the cblas_ prefix. What I would love to see is a blas to cblas header with the stubs that would give us access to the acml library without having to change hundreds of lines of legacy code.
        • Standard C Interface to Blas
          I guess one path to a solution here is to use the reference cblas library that calls the fortran routines from some C stubs.


          This still requires modification of the cblas_f77.h file but is hopefully fairly reasonable. It would have been preferable for acml to provide the standard C interface instead of redefining their own. After all we could in theory have called the Fortran directly from our C code if we were worried about the extra layer of overhead.
          • Standard C Interface to Blas
            Actually it seems my solution doesn't work very well. ACML doesn't even have a standard Fortran interface. The return values are returned through the first argument on the stack instead of the last and even worse some prototypes actually have a different number of arguments. For example CGBMV requires 14 arguments in the ACML library whereas the BLAS standard has 13 arguments. I don't know what the extra arguments are for unfortunately. How do people even use the acml BLAS libraries if you can't interchange them with other BLAS libraries, I'm curious.