Added support for M extension

This commit is contained in:
felsabbagh3
2019-03-16 23:50:01 -04:00
parent e5f1ed1af4
commit c8af6f60ff
14 changed files with 1064 additions and 1028 deletions

4
TODO
View File

@@ -1,7 +1,7 @@
* Support for compressed
* Implement Matrix Multiplication * Implement Matrix Multiplication
* 1 warp independance * 1 warp independance
* automatic warp detection * automatic warp detection
* finish python compiler * finish python compiler
* print buffers * print buffers
* Support for compressed

View File

@@ -86,7 +86,6 @@ void Core::printStats() const {
cout << "Total steps: " << steps << endl; cout << "Total steps: " << steps << endl;
cout << "Total insts: " << insts << endl; cout << "Total insts: " << insts << endl;
for (unsigned i = 0; i < w.size(); ++i) { for (unsigned i = 0; i < w.size(); ++i) {
cout << "=== Warp " << i << " ===" << endl; cout << "=== Warp " << i << " ===" << endl;
w[i].printStats(); w[i].printStats();

View File

@@ -4,7 +4,7 @@
#ifndef __DEBUG_H #ifndef __DEBUG_H
#define __DEBUG_H #define __DEBUG_H
//#define USE_DEBUG 9 // #define USE_DEBUG 9
#ifdef USE_DEBUG #ifdef USE_DEBUG
#include <iostream> #include <iostream>
@@ -12,13 +12,13 @@
#define D(lvl, x) do { \ #define D(lvl, x) do { \
using namespace std; \ using namespace std; \
if ((lvl) <= USE_DEBUG) { \ if ((lvl) <= USE_DEBUG) { \
cerr << "DEBUG " << __FILE__ << ':' << dec << __LINE__ << ": " \ cout << "DEBUG " << __FILE__ << ':' << dec << __LINE__ << ": " \
<< x << endl; \ << x << endl; \
} \ } \
} while(0) } while(0)
#define D_RAW(x) do { \ #define D_RAW(x) do { \
std::cerr << x; \ std::cout << x; \
} while (0) } while (0)
#else #else

View File

