Commit ffe8b24
committed
C_LAPACK: take the float format from <float.h> in dlamch/slamch
INSTALL/dlamch.c and INSTALL/slamch.c are f2c translations of the deprecated
dlamchf77.f and slamchf77.f, which determine the floating point format at run
time by probing in dlamc1/dlamc2 rather than reading it from the environment.
The current dlamch.f and slamch.f use the Fortran 90 inquiry intrinsics
(EPSILON, TINY, HUGE, DIGITS, MINEXPONENT, MAXEXPONENT, RADIX) instead, but f2c
cannot translate those, so the C LAPACK selected by NOFORTRAN=1 has been left
with the older probing implementation.
The probe is only correct if double intermediates are genuinely rounded to
double. That does not hold on x87. Building 32 bit for a target without SSE2,
so with -mfpmath=387, and with gcc 16, the intermediates stay in registers and
the probe measures the 80 bit register format: it reports emin/emax as
-16381/16384, and a mantissa width that follows the caller's x87 precision
control bits (64 at extended precision, 53 at double). Written back as doubles,
rmin underflows to 0 and rmax overflows to +Inf, so dlamch('S') and dlamch('U')
return 0 and dlamch('O') returns +Inf.
Everything that scales by those values is then wrong, mostly silently. The
first symptom to surface was a floating point exception rather than a wrong
answer: dsbevx computes
safmin = dlamch('S')
eps = dlamch('P')
smlnum = safmin / eps
bignum = 1 / smlnum
so a zero safe minimum makes smlnum zero and the next line divides by zero.
Callers that unmask the divide by zero exception get a hard failure there;
callers that do not get whatever the wrong scaling produces.
Replace the probe with the <float.h> constants, mirroring the values the
current dlamch.f and slamch.f return. This fixes two lesser problems at the
same time: rmach was left uninitialised when cmach matched nothing, where
dlamch.f returns zero; and the cached static results made both routines
unsafe to call concurrently on first use.
dlamc1-dlamc5 and slamc1-slamc5 are left in place. They become unreachable
from dlamch/slamch, but dlamc3 and slamc3 have callers of their own in dlaed3,
dlaed9, dlals0, dlasd3, dlasd8 and their complex equivalents, where they serve
as optimiser barriers.1 parent d9f362a commit ffe8b24
2 files changed
Lines changed: 58 additions & 98 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | 358 | | |
362 | | - | |
363 | 359 | | |
364 | 360 | | |
365 | 361 | | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | 362 | | |
373 | 363 | | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 364 | + | |
380 | 365 | | |
381 | 366 | | |
382 | 367 | | |
| |||
385 | 370 | | |
386 | 371 | | |
387 | 372 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
406 | 390 | | |
407 | 391 | | |
408 | 392 | | |
409 | 393 | | |
410 | 394 | | |
411 | 395 | | |
412 | 396 | | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | 397 | | |
419 | 398 | | |
420 | | - | |
| 399 | + | |
421 | 400 | | |
422 | | - | |
| 401 | + | |
423 | 402 | | |
424 | | - | |
| 403 | + | |
425 | 404 | | |
426 | | - | |
| 405 | + | |
427 | 406 | | |
428 | | - | |
| 407 | + | |
429 | 408 | | |
430 | | - | |
| 409 | + | |
431 | 410 | | |
432 | | - | |
| 411 | + | |
433 | 412 | | |
434 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
435 | 416 | | |
436 | 417 | | |
437 | 418 | | |
438 | | - | |
439 | 419 | | |
440 | 420 | | |
441 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | 357 | | |
361 | | - | |
362 | 358 | | |
363 | 359 | | |
364 | 360 | | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | 361 | | |
372 | 362 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
| 363 | + | |
379 | 364 | | |
380 | 365 | | |
381 | 366 | | |
| |||
384 | 369 | | |
385 | 370 | | |
386 | 371 | | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
405 | 389 | | |
406 | 390 | | |
407 | 391 | | |
408 | 392 | | |
409 | 393 | | |
410 | 394 | | |
411 | 395 | | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | 396 | | |
418 | 397 | | |
419 | | - | |
| 398 | + | |
420 | 399 | | |
421 | | - | |
| 400 | + | |
422 | 401 | | |
423 | | - | |
| 402 | + | |
424 | 403 | | |
425 | | - | |
| 404 | + | |
426 | 405 | | |
427 | | - | |
| 406 | + | |
428 | 407 | | |
429 | | - | |
| 408 | + | |
430 | 409 | | |
431 | | - | |
| 410 | + | |
432 | 411 | | |
433 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
434 | 415 | | |
435 | 416 | | |
436 | 417 | | |
437 | | - | |
438 | 418 | | |
439 | 419 | | |
440 | 420 | | |
| |||
0 commit comments