LAPACK Archives

[Lapack] Thread safety of LAPACK

And Marco Lombardi writes:
- Second, I would like to propose a workaround for all guys that (like me)
cannot or do not want to recompile the whole library.  The solution, in this
case, is to create two thread-safe versions of the {S,D}LAMCH
functions [...]

A third workaround is to create a LAPACK_INIT() subroutine that must
be called by a single thread before any other LAPACK routines are called
by any thread.  An example routine in modern Fortran:

subroutine lapack_init ()
    real(kind(0.0)) function slamch (cmach)
      character, intent(in):: cmach
    end function slamch
    real(kind(0.0d0)) function dlamch (cmach)
      character, intent(in):: cmach
    end function dlamch
  end interface
end subroutine lapack_init

The calls to slamch and dlamch initialize the internal SAVE variables
that cause problems.

It is fairly common to have a library initialization routine that must
be called my the "master" before any other thread accesses the library.
Some libraries on some platforms employ linker tricks to insert a call
to the initialization routine at library load time, but that's not at
all portable.


<Prev in Thread] Current Thread [Next in Thread>

For additional information you may use the LAPACK/ScaLAPACK Forum.
Or one of the mailing lists, or