Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional vec inst #5

Merged
merged 14 commits into from
Nov 14, 2023
Merged
105 changes: 85 additions & 20 deletions src/main/resources/applications_vector/build.sh

Large diffs are not rendered by default.

1,096 changes: 1,096 additions & 0 deletions src/main/resources/applications_vector/vmacc.dump

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions src/main/resources/applications_vector/vmacc/vmacc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#include "util.h"

#define size_t long
#define N 48

const signed short dataArray0[N] = {-26995, -13957, -10861, 25374, -18032, -21149, 23738, 24548, -28110, -21910, 16774, -10117, 19840, -11921, 12711, -24192, 27586, -20052, -20407, 13650, -15786, 21109, 31998, 18796, -11098, -1692, 1179, -29277, -17643, -26788, -15187, -12884, -8109, -21033, -28781, 21148, -26980, 24605, 14759, 5326, 32568, 14468, -29372, -25205, -3712, 12033, -13808, 15296};
const signed short dataArray1[N] = {30505, 20166, 5646, -22016, -20267, 1851, -16870, -15522, -6478, 28568, -24933, -8558, 28891, 29410, -5672, -25610, 17628, -16913, -3658, -29191, -18246, 7697, 16690, -9899, 5905, -25983, 25695, 6411, -409, 1080, 8789, -23885, -15650, 27052, -8835, -13117, -11213, 12484, 30265, -20895, 29055, -28773, -22596, 15861, -29873, 27504, 21957, -13862};
const signed short dataArray2[N] = {28495, -8577, 25952, 32552, -21237, -11141, 13665, 4943, 18722, -1943, -7490, 23423, 26213, -2937, 12240, -23931, 9720, 32697, 28006, -15275, 24539, -26743, 25687, -5263, 31572, -8462, 17153, -10801, -665, 29112, 31568, -23133, 16087, 29233, 7190, -16073, -22331, -30392, 18281, -2016, -24649, 29272, 19468, 2718, 4672, 12042, 8434, -28150};
signed short resultArray[N] = {0};
signed short answerArray[N] = {0};

extern void printstr(char* str);
extern void int64ToHex(long num, char* str);
extern void int32ToHex(int num, char* str);
extern void clearCounters();
extern void printCounters();

int main(int argc, char** argv) {
int vl, avl = 41;
const signed short *ptr0 = dataArray0;
const signed short *ptr1 = dataArray1;
const signed short *ptr2 = dataArray2;
signed short *ptr3 = resultArray;
while(avl != 0) {
asm volatile ("vsetvli %0, %1, e16, m1, ta, ma"
: "=r"(vl)
: "r"(avl));
// asm volatile ("li t0, 0x1919");
asm volatile ("vle16.v v10, (%0)"
:
: "r"(ptr0));
asm volatile ("vle16.v v11, (%0)"
:
: "r"(ptr1));
asm volatile ("vle16.v v12, (%0)"
:
: "r"(ptr2));
// v12 = v10 * v11 + v12
asm volatile ("vmacc.vv v12, v10, v11");
asm volatile ("vse16.v v12, (%0)"
:
: "r"(ptr3));
ptr0 += vl;
ptr1 += vl;
ptr2 += vl;
ptr3 += vl;
avl -= vl;
}
int i;
for(i=0; i<41; i++) {
answerArray[i] = dataArray0[i] * dataArray1[i] + dataArray2[i];
}

_Bool correct = 1;
for(i=0; i<41; i++) {
if(resultArray[i] != answerArray[i]) {
correct = 0;
}
}
avl = 41;
ptr0 = dataArray0;
ptr1 = dataArray1;
ptr3 = resultArray;
while(avl != 0) {
asm volatile ("vsetvli %0, %1, e16, m1, ta, ma"
: "=r"(vl)
: "r"(avl));
asm volatile ("vle16.v v10, (%0)"
:
: "r"(ptr0));
asm volatile ("vle16.v v11, (%0)"
:
: "r"(ptr1));
// v11 = 0x1919 * v10 + v11
asm volatile ("vmacc.vx v11, %0, v10"
:
: "r"(0x1919));
asm volatile ("vse16.v v11, (%0)"
:
: "r"(ptr3));
ptr0 += vl;
ptr1 += vl;
ptr3 += vl;
avl -= vl;
}
for(i=0; i<41; i++) {
answerArray[i] = 0x1919 * dataArray0[i] + dataArray1[i];
}
for(i=0; i<41; i++) {
if(resultArray[i] != answerArray[i]) {
correct = 0;
}
}
return !correct;
}
180 changes: 180 additions & 0 deletions src/main/resources/applications_vector/vmacc_data.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
de7f6f4f
7f286560
d47bad0b
134f3561
f8694922
5b7fe2be
f4876665
a2852fd0
7fb925f8
c4556d66
97895fdb
eb716457
def27b54
d5cf4301
71b8fd67
a5a37b50
72313ed7
c1371c16
8948a8c5
f8204769
72589fb7
0a9e4c0c
2f0a1240
920a20f2
4ec67729
aa00160e
073bb0d5
c35ebe1a
6f98e6b2
de929e9b
72e270db
9bf6e9d8
bdef44dc
8df9f1b6
1e11b8ba
d9554132
9a811711
190b645f
0438fe67
a2b32255
69acc2de
ccc3dd7d
30c4d433
ae617639
8f9b717f
3df5a7bc
6b708b4f
c9da55c5
c97b968d
631ed593
ad63b990
5fe45cba
aa6a9232
d87b4186
d16f4d80
a18031a7
b1ac6bc2
3552b049
5275c256
496c7cfe
f964d4a6
8da3049b
975cbb15
cdacc4ad
add7e053
529c8f93
601d969c
14ce39a7
38847f38
9d8b8d44
2f01f180
3bc0ca10
ffffc3c0
ffffc404
ffffc448
ffffc358
ffffc48c
ffffc4d0
ffffc514
ffffc558
ffffc358
ffffc358
ffffc358
ffffc59c
6c637963
00203a65
736e690a
74657274
0000203a
00000000
74697845
646f6320
00203a65
00000000
54534e49
54435552
204e4f49
52444441
20535345
4153494d
4e47494c
61204445
43502074
0000203a
54534e49
54435552
204e4f49
45434341
46205353
544c5541
20746120
203a4350
00000000
00000000
454c4c49
204c4147
54534e49
54435552
204e4f49
50207461
00203a43
00000000
44414f4c
44444120
53534552
53494d20
47494c41
2044454e
50207461
00203a43
44414f4c
43434120
20535345
4c554146
74612054
3a435020
00000020
00000000
524f5453
44412045
53455244
494d2053
494c4153
44454e47
20746120
203a4350
00000000
00000000
524f5453
43412045
53534543
55414620
6120544c
43502074
0000203a
00000000
4c414345
5246204c
4d204d4f
444f4d2d
74612045
3a435020
00000020
00000000
4e4b4e55
204e574f
45435845
4f495450
7461204e
3a435020
00000020
00000000
4548430a
4d204b43
53554143
6e692045
4c545220
00000000
01010101
01010101
Loading
Loading