Skip to content

Commit

Permalink
Add tests for vadda
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 12, 2023
1 parent 661f5a1 commit e9fa480
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 4 deletions.
9 changes: 9 additions & 0 deletions code/vadda_b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v128 vadda_b(v128 a, v128 b) {
v128 dst;
#include "vadda_b.h"
return dst;
}

void test() { FUZZ2(vadda_b); }
2 changes: 1 addition & 1 deletion code/vadda_b.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 16; i++) {
dst.byte[i] = abs(a.byte[i]) + abs(b.byte[i]);
dst.byte[i] = abs((s8)a.byte[i]) + abs((s8)b.byte[i]);
}
9 changes: 9 additions & 0 deletions code/vadda_d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "common.h"

v128 vadda_d(v128 a, v128 b) {
v128 dst;
#include "vadda_d.h"
return dst;
}

void test() { FUZZ2(vadda_d); }
2 changes: 1 addition & 1 deletion code/vadda_d.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for (int i = 0; i < 2; i++) {
dst.dword[i] = abs(a.dword[i]) + abs(b.dword[i]);
dst.dword[i] = abs((s64)a.dword[i]) + abs((s64)b.dword[i]);
}

10 changes: 10 additions & 0 deletions code/vadda_h.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "common.h"

v128 vadda_h(v128 a, v128 b) {
v128 dst;
#include "vadda_h.h"
return dst;
}

void test() { FUZZ2(vadda_h); }

2 changes: 1 addition & 1 deletion code/vadda_h.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for (int i = 0; i < 8; i++) {
dst.half[i] = abs(a.half[i]) + abs(b.half[i]);
dst.half[i] = abs((s16)a.half[i]) + abs((s16)b.half[i]);
}

10 changes: 10 additions & 0 deletions code/vadda_w.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "common.h"

v128 vadda_w(v128 a, v128 b) {
v128 dst;
#include "vadda_w.h"
return dst;
}

void test() { FUZZ2(vadda_w); }

2 changes: 1 addition & 1 deletion code/vadda_w.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (int i = 0; i < 4; i++) {
dst.word[i] = abs(a.word[i]) + abs(b.word[i]);
dst.word[i] = abs((s32)a.word[i]) + abs((s32)b.word[i]);
}
8 changes: 8 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
import os

def define_env(env):
widths = {
Expand Down Expand Up @@ -30,6 +31,10 @@ def include(file):

def instruction(intrinsic, instr, desc):
file_name = instr.split(" ")[0].replace(".", "_")
if os.path.exists(f"code/{file_name}.cpp"):
tested = "Tested on real machine."
else:
tested = ""
return f"""
## {intrinsic}
Expand All @@ -51,6 +56,9 @@ def instruction(intrinsic, instr, desc):
```c++
{include(f'{file_name}.h')}
```
{tested}
"""

@env.macro
Expand Down

0 comments on commit e9fa480

Please sign in to comment.