Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

Compatibility of complex arrays (2025.1) with reference BLAS

NCarlson
New Contributor I
1,028 Views

There seems to be either an ifx bug involving passing (whole) complex arrays to complex BLAS procedures from the system reference BLAS library or an expected incompatibility with the library (I'm on Linux). I'm really not sure what to make of it.  Here's an example code.

use,intrinsic :: iso_fortran_env
implicit none

interface ! BLAS procedures
  function cdotc(n, x, incx, y, incy)
    import
    integer :: n, incx, incy
    complex(real32) :: x(*), y(*), cdotc
  end function
  function zdotc(n, x, incx, y, incy)
    import
    integer :: n, incx, incy
    complex(real64) :: x(*), y(*), zdotc
  end function
end interface

integer :: stat = 0

block
  complex(real32) :: z(2)
  z = cmplx(3,4,kind=real32)
  if (cdotc(2,z,1,z,1) /= 25*size(z)) stat = stat + 1
end block

block
  complex(real64) :: z(2)
  z = cmplx(3,4,kind=real64)
  if (zdotc(2,z,1,z,1) /= 25*size(z)) stat = stat + 2
end block

stop stat

end

This should return a 0 status value, and it does with flang, gfortran, and NAG (compiled with -lblas).  However using ifx and -lblas it returns 3, indicating both calls returned incorrect results. But if I use the MLK blas (-qmkl) it returns 0.  So is this just an expected incompatibility with the reference BLAS compiled with a non-Intel compiler?  I'm surprised because we make some limited use of ifx and real BLAS/LAPACK procedures from the reference libraries without any problem.

 

1 Reply
Keith_R_1
Novice
811 Views

So is this just an expected incompatibility with the reference BLAS compiled with a non-Intel compiler?

Yes, exactly that.  There is no common Fortran ABI, which will allow a successful link to libraries and be compiler-independent.  In principle libraries must be compiled separately for every different Fortran compiler. However it just so happens that flang and NAG both use the GNU ABI, so in that case you got away with it.

Actually and more specifically the title of this post is misleading.  It's not the passing of complex arrays which is causing the problem - these are compatible between Intel and GNU - it is the complex function result which is incompatible.

I assume that you are aware that Intel's MKL libraries provide both Intel-ABI and GNU_ABI versions of BLAS.

0 Kudos
Reply