Add vector unit tests and timing
Adds magnitude_sqr tests
This commit is contained in:
parent
91b4f47d9d
commit
810750febb
@ -11,7 +11,10 @@ bool vec_suite::addition_v2() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec2 operator()(vec2 a, vec2 b) {
|
||||
return a + b;
|
||||
start_timer();
|
||||
vec2 r = a + b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -23,7 +26,10 @@ bool vec_suite::addition_v3() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec3 operator()(vec3 a, vec3 b) {
|
||||
return a + b;
|
||||
start_timer();
|
||||
vec3 r = a + b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -35,7 +41,10 @@ bool vec_suite::addition_v4() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec4 operator()(vec4 a, vec4 b) {
|
||||
return a + b;
|
||||
start_timer();
|
||||
vec4 r = a + b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -48,7 +57,10 @@ bool vec_suite::subtraction_v2() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec2 operator()(vec2 a, vec2 b) {
|
||||
return a - b;
|
||||
start_timer();
|
||||
vec2 r = a - b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -60,7 +72,10 @@ bool vec_suite::subtraction_v3() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec3 operator()(vec3 a, vec3 b) {
|
||||
return a - b;
|
||||
start_timer();
|
||||
vec3 r = a - b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -72,7 +87,10 @@ bool vec_suite::subtraction_v4() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec4 operator()(vec4 a, vec4 b) {
|
||||
return a - b;
|
||||
start_timer();
|
||||
vec4 r = a - b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -85,7 +103,10 @@ bool vec_suite::negation_v2() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec2 operator()(vec2 a) {
|
||||
return -a;
|
||||
start_timer();
|
||||
vec2 r = -a;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -97,7 +118,10 @@ bool vec_suite::negation_v3() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec3 operator()(vec3 a) {
|
||||
return -a;
|
||||
start_timer();
|
||||
vec3 r = -a;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -109,7 +133,10 @@ bool vec_suite::negation_v4() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec4 operator()(vec4 a) {
|
||||
return -a;
|
||||
start_timer();
|
||||
vec4 r = -a;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -122,7 +149,10 @@ bool vec_suite::mult_scalar_v2() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec2 operator()(vec2 a, fixed x) {
|
||||
return a * x;
|
||||
start_timer();
|
||||
vec2 r = a * x;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -134,7 +164,10 @@ bool vec_suite::mult_scalar_v3() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec3 operator()(vec3 a, fixed x) {
|
||||
return a * x;
|
||||
start_timer();
|
||||
vec3 r = a * x;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -146,7 +179,10 @@ bool vec_suite::mult_scalar_v4() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec4 operator()(vec4 a, fixed x) {
|
||||
return a * x;
|
||||
start_timer();
|
||||
vec4 r = a * x;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -159,7 +195,10 @@ bool vec_suite::dot_v2() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
fixed operator()(vec2 a, vec2 b) {
|
||||
return a * b;
|
||||
start_timer();
|
||||
fixed r = a * b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -171,7 +210,10 @@ bool vec_suite::dot_v3() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
fixed operator()(vec3 a, vec3 b) {
|
||||
return a * b;
|
||||
start_timer();
|
||||
fixed r = a * b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -183,7 +225,10 @@ bool vec_suite::dot_v4() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
fixed operator()(vec4 a, vec4 b) {
|
||||
return a * b;
|
||||
start_timer();
|
||||
fixed r = a * b;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -196,7 +241,10 @@ bool vec_suite::division_scalar_v2() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec2 operator()(vec2 a, fixed x) {
|
||||
return a / x;
|
||||
start_timer();
|
||||
vec2 r = a / x;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -208,7 +256,10 @@ bool vec_suite::division_scalar_v3() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec3 operator()(vec3 a, fixed x) {
|
||||
return a / x;
|
||||
start_timer();
|
||||
vec3 r = a / x;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -220,7 +271,10 @@ bool vec_suite::division_scalar_v4() {
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
vec4 operator()(vec4 a, fixed x) {
|
||||
return a / x;
|
||||
start_timer();
|
||||
vec4 r = a / x;
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
@ -230,16 +284,49 @@ bool vec_suite::division_scalar_v4() {
|
||||
}
|
||||
|
||||
bool vec_suite::magnitude_sqr_v2() {
|
||||
log::debug << "UNIMPLEMENTED" << endl;
|
||||
return true;
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
fixed operator()(vec2 a) {
|
||||
start_timer();
|
||||
fixed r = a.magnitude_sqr();
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
fixed c = f(vec2(1, 2));
|
||||
|
||||
return c == 5;
|
||||
}
|
||||
bool vec_suite::magnitude_sqr_v3() {
|
||||
log::debug << "UNIMPLEMENTED" << endl;
|
||||
return true;
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
fixed operator()(vec3 a) {
|
||||
start_timer();
|
||||
fixed r = a.magnitude_sqr();
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
fixed c = f(vec3(1, 2, 3));
|
||||
|
||||
return c == 14;
|
||||
}
|
||||
bool vec_suite::magnitude_sqr_v4() {
|
||||
log::debug << "UNIMPLEMENTED" << endl;
|
||||
return true;
|
||||
struct {
|
||||
NOINLINE GBA_IWRAM ARM_MODE
|
||||
fixed operator()(vec4 a) {
|
||||
start_timer();
|
||||
fixed r = a.magnitude_sqr();
|
||||
end_timer();
|
||||
return r;
|
||||
}
|
||||
} f;
|
||||
|
||||
fixed c = f(vec4(1, 2, 3, 4));
|
||||
|
||||
return c == 30;
|
||||
}
|
||||
|
||||
bool vec_suite::transpose_v2() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user