[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN/test normalize_test.cc
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN/test normalize_test.cc |
Date: |
Wed, 25 Mar 2009 20:18:17 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/03/25 20:18:17
Added files:
test : normalize_test.cc
Log message:
Added test function to test normalization in place (norm_v_1),
normalization
as assignment fomr a unit vector computed out of place (norm_v_2) and
assignment
from a unit vector computed out of place on a slice (norm_v_3).
Compilation options are:
-O3 -ffast-math -mfpmath=sse -msse
to make the asm code more readable. The results are:
_Z8norm_v_1v: _Z8norm_v_2v:
_Z8norm_v_3v:
.LFB1511: .LFB1512:
.LFB1513:
movl v, %eax movl v, %eax
movl v, %eax
pushl %ebp pushl %ebp
pushl %ebp
.LCFI5: .LCFI7:
.LCFI3:
movl %esp, %ebp movl %esp, %ebp
movl %esp, %ebp
.LCFI6: .LCFI8:
.LCFI4:
movsd (%eax), %xmm3 movsd (%eax), %xmm2
movsd (%eax), %xmm3
movsd 8(%eax), %xmm4 movsd 8(%eax), %xmm3
movsd 8(%eax), %xmm4
movsd 16(%eax), %xmm5 movsd 16(%eax), %xmm4
movsd 16(%eax), %xmm5
movapd %xmm3, %xmm1 movapd %xmm2, %xmm1
movsd 24(%eax), %xmm6
movapd %xmm4, %xmm2 movapd %xmm3, %xmm5
movapd %xmm3, %xmm1
mulsd %xmm3, %xmm1 mulsd %xmm2, %xmm1
movapd %xmm4, %xmm2
mulsd %xmm4, %xmm2 mulsd %xmm3, %xmm5
mulsd %xmm3, %xmm1
movapd %xmm5, %xmm0 movapd %xmm4, %xmm0
mulsd %xmm4, %xmm2
mulsd %xmm5, %xmm0 mulsd %xmm4, %xmm0
movapd %xmm5, %xmm0
addsd %xmm2, %xmm0 addsd %xmm5, %xmm0
mulsd %xmm5, %xmm0
movsd 24(%eax), %xmm2 movsd 24(%eax), %xmm5
addsd %xmm2, %xmm0
addsd %xmm0, %xmm1 addsd %xmm0, %xmm1
addsd %xmm0, %xmm1
movapd %xmm2, %xmm0 movapd %xmm5, %xmm0
movapd %xmm6, %xmm0
mulsd %xmm2, %xmm0 mulsd %xmm5, %xmm0
mulsd %xmm6, %xmm0
addsd %xmm1, %xmm0 addsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd .LC0, %xmm1 movsd .LC0, %xmm1
movsd .LC0, %xmm1
sqrtsd %xmm0, %xmm0 sqrtsd %xmm0, %xmm0
sqrtsd %xmm0, %xmm0
divsd %xmm0, %xmm1 divsd %xmm0, %xmm1
divsd %xmm0, %xmm1
mulsd %xmm1, %xmm3 mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm4 mulsd %xmm1, %xmm3
mulsd %xmm1, %xmm4
movsd %xmm3, (%eax) mulsd %xmm1, %xmm4
movsd %xmm3, (%eax)
movsd %xmm4, 8(%eax) movsd %xmm2, (%eax)
movsd %xmm4, 8(%eax)
mulsd %xmm1, %xmm5 movsd %xmm3, 8(%eax)
mulsd %xmm1, %xmm5
mulsd %xmm1, %xmm2 movsd %xmm4, 16(%eax)
mulsd %xmm1, %xmm6
movsd %xmm5, 16(%eax) mulsd %xmm5, %xmm1
movsd %xmm5, 16(%eax)
movsd %xmm2, 24(%eax) movsd %xmm1, 24(%eax)
movsd %xmm6, 24(%eax)
popl %ebp popl %ebp
popl %ebp
ret ret
ret
Note that the three functions are identical up to a minor reording in
norm_v_3.
There is therefore no need to have a normalize in place function, which
is
useful since working on slices is inconvenient since they are non-const
temporaries.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/test/normalize_test.cc?cvsroot=toon&rev=1.1
Patches:
Index: normalize_test.cc
===================================================================
RCS file: normalize_test.cc
diff -N normalize_test.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ normalize_test.cc 25 Mar 2009 20:18:16 -0000 1.1
@@ -0,0 +1,36 @@
+#include <TooN/TooN.h>
+#include <cmath>
+
+using namespace TooN;
+using namespace std;
+
+extern Vector<4>& v;
+
+inline void norm_in_place(Vector<4>& v)
+{
+ v/=sqrt(v*v);
+}
+
+
+inline Vector<4> unit(const Vector<4>& v)
+{
+ return v/sqrt(v*v);
+}
+
+
+void norm_v_1()
+{
+ norm_in_place(v);
+}
+
+void norm_v_2()
+{
+ v = unit(v);
+}
+
+
+void norm_v_3()
+{
+ v.slice<0,4>() = unit(v.slice<0,4>());
+}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN/test normalize_test.cc,
Edward Rosten <=