Nicolás Wolovick, 20160310
"La computación es la ciencia de la abstracción".
¿Mapeo no inyectivo R -> cantidad finita de bits?
123.45 -> 0001 0010 0011 0100 0101
123.45 -> 12345/100
123.45 -> 11000000111001
123.45 -> 0.12345 * 10^3
Si hacemos arqueología computacional, vamos a encontrar de todo.
Hay cosas curiosas. Por ejemplo la ZX81 solo manejaba flotantes cuando su µP sumaba enteros de hasta 16 bits.
(-1)^s * (1+mantisa) * 2^{exponente-offset}
Verdades de perogrullo.
a+b = a, b!=0
1 REAL*4 X,Y
2 X = 1.25E8
3 Y = X + 7.5E-3
4 IF (X .EQ. Y) THEN
5 PRINT *,'Am I nuts or what?'
6 ENDIF
7 PRINT *,X,Y
8 END
0.1*10 != 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1
1 REAL*4 X,Y
2 X = 0.1
3 Y = 0
4 DO I=1,10
5 Y = Y+X
6 ENDDO
7 IF (Y .EQ. 1.0) THEN
8 PRINT *,'Algebra is truth'
9 ELSE
10 PRINT *,'Not here'
11 ENDIF
12 PRINT *,1.0-Y
13 END
x^-1 * x != 1
1 INTEGER X
2 DO X=1, 1000
3 IF ((1.0/X)*X .NE. 1.0) THEN
4 PRINT *, "X^-1*X != 1 for X=", X
5 ENDIF
6 ENDDO
7 END
Imprime 135 números.
1 (X+Y)+Z = (.00005 + .00005) + 1.0000
2 = .0001 + 1.0000
3 = 1.0001
4 X+(Y+Z) = .00005 + (.00005 + 1.0000)
5 = .00005 + 1.0000
6 = 1.0000
El no-determinismo en el orden de la suma se pierde.
No es un conjunto es una secuencia.
Secuencialidad => Corrección
¿Adiós paralelismo!
El estándar de "C"
dice que (x+y)+z
se puede evaluar como x+(y+z)
.
(mirar gimple)
Transformar divisiones en multiplicaciones siempre que se pueda.
También define el "como" de las computaciones:
Hay no-determinismo en esta especificación que permite diferentes implementaciones.
Implementaciones: Intel, Cray, NVIDIA, AMD, Xilnix, IBM, ...
ggs
Todas las implementaciones permiten modificar el rounding mode.
000...0
.NaN
es una constante que se propaga infinitamente.fp32
vs. fp64
fp64
ocupa el doble de memoria.fp64
.fp16
y no IEEE754 compatible.fp16
para CV y DNN.fp80
y por fuera fp32
o fp64
.--use_fast_math (-use_fast_math)
Make use of fast math library. -use_fast_math implies -ftz=true
-prec-div=false -prec-sqrt=false.
--ftz [true,false] (-ftz)
When performing single-precision floating-point operations, flush
denormal values to zero or preserve denormal values. -use_fast_math
implies --ftz=true.
Default value: 0.
--prec-div [true,false] (-prec-div)
For single-precision floating-point division and reciprocals, use IEEE
round-to-nearest mode or use a faster approximation. -use_fast_math
implies --prec-div=false.
Default value: 1.
--prec-sqrt [true,false] (-prec-sqrt)
For single-precision floating-point square root, use IEEE
round-to-nearest mode or use a faster approximation. -use_fast_math
implies --prec-sqrt=false.
Default value: 1.
--fmad [true,false] (-fmad)
Enables (disables) the contraction of floating-point multiplies and
adds/subtracts into floating-point multiply-add operations (FMAD, FFMA,
or DFMA). This option is supported only when '--gpu-architecture' is
set with compute_20, sm_20, or higher. For other architecture classes,
the contraction is always enabled. -use_fast_math implies --fmad=true.
Default value: 1.
-ffast-math
Sets -fno-math-errno, -funsafe-math-optimizations, -ffinite-math-only, -fno-rounding-math, -fno-signaling-nans and
-fcx-limited-range.
-funsafe-math-optimizations
Allow optimizations for floating-point arithmetic that (a) assume that arguments and results are valid and (b) may violate IEEE
or ANSI standards. When used at link-time, it may include libraries or startup files that change the default FPU control word
or other similar optimizations.
This option is not turned on by any -O option since it can result in incorrect output for programs that depend on an exact
implementation of IEEE or ISO rules/specifications for math functions. It may, however, yield faster code for programs that do
not require the guarantees of these specifications. Enables -fno-signed-zeros, -fno-trapping-math, -fassociative-math and
-freciprocal-math.
The default is -fno-unsafe-math-optimizations.
Modificar el registro de estado MXCSR
.
FZ bit 15 Flush To Zero
R+ bit 14 Round Positive
R- bit 13 Round Negative
RZ bits 13 and 14 Round To Zero
RN bits 13 and 14 are 0 Round To Nearest
Modificadores de las instrucciones de assembler:
.rn Round to nearest even.
.rz Round towards zero.
.rm Round towards -infty.
.rp Round towards +infty.
fp64
de manera juiciosa (ancho de banda, memoria).fp64
y almacena los vectore en fp32
.Naturales: notación binaria
Enteros: representación complemento a 2s.
1 bits: nombre
2 8: char
3 16: short
4 32: int, long
5 64: long
¡Depende de la arquitectura!
1 #include <inttypes.h>
2
3 int8_t spin;
4 uint64_t total_sum;
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |