The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

DLAMCH stalls when called from Delphi

Open discussion regarding features, bugs, issues, vendors, etc.

DLAMCH stalls when called from Delphi

Postby Esquivel » Wed Jul 02, 2008 10:33 am

Hi folks!

I'm currently working on a Delphi programm calling functions from LAPACK.dll which works quite well in general, but I have encountered a severe problem: As soon as the function DLAMCH from LAPACK.dll is called, the execution stalls (remember: DLAMCH determines double precision machine parameters).

I have figured out up to now that DLAMCH stalls in subroutine DLAMC1
which determines the machine parameters given by BETA, T, RND, and IEEE1 (i.e. BETA = base of the machine, T = number of BETA digits in the mantissa, RND = does rounding or chopping occur in addition?, IEEE1 = is rounding done in IEEE style?). DLAMC1 does not terminate in the very last while loop which is supposed to compute the mantissa T.

When I'm calling DLAMCH from LAPACK.dll out of a C programm everything works fine. Has anybody a clue what the reason may be and how this problem could be solved?

Thanks in advance!

Sandro
Esquivel
 
Posts: 2
Joined: Wed Jul 02, 2008 10:16 am

Solution to the problem

Postby Esquivel » Tue Jul 08, 2008 9:14 am

Ok, in the meantime I have figured out the problem and its (possibly hacking) solution...

First, the computation of the mantissa of floating point numbers fails when DLAMC1 is called from Delphi. I do not know until now why it does so but including a single printf("") right in front of the last while loop computing the mantissa length mysteriously solves the problem... Maybe it is a synchronisation problem which is solved by the minimal delay which is caused by evaluating printf(""). However, this problem could only be solved by me by recompiling the LAPACK.dll from CLAPACK and inserting said printf("").

Second, Delphi catches floating point exceptions by default while MS Visual Studio supresses them for instance. One of these is the "Invalid Floating Point Operation" exception which is raised when NaN values occur which is not desiderable in all cases, especially for LAPACK routines! Moreover, overruns of the FPU are considered as exception while DLAMCH explicitely aims at producing such an overrun in order to compute floating point parameters! So FPU exceptions have to be turned off before calling a LAPACK routine (and possibly turned back on afterwards) by calling
Code: Select all
Set8087CW($133F);

from the Delphi program.

Hope it might help one or the other who struggles with Delphi and LAPACK...

Sandro
Esquivel
 
Posts: 2
Joined: Wed Jul 02, 2008 10:16 am


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 8 guests