@@ -84,7 +84,7 @@ void Instruction::executeOn(Warp &c) {
/* If I try to execute a privileged instruction in user mode, throw an /* If I try to execute a privileged instruction in user mode, throw an
exception 3. */ exception 3. */
if (instTable[op].privileged && !c.supervisorMode) { if (instTable[op].privileged && !c.supervisorMode) {
//std::cout << "INTERRUPT SUPERVISOR\n"; std::cout << "INTERRUPT SUPERVISOR\n";
c.interrupt(3); c.interrupt(3);
return; return;
} }
@@ -127,18 +127,30 @@ void Instruction::executeOn(Warp &c) {
stack<DomStackEntry> &domStack(c.domStack); stack<DomStackEntry> &domStack(c.domStack);
//std::cout << std::hex << "opcode: " << op << " func3: " << func3 << "\n"; //std::cout << std::hex << "opcode: " << op << " func3: " << func3 << "\n";
if (op == GPGPU) //std::cout << "OPCODE MATCHED GPGPU\n"; //if (op == GPGPU) //std::cout << "OPCODE MATCHED GPGPU\n";
// If this thread is masked out, don't execute the instruction, unless it's // If this thread is masked out, don't execute the instruction, unless it's
// a split or join. // a split or join.
// if (((predicated && !pReg[pred]) || !c.tmask[t]) && // if (((predicated && !pReg[pred]) || !c.tmask[t]) &&
// op != SPLIT && op != JOIN) continue; // op != SPLIT && op != JOIN) continue;
predicated = (op == GPGPU) && ((func3 == 7) || (func3 == 2));
bool split = (op == GPGPU) && (func3 == 2); bool split = (op == GPGPU) && (func3 == 2);
bool join = (op == GPGPU) && (func3 == 3); bool join = (op == GPGPU) && (func3 == 3);
if (((predicated && !reg[pred]) || !c.tmask[t]) && !split && !join) continue;
predicated = (op == GPGPU) && ((func3 == 7) || (func3 == 2));
// printf("Predicated: %d, split: %d, join: %d\n",predicated, split, join );
// printf("%d && ((%d) || (%d))\n",(op == GPGPU), (func3 == 7), (func3 == 2) );
// cout << "before " << op << " = " << GPGPU << "\n";
if (((predicated && !reg[pred]) || !c.tmask[t]) && !split && !join)
{
// cout << "about to continue\n";
continue;
}
// cout << "after\n";
++c.insts; ++c.insts;
@@ -148,78 +160,180 @@ void Instruction::executeOn(Warp &c) {
Word temp; Word temp;
Word data_read; Word data_read;
int op1, op2; int op1, op2;
bool m_exten;
// std::cout << "op = " << op << "\n";
// std::cout << "R_INST: " << R_INST << "\n";
switch (op) { switch (op) {
case NOP: case NOP:
//std::cout << "NOP_INST\n"; //std::cout << "NOP_INST\n";
break; break;
case R_INST: case R_INST:
//std::cout << "R_INST\n"; // std::cout << "R_INST\n";
switch (func3) m_exten = func7 & 0x1;
if (m_exten)
{ {
case 0: // std::cout << "FOUND A MUL/DIV\n";
if (func7)
{ switch (func3)
reg[rdest] = reg[rsrc[0]] - reg[rsrc[1]]; {
reg[rdest].trunc(wordSz); case 0:
} // MUL
else // cout << "MUL\n";
{ reg[rdest] = ((int) reg[rsrc[0]]) * ((int) reg[rsrc[1]]);
reg[rdest] = reg[rsrc[0]] + reg[rsrc[1]]; break;
reg[rdest].trunc(wordSz); case 1:
} // MULH
break; {
case 1: int64_t first = (int64_t) reg[rsrc[0]];
reg[rdest] = reg[rsrc[0]] << reg[rsrc[1]]; if (reg[rsrc[0]] & 0x80000000)
reg[rdest].trunc(wordSz); {
break; first = first | 0xFFFFFFFF00000000;
case 2: }
if ( int(reg[rsrc[0]]) < int(reg[rsrc[1]])) int64_t second = (int64_t) reg[rsrc[1]];
{ if (reg[rsrc[1]] & 0x80000000)
reg[rdest] = 1; {
} second = second | 0xFFFFFFFF00000000;
else }
{ // cout << "mulh: " << std::dec << first << " * " << second;
reg[rdest] = 0; uint64_t result = first * second;
} reg[rdest] = ( result >> 32) & 0xFFFFFFFF;
break; // cout << " = " << result << " or " << reg[rdest] << "\n";
case 3: }
if ( Word_u(reg[rsrc[0]]) < Word_u(reg[rsrc[1]])) break;
{ case 2:
reg[rdest] = 1; // MULHSU
} {
else int64_t first = (int64_t) reg[rsrc[0]];
{ if (reg[rsrc[0]] & 0x80000000)
reg[rdest] = 0; {
} first = first | 0xFFFFFFFF00000000;
break; }
case 4: int64_t second = (int64_t) reg[rsrc[1]];
reg[rdest] = reg[rsrc[0]] ^ reg[rsrc[1]]; reg[rdest] = (( first * second ) >> 32) & 0xFFFFFFFF;
break; }
case 5: break;
if (func7) case 3:
{ // MULHU
reg[rdest] = int(reg[rsrc[0]]) >> int(reg[rsrc[1]]); {
reg[rdest].trunc(wordSz); uint64_t first = (uint64_t) reg[rsrc[0]];
} uint64_t second = (uint64_t) reg[rsrc[1]];
else // cout << "MULHU\n";
{ reg[rdest] = (( first * second) >> 32) & 0xFFFFFFFF;
reg[rdest] = Word_u(reg[rsrc[0]]) >> Word_u(reg[rsrc[1]]); }
reg[rdest].trunc(wordSz); break;
} case 4:
break; // DIV
case 6: if (reg[rsrc[1]] == 0)
reg[rdest] = reg[rsrc[0]] | reg[rsrc[1]]; {
break; reg[rdest] = -1;
case 7: break;
reg[rdest] = reg[rsrc[0]] & reg[rsrc[1]]; }
break; // cout << "dividing: " << dec << ((int) reg[rsrc[0]]) << " / " << ((int) reg[rsrc[1]]);
default: reg[rdest] = ( (int) reg[rsrc[0]]) / ( (int) reg[rsrc[1]]);
cout << "ERROR: UNSUPPORTED R INST\n"; // cout << " = " << ((int) reg[rdest]) << "\n";
exit(1); break;
case 5:
// DIVU
if (reg[rsrc[1]] == 0)
{
reg[rdest] = -1;
break;
}
reg[rdest] = ((uint32_t) reg[rsrc[0]]) / ((uint32_t) reg[rsrc[1]]);
break;
case 6:
// REM
if (reg[rsrc[1]] == 0)
{
reg[rdest] = reg[rsrc[0]];
break;
}
reg[rdest] = ((int) reg[rsrc[0]]) % ((int) reg[rsrc[1]]);
break;
case 7:
// REMU
if (reg[rsrc[1]] == 0)
{
reg[rdest] = reg[rsrc[0]];
break;
}
reg[rdest] = ((uint32_t) reg[rsrc[0]]) % ((uint32_t) reg[rsrc[1]]);
break;
default:
cout << "unsupported MUL/DIV instr\n";
exit(1);
}
}
else
{
// std::cout << "NORMAL R-TYPE\n";
switch (func3)
{
case 0:
if (func7)
{
reg[rdest] = reg[rsrc[0]] - reg[rsrc[1]];
reg[rdest].trunc(wordSz);
}
else
{
reg[rdest] = reg[rsrc[0]] + reg[rsrc[1]];
reg[rdest].trunc(wordSz);
}
break;
case 1:
reg[rdest] = reg[rsrc[0]] << reg[rsrc[1]];
reg[rdest].trunc(wordSz);
break;
case 2:
if ( int(reg[rsrc[0]]) < int(reg[rsrc[1]]))
{
reg[rdest] = 1;
}
else
{
reg[rdest] = 0;
}
break;
case 3:
if ( Word_u(reg[rsrc[0]]) < Word_u(reg[rsrc[1]]))
{
reg[rdest] = 1;
}
else
{
reg[rdest] = 0;
}
break;
case 4:
reg[rdest] = reg[rsrc[0]] ^ reg[rsrc[1]];
break;
case 5:
if (func7)
{
reg[rdest] = int(reg[rsrc[0]]) >> int(reg[rsrc[1]]);
reg[rdest].trunc(wordSz);
}
else
{
reg[rdest] = Word_u(reg[rsrc[0]]) >> Word_u(reg[rsrc[1]]);
reg[rdest].trunc(wordSz);
}
break;
case 6:
reg[rdest] = reg[rsrc[0]] | reg[rsrc[1]];
break;
case 7:
reg[rdest] = reg[rsrc[0]] & reg[rsrc[1]];
break;
default:
cout << "ERROR: UNSUPPORTED R INST\n";
exit(1);
}
} }
break; break;
case L_INST: case L_INST:
//std::cout << "L_INST\n"; //std::cout << "L_INST\n";
memAddr = ((reg[rsrc[0]] + immsrc) & 0xFFFFFFFC); memAddr = ((reg[rsrc[0]] + immsrc) & 0xFFFFFFFC);

View File

@@ -1,6 +1,6 @@
COMP = /opt/riscv/bin/riscv32-unknown-elf-gcc COMP = /opt/riscv/bin/riscv32-unknown-elf-gcc
CC_FLAGS = -march=rv32i -mabi=ilp32 -O0 -Wl,-Bstatic,-T,linker.ld -ffreestanding -nostdlib CC_FLAGS = -march=rv32im -mabi=ilp32 -O0 -Wl,-Bstatic,-T,linker.ld -ffreestanding -nostdlib
DMP = /opt/riscv/bin/riscv32-unknown-elf-objdump DMP = /opt/riscv/bin/riscv32-unknown-elf-objdump
CPY = /opt/riscv/bin/riscv32-unknown-elf-objcopy CPY = /opt/riscv/bin/riscv32-unknown-elf-objcopy

View File

@@ -10,20 +10,31 @@ void matAddition (unsigned, unsigned);
#include "./lib/lib.h" #include "./lib/lib.h"
// unsigned x[] = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}; // unsigned x[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1 , 1 , 1 , 1 , 1 };
// unsigned y[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; // unsigned y[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
// unsigned z[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // unsigned z[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned x[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1 , 1 , 1 , 1 , 1 };
unsigned y[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
unsigned z[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// unsigned x[] = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
// unsigned y[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
// unsigned z[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
#define NUM_WARPS 2 unsigned x[] = {1,0,0,0,
#define NUM_THREADS 8 0,2,0,0,
0,0,3,0,
0,0,0,4};
unsigned y[] = {10,0,0,0,
0,10,0,0,
0,0,10,0,
0,0,0,10};
unsigned z[] = {0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0};
#define MAT_DIM 4
#define NUM_WARPS MAT_DIM
#define NUM_THREADS MAT_DIM
int main() int main()
{ {
@@ -33,20 +44,21 @@ int main()
queue_initialize(q + i); queue_initialize(q + i);
} }
createWarps(NUM_WARPS, NUM_THREADS, matAddition, x, y, z); createWarps(NUM_WARPS, NUM_THREADS, matAddition, (void *) x, (void *) y, (void *) z);
wait_for_done(NUM_WARPS); wait_for_done(NUM_WARPS);
print_consol("-------------------------\n"); print_consol("-------------------------\n");
print_consol("FINAL Z\n"); print_consol("FINAL Z\n");
for (int i = 0; i < 16; i++)
for (int j = 0; j < (MAT_DIM * MAT_DIM); j++)
{ {
int_print(i); if ((j % MAT_DIM) == 0) print_consol("\n");
print_consol(": "); int_print(z[j]);
int_print(z[i]); print_consol(" ");
print_consol("\n");
} }
print_consol("-------------------------------\n");
print_consol("\n-------------------------------\n");
return 0; return 0;
} }
@@ -54,16 +66,22 @@ int main()
void matAddition(unsigned tid, unsigned wid) void matAddition(unsigned tid, unsigned wid)
{ {
unsigned * x_ptr = get_1st_arg(); unsigned * x_ptr = (unsigned *) get_1st_arg();
unsigned * y_ptr = get_2nd_arg(); unsigned * y_ptr = (unsigned *) get_2nd_arg();
unsigned * z_ptr = get_3rd_arg(); unsigned * z_ptr = (unsigned *) get_3rd_arg();
unsigned i = (wid * NUM_THREADS) + tid;
__if((i < 11)) unsigned total = 0;
z_ptr[i] = x_ptr[i] + y_ptr[i]; for (unsigned place = 0; place < MAT_DIM; place++)
__else {
__end_if unsigned x_i = (wid * MAT_DIM) + place;
unsigned y_i = (MAT_DIM * place) + tid;
total += (x_ptr[x_i] * y_ptr[y_i]);
}
int final_i = (wid * MAT_DIM) + tid;
z_ptr[final_i] = total;
return; return;

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -4,7 +4,7 @@
:100020009303050013051000635C75001301018044 :100020009303050013051000635C75001301018044
:10003000130305006B500300130515006FF0DFFE7E :10003000130305006B500300130515006FF0DFFE7E
:1000400013010F0013050000930F0600938D0300AA :1000400013010F0013050000930F0600938D0300AA
:10005000EBE0BF01170500001305854B6B40050061 :10005000EBE0BF01170500001305C54B6B40050021
:10006000B708010023A0B800678000001703000054 :10006000B708010023A0B800678000001703000054
:10007000130303FA6B00030067800000130141FFC4 :10007000130303FA6B00030067800000130141FFC4
:10008000232011002322B100834505006388050069 :10008000232011002322B100834505006388050069
@@ -13,145 +13,133 @@
:1000B000232011002322B10093050503EFF05FFA1E :1000B000232011002322B10093050503EFF05FFA1E
:1000C00083200100832541001301C10067800000E7 :1000C00083200100832541001301C10067800000E7
:1000D000130101FE232E1100232C810013040102C1 :1000D000130101FE232E1100232C810013040102C1
:1000E000232604FE6F00C0040327C4FE9307070005 :1000E000232604FE6F0000030327C4FE9307406528
:1000F00093973700B387E74093972700B387E7408C :1000F0003307F702B707008193870722B307F7009A
:10010000139747003307F74093172700138707001B :1001000013850700EF00401E8327C4FE9387170066
:10011000B707008193874724B307F70013850700CB :100110002326F4FE0327C4FE93077000E3D6E7FC12
:10012000EF00401C8327C4FE938717002326F4FEAC :10012000B70700819387471D3707008113074715DD
:100130000327C4FE93077000E3D8E7FAB7070081EE :10013000B706008193864611370600801306461FD6
:100140009387871F3707008113078717B70600813A :100140009305400013054000EF00005913054000DF
:1001500093868613370600801306062193058000D8 :10015000EF000068B707008113850704EFF01FF276
:1001600013052000EF00406013052000EF00007130 :10016000B70700811385C705EFF05FF1232404FE74
:10017000B707008113850704EFF05FF0B707008130 :100170006F004005832784FE93F7370063980700DC
:100180001385C705EFF09FEF232404FE6F004005A1 :10018000B707008113858706EFF05FEFB70700819F
:10019000832784FE13850700EF00002BB70700813B :10019000032784FE131727009387471DB307F70033
:1001A00013858706EFF09FEDB7070081032784FED4 :1001A00083A7070013850700EF00402AB7070081E7
:1001B000131727009387871FB307F70083A707004C :1001B0001385C706EFF09FEC832784FE9387170013
:1001C00013850700EF004028B70700811385C70695 :1001C0002324F4FE032784FE9307F000E3D4E7FA28
:1001D000EFF0DFEA832784FE938717002324F4FEE1 :1001D000B707008113850707EFF05FEA9307000078
:1001E000032784FE9307F000E3D4E7FAB707008102 :1001E000138507008320C10103248101130101024B
:1001F00013850707EFF09FE89307000013850700BA :1001F00067800000130101FC232E1102232C8102D1
:100200008320C101032481011301010267800000E2 :10020000130401042326A4FC2324B4FCEF0080641F
:10021000130101FC232E1102232C8102130401047B :100210002322A4FEEF0080662320A4FEEF00806866
:100220002326A4FC2324B4FCEF00C06E2326A4FEE6 :10022000232EA4FC232604FE232404FE6F000007D3
:10023000EF00C0702324A4FEEF00C0722322A4FEAE :10023000832784FC93972700032784FEB307F700E6
:10024000832784FC939737000327C4FCB307F70088 :10024000232CF4FC832784FE939727000327C4FC08
:100250002320F4FE832704FE93B7B70093C717004B :10025000B307F700232AF4FC832784FD9397270034
:10026000A30FF4FC8347F4FD138F0700B70700804A :10026000032744FEB307F70003A70700832744FDD5
:10027000938F872C6B200F007B70FF01832704FE78 :1002700093972700832604FEB387F60083A7070021
:10028000939727000327C4FEB307F70083A6070050 :10028000B307F7020327C4FEB307F7002326F4FEE3
:10029000832704FE93972700032784FEB307F70004 :10029000832784FE938717002324F4FE032784FE1C
:1002A00003A70700832704FE93972700032644FE35 :1002A00093073000E3F6E7F8832784FC13972700D1
:1002B000B307F6003387E60023A0E700B707008006 :1002B0008327C4FCB307F7002328F4FC832704FD3D
:1002C000138EC72C67000E00130000006B30000077 :1002C000939727000327C4FDB307F7000327C4FE55
:1002D000130000008320C1030324810313010104E0 :1002D00023A0E700130000008320C103032481034F
:1002E0006780000093020500130300009303700071 :1002E000130101046780000093020500130300005E
:1002F00023A0620023A2620023A4620023A672004E :1002F0009303700023A0620023A2620023A4620083
:1003000023A86200678000009302050003A3820017 :1003000023A6720023A86200678000009302050004
:100310001303130023A462001383420183AE42003F :1003100003A382001303130023A46200138342018A
:1003200093935E003303730003AE05002320C301E3 :1003200083AE420093935E003303730003AE050077
:1003300003AE45002322C30103AE85002324C3017D :100330002320C30103AE45002322C30103AE850081
:1003400003AEC5002326C30103AE05012328C30164 :100340002324C30103AEC5002326C30103AE050168
:1003500003AE4501232AC30103AE8501232CC3014B :100350002328C30103AE4501232AC30103AE85014F
:1003600003AEC501232EC301938E1E00130F20037D :10036000232CC30103AEC501232EC301938E1E00AF
:100370006394EE01930E000023A2D2016780000077 :10037000130F20036394EE01930E000023A2D20119
:100380009302050003A382001303F3FF23A462007A :10038000678000009302050003A382001303F3FFBC
:100390001383420183AE0200930F2003138F0E00DC :1003900023A462001383420183AE0200930F200363
:1003A000130F1F006314FF01130F000023A0E201CD :1003A000138F0E00130F1F006314FF01130F0000C3
:1003B00093935E0033037300032E030023A0C50153 :1003B00023A0E20193935E0033037300032E030036
:1003C000032E430023A2C501032E830023A4C501ED :1003C00023A0C501032E430023A2C501032E8300F1
:1003D000032EC30023A6C501032E030123A8C501D4 :1003D00023A4C501032EC30023A6C501032E0301D8
:1003E000032E430123AAC501032E830123ACC501BB :1003E00023A8C501032E430123AAC501032E8301BF
:1003F000032EC30123AEC5016780000093020500F0 :1003F00023ACC501032EC30123AEC50167800000F5
:1004000003A3820013050000130E200363146E0083 :100400009302050003A3820013050000130E2003CE
:1004100013051500678000009302050003A3820006 :1004100063146E0013051500678000009302050049
:1004200013050000130E000063146E001305150081 :1004200003A3820013050000130E000063146E0086
:10043000678000009302050003A3C20083A30201AA :1004300013051500678000009302050003A3C200A6
:1004400033B5630067800000130101FD232611020C :1004400083A3020133B5630067800000130101FD3F
:100450002324810213040103232EA4FC0327C4FDDB :10045000232611022324810213040103232EA4FC6A
:100460009307F00063E4E702B70700810327C4FDA8 :100460000327C4FD9307F00063E4E702B7070081A8
:10047000131727009387871BB307F70083A707008D :100470000327C4FD1317270093874719B307F70015
:1004800013850700EFF09FBF6F004007930700023E :1004800083A7070013850700EFF05FBF6F004007E9
:100490002326F4FEA30504FE8327C4FE9387C7FF2B :10049000930700022326F4FEA30504FE8327C4FE6F
:1004A0000327C4FDB357F70093F7F7002322F4FEA8 :1004A0009387C7FF0327C4FDB357F70093F7F700FF
:1004B000832744FE6386070093071000A305F4FE1C :1004B0002322F4FE832744FE63860700930710007F
:1004C0008347B4FE63820702B7070081032744FE17 :1004C000A305F4FE8347B4FE63820702B7070081E9
:1004D000131727009387871BB307F70083A707002D :1004D000032744FE1317270093874719B307F70034
:1004E00013850700EFF09FB98327C4FE9387C7FFEA :1004E00083A7070013850700EFF05FB98327C4FED9
:1004F0002326F4FE8327C4FEE340F0FA8320C102E2 :1004F0009387C7FF2326F4FE8327C4FEE340F0FA68
:10050000032481021301010367800000130101FD30 :100500008320C102032481021301010367800000DC
:1005100023261102232481022322A10313040103B1 :10051000130101FD23261102232481022322A103BA
:1005200013070D009307070093973700B387E74041 :100520001304010313070D00930740653307F70217
:1005300093972700B387E740139747003307F740A7 :10053000B707008193870722B307F70013850700E9
:100540009317270013870700B70700819387472475 :10054000EFF0DFED930705006380070213070D004E
:10055000B307F70013850700EFF01FEC93070500C2 :10055000B73700819387074CB307F70013071000E4
:1005600063820704B70700811385470DEFF01FB1C1 :100560002380E7007300000013070D009307406528
:1005700093070D0013850700EFF01FEDB70700810B :100570003307F702B707008193870722B307F70015
:100580001385C70DEFF09FAF13070D00B73700813C :10058000130704FD9305070013850700EFF09FDFB5
:100590009387474EB307F700130710002380E70047 :10059000832784FD13810700032544FD832504FD83
:1005A0007300000013070D009307070093973700AF :1005A0000326C4FD832604FE032744FE832784FE1E
:1005B000B387E74093972700B387E7401397470037 :1005B0000328C4FEEFF09FA57300000013000000A5
:1005C0003307F7409317270013870700B707008109 :1005C0008320C10203248102032D41021301010390
:1005D00093874724B307F700130704FD930507002B :1005D00067800000130101FC232E1102232C8102ED
:1005E00013850700EFF0DFD9832784FD138107000F :1005E0001304010493090100232604FE6F00800810
:1005F000032544FD832504FD0326C4FD832604FE54 :1005F0000327C4FE930740653307F702B70700815E
:10060000032744FE832784FE0328C4FEEFF01FA0C7 :1006000093870722B307F70013850700EFF01FE178
:1006100073000000130000008320C1020324810244 :1006100093070500639A07040327C4FE9307406508
:10062000032D41021301010367800000130101FC47 :100620003307F702B707008193870722B307F70064
:10063000232E1102232C81021304010493090100CB :100630001307C4FC9305070013850700EFF09FD450
:10064000232604FE6F00000C0327C4FE9307070057 :10064000832744FD13810700032504FD8325C4FC93
:1006500093973700B387E74093972700B387E74026 :10065000032684FD8326C4FD032704FE832744FE6E
:10066000139747003307F7409317270013870700B6 :10066000032884FEEFF09FA08327C4FE9387170022
:10067000B707008193874724B307F7001385070066 :100670002326F4FE0327C4FE93076000E3DAE7F6BF
:10068000EFF09FD993070500639807060327C4FE80 :1006800013810900130000008320C10303248103A8
:100690009307070093973700B387E74093972700A6 :100690001301010467800000130101FD232681027C
:1006A000B387E740139747003307F74093172700B6 :1006A00013040103232EA4FC232604FE6F00000183
:1006B00013870700B707008193874724B307F70024 :1006B0008327C4FE938717002326F4FE0327C4FE76
:1006C0001307C4FC9305070013850700EFF05FCB09 :1006C0008327C4FDE346F7FE130000000324C102A4
:1006D000832744FD13810700032504FD8325C4FC03 :1006D0001301010367800000130101FA232E1104A6
:1006E000032684FD8326C4FD032704FE832744FEDE :1006E000232C810413040106232EA4FA232CB4FA2C
:1006F000032884FEEFF09F978327C4FE938717009B :1006F000232AC4FA2328D4FA2326E4FA2324F4FA7A
:100700002326F4FE0327C4FE93076000E3DEE7F22E :1007000013090100232604FE232404FE6F00C00900
:1007100013810900130000008320C1030324810317 :10071000B709FFFF33013101832784FE2324F4FC52
:100720001301010467800000130101FD23268102EB :10072000832784FB2326F4FC930701002328F4FC91
:1007300013040103232EA4FC232604FE6F000001F2 :10073000832744FB232AF4FC832704FB232CF4FCAB
:100740008327C4FE938717002326F4FE0327C4FEE5 :100740008327C4FA232EF4FC832784FA2320F4FEA3
:100750008327C4FDE346F7FE130000000324C10213 :100750008327C4FE2322F4FE0327C4FE93074065CB
:100760001301010367800000130101FA232E110415 :100760003307F702B707008193870722B307F70023
:10077000232C810413040106232EA4FA232CB4FA9B :10077000130784FC9305070013850700EFF01FB9EA
:10078000232AC4FA2328D4FA2326E4FA2324F4FAE9 :100780008327C4FE938717002326F4FE0327C4FEA5
:1007900013090100232604FE232404FE6F00800BAE :100790009307600063D4E700232604FE832784FECA
:1007A000B709FFFF33013101832784FE2324F4FCC2 :1007A000938717002324F4FE032784FE8327C4FBCA
:1007B000832784FB2326F4FC930701002328F4FC01 :1007B000E360F7F613010900EFF0DFE1130000003A
:1007C000832744FB232AF4FC832704FB232CF4FC1B :1007C0008320C10503248105130101066780000011
:1007D0008327C4FA232EF4FC832784FA2320F4FE13 :1007D000130101FD2326810213040103232EA4FC2F
:1007E0008327C4FE2322F4FE0327C4FE93070700D9 :1007E000A30704FE6F00000593071000A307F4FEA3
:1007F00093973700B387E74093972700B387E74085 :1007F000232404FE6F0040038347F4FE3737008153
:10080000139747003307F740931727001387070014 :100800009306074C032784FE3387E600034707005F
:10081000B707008193874724B307F700130784FCC9 :10081000B3F7E700B337F000A307F4FE832784FEA5
:100820009305070013850700EFF01FAE8327C4FE72 :10082000938717002324F4FE832784FE0327C4FD47
:10083000938717002326F4FE0327C4FE9307600066 :10083000E3E4E7FC8347F4FE93C7170093F7F70F51
:1008400063D4E700232604FE832784FE93871700E2 :10084000E39407FA130000000324C102130101031B
:100850002324F4FE032784FE8327C4FBE362F7F41A :1008500067800000130101FF23268100232471011A
:1008600013010900EFF09FDC130000008320C10595 :100860001304010193870B00138507000324C100C3
:10087000032481051301010667800000130101FDB7 :10087000832B81001301010167800000130101FF38
:10088000232611022324810213040103232EA4FC36 :1008800023268100232481011304010193070C0016
:10089000B70700811385070EEFF04FFEA30704FE94 :10089000138507000324C100032C8100130101010B
:1008A0006F00000593071000A307F4FE232404FE45 :1008A00067800000130101FF2326810023249101AA
:1008B0006F0040038347F4FE373700819306474EAD :1008B0001304010193870C00138507000324C10072
:1008C000032784FE3387E60003470700B3F7E700FA :0C08C000832C81001301010167800000FF
:1008D000B337F000A307F4FE832784FE9387170045
:1008E0002324F4FE832784FE0327C4FDE3E4E7FC0E
:1008F0008347F4FE93C7170093F7F70FE39407FAC3
:10090000130000008320C1020324810213010103AC
:1009100067800000130101FF232681002324710159
:100920001304010193870B00138507000324C10002
:10093000832B81001301010167800000130101FF77
:1009400023268100232481011304010193070C0055
:10095000138507000324C100032C8100130101014A
:1009600067800000130101FF2326810023249101E9
:100970001304010193870C00138507000324C100B1
:0C098000832C810013010101678000003E
:02000004810079 :02000004810079
:10000000300000003100000032000000330000002A :10000000300000003100000032000000330000002A
:10001000340000003500000036000000370000000A :10001000340000003500000036000000370000000A
@@ -159,31 +147,29 @@
:10003000630000006400000065000000660000002E :10003000630000006400000065000000660000002E
:100040002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DE0 :100040002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DE0
:100050002D2D2D2D2D2D2D2D2D0A000046494E41E3 :100050002D2D2D2D2D2D2D2D2D0A000046494E41E3
:100060004C205A0A000000003A2000000A0000005C :100060004C205A0A000000000A0000002000000096
:100070002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DB0 :100070000A2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DD3
:100080002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0AC3 :100080002D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2DA0
:1000900000000000300000003100000032000000CD :100090000A000000300000003100000032000000C3
:1000A000330000003400000035000000360000007E :1000A000330000003400000035000000360000007E
:1000B0003700000038000000390000006100000037 :1000B0003700000038000000390000006100000037
:1000C00062000000630000006400000065000000A2 :1000C00062000000630000006400000065000000A2
:1000D00066000000646F6E653A2000000A000000B0 :0200D0006600C8
:1000E00061626F757420746F207761697420666F28 :1000D4000000008104000081080000810C00008100
:0800F0007220646F6E650A00C6 :1000E4001000008114000081180000811C000081B0
:1000F8000000008104000081080000810C000081DC :1000F4002000008124000081280000812C00008160
:100108001000008114000081180000811C0000818B :100104003000008134000081380000813C0000810F
:100118002000008124000081280000812C0000813B :1001140001000000000000000000000000000000DA
:100128003000008134000081380000813C000081EB :1001240000000000020000000000000000000000C9
:1001380001000000010000000100000001000000B3 :1001340000000000000000000300000000000000B8
:1001480001000000010000000100000001000000A3 :1001440000000000000000000000000004000000A7
:100158000100000001000000010000000100000093 :100154000A00000000000000000000000000000091
:100168000100000001000000010000000100000083 :10016400000000000A000000000000000000000081
:100178000000000001000000020000000300000071 :1001740000000000000000000A0000000000000071
:100188000400000005000000060000000700000051 :100184000000000000000000000000000A00000061
:1001980008000000090000000A0000000B00000031 :1001940094000081980000819C000081A0000081EF
:1001A8000C0000000D0000000E0000000F00000011 :1001A400A4000081A8000081AC000081B00000819F
:1001B80094000081980000819C000081A0000081CB :1001B400B4000081B8000081BC000081C00000814F
:1001C800A4000081A8000081AC000081B00000817B :1001C400C4000081C8000081CC000081D0000081FF
:1001D800B4000081B8000081BC000081C00000812B
:1001E800C4000081C8000081CC000081D0000081DB
:040000058000000077 :040000058000000077
:00000001FF :00000001FF

View File

@@ -1,3 +0,0 @@
/opt/riscv/bin/riscv32-unknown-elf-gcc -march=rv32i -mabi=ilp32 -O0 -Wl,-Bstatic,-T,linker.ld -ffreestanding -nostdlib queue.c -o queue.elf
/opt/riscv/bin/riscv32-unknown-elf-objdump -D queue.elf > queue.dump
/opt/riscv/bin/riscv32-unknown-elf-objcopy -O ihex queue.elf queue.hex

View File

@@ -1,8 +1,8 @@
#include "lib.h" #include "lib.h"
extern void createThreads(unsigned, unsigned, unsigned, unsigned *, unsigned *, unsigned *, unsigned); extern void createThreads(unsigned, unsigned, unsigned, void *, void *, void *, unsigned);
extern void wspawn(unsigned, unsigned, unsigned, unsigned *, unsigned *, unsigned *, unsigned); extern void wspawn(unsigned, unsigned, unsigned, void *, void *, void *, unsigned);
extern void print_consol(char *); extern void print_consol(char *);
extern void printc(char); extern void printc(char);
@@ -33,9 +33,9 @@ void reschedule_warps()
if (queue_isEmpty(q+curr_warp)) if (queue_isEmpty(q+curr_warp))
{ {
print_consol("done: "); // print_consol("done: ");
int_print(curr_warp); // int_print(curr_warp);
print_consol("\n"); // print_consol("\n");
done[curr_warp] = true; done[curr_warp] = true;
ECALL; ECALL;
} }
@@ -75,7 +75,7 @@ void sleep(int t)
void createWarps(unsigned num_Warps, unsigned num_threads, FUNC, unsigned * x_ptr, unsigned * y_ptr, unsigned * z_ptr) void createWarps(unsigned num_Warps, unsigned num_threads, FUNC, void * x_ptr, void * y_ptr, void * z_ptr)
{ {
asm __volatile__("addi s2, sp, 0"); asm __volatile__("addi s2, sp, 0");
int warp = 0; int warp = 0;
@@ -108,7 +108,6 @@ void createWarps(unsigned num_Warps, unsigned num_threads, FUNC, unsigned * x_pt
void wait_for_done(unsigned num_wait) void wait_for_done(unsigned num_wait)
{ {
print_consol("about to wait for done\n");
bool temp = false; bool temp = false;
while (!temp) while (!temp)
{ {
@@ -121,19 +120,19 @@ void wait_for_done(unsigned num_wait)
} }
unsigned * get_1st_arg(void) void * get_1st_arg(void)
{ {
register unsigned *ret asm("s7"); register void *ret asm("s7");
return ret; return ret;
} }
unsigned * get_2nd_arg(void) void * get_2nd_arg(void)
{ {
register unsigned *ret asm("s8"); register void *ret asm("s8");
return ret; return ret;
} }
unsigned * get_3rd_arg(void) void * get_3rd_arg(void)
{ {
register unsigned *ret asm("s9"); register void *ret asm("s9");
return ret; return ret;
} }

View File

@@ -35,14 +35,14 @@ static bool done[] = {false, false, false, false, false, false, false};
static int main_sp[1]; static int main_sp[1];
#define FUNC void (func)(unsigned, unsigned) #define FUNC void (func)(unsigned, unsigned)
void createWarps(unsigned num_Warps, unsigned num_threads, FUNC, unsigned *, unsigned *, unsigned *); void createWarps(unsigned num_Warps, unsigned num_threads, FUNC, void *, void *, void *);
void reschedule_warps(void); void reschedule_warps(void);
void int_print(unsigned); void int_print(unsigned);
void wait_for_done(unsigned); void wait_for_done(unsigned);
unsigned * get_1st_arg(void); void * get_1st_arg(void);
unsigned * get_2nd_arg(void); void * get_2nd_arg(void);
unsigned * get_3rd_arg(void); void * get_3rd_arg(void);
void sleep(int); void sleep(int);

View File

@@ -15,9 +15,9 @@ typedef struct Job_t
unsigned n_threads; unsigned n_threads;
unsigned base_sp; unsigned base_sp;
unsigned func_ptr; unsigned func_ptr;
unsigned * x; void * x;
unsigned * y; void * y;
unsigned * z; void * z;
unsigned assigned_warp; unsigned assigned_warp;
} Job; } Job;

View File

@@ -113,3 +113,31 @@ echo ./riscv_tests/rv32ui-p-xor.hex >> results.txt
echo ./riscv_tests/rv32ui-p-xori.hex >> results.txt echo ./riscv_tests/rv32ui-p-xori.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32ui-p-xori.hex -s -b >> results.txt ./harptool -E -a rv32i --core ./riscv_tests/rv32ui-p-xori.hex -s -b >> results.txt
echo ./riscv_tests/rv32um-p-div.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32um-p-div.hex -s -b >> results.txt
echo ./riscv_tests/rv32um-p-divu.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32um-p-divu.hex -s -b >> results.txt
echo ./riscv_tests/rv32um-p-mul.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32um-p-mul.hex -s -b >> results.txt
echo ./riscv_tests/rv32um-p-mulh.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32um-p-mulh.hex -s -b >> results.txt
echo ./riscv_tests/rv32um-p-mulhsu.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32um-p-mulhsu.hex -s -b >> results.txt
echo ./riscv_tests/rv32um-p-mulhu.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32um-p-mulhu.hex -s -b >> results.txt
echo ./riscv_tests/rv32um-p-rem.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32um-p-rem.hex -s -b >> results.txt
echo ./riscv_tests/rv32um-p-remu.hex >> results.txt
./harptool -E -a rv32i --core ./riscv_tests/rv32um-p-remu.hex -s -b >> results.txt