Ada algoritma yang pake fungsi logaritma untuk setiap titik ketika rendering, mengingat fungsi logaritma lambatnya minta ampun.
Quote:
salah satu algoritma yang gw temukan untuk menghitung logaritma melibatkan pembagian iteratif dalam 2 tahap dan pembagian adalah AFAIK operasi aritmetika sederhana yang perlu cpu cycle paling mahal (dibanding perkalian)
kira-kira dari solusi di bawah (tambahin klo belum ada) lebih baik pilih yang mana dan kenapa? thx b4
- SLUT (simply look up table)?
- Algoritma numerik yang lebih cepat (pake binary log atau fixed point number)?
- program di gpu?
Masalah yang paling baik, menurut gue trade off. LUT IMO yang paling gak tepat tapi paling cepet.
__________________
"Experience is something that you got when you don't get something that you want" - Randy Pausch ( The Last Lecture )
"The brick wall is there for a reason, to separate those who really want it and the rest" - Randy Pausch ( The Last Lecture )
klo mo pake LUT mesti tau batasan memori jg kayaknya. klo mo per-bit bisa sampe 4GB (IEEE 754) buat LUT.
barusan dapet algoritma berbasis LUT yang cuma pake 64K memori dan presisi sampe 1e-7. setelah gw benchmark (di CPU), lumayan 4 kali lebih cepat.
Quote:
vinyals, Oriol; et al. Revisiting Basic function on current CPUs: A fast logarithm implementation with adjustable accuracy. June 21, 2007. ICSI Berkeley Report
gw pake 16 bit mantissa (jadi 7 bit dibuang) dan implementasiin untuk log10 (bukan ln).
Code:
var
//16 bit used for mantissa lookup
lut : array[0..65535] of single;
//IEEE 754 32-bit Floating-Point Number
procedure precalc_lut;
var
step : integer;
i, p, x : integer;
fval : single;
pf : ^dword;
begin
pf := @fval;
x := $3F800000;
pf^ := x;
step := 1 shl 16;//23 - 7
p := 1 shl 7;
for i := 0 to p - 1 do begin
lut[i] := log2( fval );
x := x + step;
pf^ := x;
end;
end;
function _log10( val: single ): single; register;
var
pf : ^dword;
x, log_2 : integer;
begin
pf := @val;
x := pf^;
log_2 := ( ( x shr 23 ) and $FF ) - 127;
x := (x and $7FFFFF) shr 16;
result := (
( lut[x]
+ log_2
)
* 0.301029995664
);
end;
hehehe ... mo nimbrung ... bikin fungsi logaritma pake SSE, masalahnya :
1. nggak gitu akurat, maklum cuma evaluasi maclaurin series cuma 4 suku saja
2. Only work for x where 0 < x < 2 (open interval)
3. No guarantee it is faster
Wogh maap om peb, otak gue cuman nyampe ke LUT, yang GPU sama Algo baru mah gue asumsi dari tingkat kesulitannya, maksudnya creating a new faster algo itu jelas lebih sulit daripada utilize GPU toh . kalo coding GPU om kiki noh .
__________________
"Experience is something that you got when you don't get something that you want" - Randy Pausch ( The Last Lecture )
"The brick wall is there for a reason, to separate those who really want it and the rest" - Randy Pausch ( The Last Lecture )