4 Replies Latest reply on Jun 19, 2009 7:02 PM by mickpont

    QR Factorization



      I'm trying to use ACML LAPACK/BLAS routines. I specifically use C fortran interfaces (e.g. function names end with underscores).

      The problem I face is that ACML method signatures differ from the LAPACK/BLAS standard. For instance, in LAPACK dormqr take 13 parameters, while the ACML version requires 15 parameters.

      The first problem is that now I have to change my code specifically for ACML usage. The second problem is that there's no documentation for the additional parameters.

      Where can I find documentation for the additional parameters? Is there a header file the comply with LAPACK/BLAS?


        • QR Factorization

          We just posted a quick poll about this topic on our download page.  Please vote if you haven't already.

          One of the choices was designed to see if we're documenting this topic well enough. I guess you're voting that we aren't, in a way. Although you do at least know which interface type you're using (Fortran style)

          The header file acml.h does have both C style and Fortran style C interfaces.  Unless you happened to choose one of a number of utility routines that we haven't included.  All of the main lapack routines should have prototypes.

          The extra parameters come into play when you have string or char parameters in the calling list.  Since Fortran doesn't have zero terminated strings, it requires a length parameter to tell it how long strings are.  Just to make things weird, the Fortran ABI implicitly puts these integer string lengths at the end of the list, after all of the explicit arguments.

          This is documented in our user guide, section 2.5.

          If you prefer, you can call the C style interfaces, without the underscore.  In these interfaces we allow C style strings and don't need the extra lenth parameters.  We also eliminate work arrays, allocating them in the C interface code.

          Please note that we only support Fortran column-major data ordering.  If your C program uses row-major, you will have to carefully account for that - possibly with creative use of the transpose flags.

            • QR Factorization


              First, thanks for the great info. I can now compile and run my code with ACML.

              Regarding the modified function prototypes: I can understand the problem you're trying to address, however according to LAPACK, char* parameters are single character and not a string. I find that modifying the prototype to support strings is actually confusing.

              Regarding the documentation, I might have missed this, however I believe section 2.5 discuss the C interfaces, and only mention the use of underscores in Fortran interface names. For me, C interfaces doesn't work as weel as Fortran interfaces due to the need to control memory allocations (e.g. the workspace area).

              Again, thanks for the help.

                • QR Factorization

                  If I can add a vote to this issue, I would suggest that the C interface _should not_ do memory management. In my specific case I have thousands of small linear systems and the extra memory allocation actually hurts.

                  • QR Factorization


                    just to be clear - it's not ACML that added those extra string length arguments, it's the Fortran compiler, just as it's the compiler that added the extra underscore to the end of the subroutine name. That's why it's usually easier to call the C interfaces to ACML routines, although your desire to handle all the memory allocation is a good reason to want to call the Fortran.

                    Incidentally, in Fortran, a character argument and a string argument aren't really different - a character is just a string of length 1. So if a Fortran routine declares a character argument, it still ends up with the extra length argument tacked on the end. Furthermore, the length argument is passed by value, rather than by reference as Fortran arguments are usually passed, so care is needed when calling Fortran interfaces from C.