The GNU Fortran compiler (gfortran), AOCC (Flang), and Intel Fortran compiler (ifort) have different requirements for returning complex numbers from the C functions as follows:
GNU (gfortran) compiler returns complex numbers using registers. Thus, the complex numbers are returned as the return value of the function itself. BLIS refers to this as “gnu” complex return, and this is the default choice.
AOCC (Flang) and Intel® (ifort) compilers return complex numbers using the hidden first argument. The caller must pass the pointer to the return value as the first parameter. BLIS refers to this as “intel” complex return, but it may be referred to elsewhere as “void” or “F2C” complex return.
The BLAS APIs affected are cdotc, cdotu, zdotc, and
zdotu APIs.
BLIS implements BLAS using C code. Thus it can support either Fortran complex return convention with any compiler using appropriate configure or cmake options. The options to implement the default Fortran convention for GNU and AOCC compilers are:
gfortran Example:
Configure Option:
--complex-return=gnu
cmake Option:
-DCOMPLEX_RETURN=gnu
API Call:
ret_value = cdotc_(&n, x, &incx, y, &incy);
AOCC flang Example:
Configure Option:
--complex-return=intel CC=clang CXX=clang++
cmake Option:
-DCOMPLEX_RETURN=intel
API Call:
cdotc_(&ret_value, &n, x, &incx, y, &incy);
Note
Individual applications or environment may have chosen a different convention from the compiler’s default. For example, PyTorch uses the GCC compiler but the “intel” complex return for library calls instead of the default “gnu” convention. AOCL binary distributions use the compiler’s default convention. Therefore for applications with different requirements, compile BLIS from source configured with the appropriate flags.