- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hi everybody!

I'm posting an update related to my VecLib project.While testing slightly optimized version of sine function where the sine convergence

is achieved with the help of SSE inline assembly I ran into some problem.I eliminated one instruction which performed explicit multiplication of the argument by x^2 so the total count of instruction per one term was three,but the accurracy was greatly reduced up to 2-3 decimal places.Double precision primitives were used so the loss of accurracy can not be blamed for the inaccurate result.

I suspect that somehow combined multiplication of an argument by pre-calculated coefficient coupled with exponentiation of the argument all of it performed in the same xmm0 register which served as an accumulator could have caused probably the loss in accuracy.

I rewrote the inline asm block and removed the load of xmm0 register by adding another instruction which multiplies the argument by x^2 and that problem dissapeared.

Please look at Vec_Sin_f() function inline assembly code block and Vec_Cos_d() inline assembly block.

Here is the part of optimized code which is responsible for the loss of accuracy.This code calculate third term of Taylor expansion by mean of of Horner scheme

[cpp]movupd xmm1,veclib3[/cpp]

[cpp]mulpd xmm0,xmm1[/cpp] This part of the code is responsible for the inaccurrate result

[cpp]addpd xmm7,xmm0[/cpp]

And here is the part of corrected code.I added another instruction which performs a multiplication of an argument by x^2 in different register

[cpp]movupd xmm1,vec3lib[/cpp]

[cpp]mulpd xmm0,xmm5[/cpp]

[cpp]mulpd xmm1,xmm0[/cpp]

[cpp]addpd xmm7,xmm1[/cpp]

Thanks in advance.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page