Skip to content

Commit

Permalink
Add more testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Dec 11, 2023
1 parent 6d594a8 commit efe646c
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 2 deletions.
8 changes: 6 additions & 2 deletions code/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@

void test();

void print(const char *s, __m128i num) {
printf("__m128i %s: %016llx %016llx\n", s, num[0], num[1]);
}

void print(const char *s, __m128 num) {
printf("%s: %f %f %f %f\n", s, num[0], num[1], num[2], num[3]);
printf("__m128 %s: %f %f %f %f\n", s, num[0], num[1], num[2], num[3]);
}

void print(const char *s, __m128d num) {
printf("%s: %lf %lf\n", s, num[0], num[1]);
printf("__m128d %s: %lf %lf\n", s, num[0], num[1]);
}

#define PRINT(x) print(#x, x)
Expand Down
11 changes: 11 additions & 0 deletions code/vbitsel_v.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "common.h"

void test() {
__m128i a = {0x123456789ABCDEF0, 0x0FEDCBA987654321};
__m128i b = {0x1122334455667788, 0x1212343456567878};
__m128i c = {0x0FF0FFFF00000000, 0x0102040810204080};
PRINT(a);
PRINT(b);
PRINT(c);
PRINT(__lsx_vbitsel_v(a, b, c));
}
23 changes: 23 additions & 0 deletions code/vfmsub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "common.h"

void test() {
{
__m128 a = {1.0, 2.0, 3.0, 4.0};
__m128 b = {5.0, 6.0, 7.0, 8.0};
__m128 c = {9.0, 10.0, 11.0, 12.0};
PRINT(a);
PRINT(b);
PRINT(c);
PRINT(__lsx_vfmsub_s(a, b, c));
}

{
__m128d a = {1.0, 2.0};
__m128d b = {3.0, 4.0};
__m128d c = {5.0, 6.0};
PRINT(a);
PRINT(b);
PRINT(c);
PRINT(__lsx_vfmsub_d(a, b, c));
}
}
23 changes: 23 additions & 0 deletions code/vfnmadd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "common.h"

void test() {
{
__m128 a = {1.0, 2.0, 3.0, 4.0};
__m128 b = {5.0, 6.0, 7.0, 8.0};
__m128 c = {9.0, 10.0, 11.0, 12.0};
PRINT(a);
PRINT(b);
PRINT(c);
PRINT(__lsx_vfnmadd_s(a, b, c));
}

{
__m128d a = {1.0, 2.0};
__m128d b = {3.0, 4.0};
__m128d c = {5.0, 6.0};
PRINT(a);
PRINT(b);
PRINT(c);
PRINT(__lsx_vfnmadd_d(a, b, c));
}
}
23 changes: 23 additions & 0 deletions code/vfnmsub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "common.h"

void test() {
{
__m128 a = {1.0, 2.0, 3.0, 4.0};
__m128 b = {5.0, 6.0, 7.0, 8.0};
__m128 c = {9.0, 10.0, 11.0, 12.0};
PRINT(a);
PRINT(b);
PRINT(c);
PRINT(__lsx_vfnmsub_s(a, b, c));
}

{
__m128d a = {1.0, 2.0};
__m128d b = {3.0, 4.0};
__m128d c = {5.0, 6.0};
PRINT(a);
PRINT(b);
PRINT(c);
PRINT(__lsx_vfnmsub_d(a, b, c));
}
}

0 comments on commit efe646c

Please sign in to comment.