First (not quite working) floating point benchmark.

This commit is contained in:
Chad Kersey
2013-10-06 13:40:05 -04:00
parent 89e66d64f2
commit 0e0aa64e74
6 changed files with 45 additions and 10 deletions

View File

@@ -159,6 +159,9 @@ void Instruction::executeOn(Core &c) {
case SHL: reg[rdest] = reg[rsrc[0]] << reg[rsrc[1]]; case SHL: reg[rdest] = reg[rsrc[0]] << reg[rsrc[1]];
reg[rdest].trunc(wordSz); reg[rdest].trunc(wordSz);
break; break;
case SHR: reg[rdest] = reg[rsrc[0]] >> reg[rsrc[1]];
reg[rdest].trunc(wordSz);
break;
case MOD: if (reg[rsrc[1]] == 0) throw DomainException(); case MOD: if (reg[rsrc[1]] == 0) throw DomainException();
reg[rdest] = reg[rsrc[0]] % reg[rsrc[1]]; reg[rdest] = reg[rsrc[0]] % reg[rsrc[1]];
break; break;

View File

@@ -94,9 +94,9 @@ static uint64_t readParenExpression(const string &s, const map<string, Word> &d,
exit(1); exit(1);
} }
int lexerBits; int lexerBytes;
Obj *AsmReader::read(std::istream &input) { Obj *AsmReader::read(std::istream &input) {
lexerBits = wordSize; lexerBytes = wordSize;
FlexLexer *f = new yyFlexLexer(&input); FlexLexer *f = new yyFlexLexer(&input);
Obj *o = new Obj(); Obj *o = new Obj();
std::vector<Chunk>::reverse_iterator cur; std::vector<Chunk>::reverse_iterator cur;

View File

@@ -16,14 +16,14 @@
#include "include/asm-tokens.h" #include "include/asm-tokens.h"
#include "include/harpfloat.h" #include "include/harpfloat.h"
extern int lexerBits; extern int lexerBytes;
static int64_t read_number(const char *s) { static int64_t read_number(const char *s) {
while (!isdigit(*s) && *s != '-' && *s != '+') s++; while (!isdigit(*s) && *s != '-' && *s != '+') s++;
if (strchr(s, 'f') || strchr(s, '.')) { if (strchr(s, 'f') || strchr(s, '.')) {
double d; double d;
sscanf(s, "%f", &d); sscanf(s, "%f", &d);
return Harp::Word_u(Harp::Float(d, lexerBits)); return Harp::Word_u(Harp::Float(d, lexerBytes));
} else { } else {
long long u; long long u;
sscanf(s, "%lli", &u); sscanf(s, "%lli", &u);

View File

@@ -4,11 +4,11 @@ HARPEM = ../harptool -E
HARPDIS = ../harptool -D HARPDIS = ../harptool -D
4BARCH = 4b16/16/2 4BARCH = 4b16/16/2
all: simple.bin sieve.bin 2thread.bin simple.4b.bin sieve.4b.bin 2thread.4b.bin bubble.bin bubble.4b.bin all: simple.bin sieve.bin 2thread.bin simple.4b.bin sieve.4b.bin 2thread.4b.bin bubble.bin bubble.4b.bin dotprod.bin dotprod.4b.bin
run: simple.out sieve.out 2thread.out simple.4b.out sieve.4b.out 2thread.4b.out bubble.out bubble.4b.out run: simple.out sieve.out 2thread.out simple.4b.out sieve.4b.out 2thread.4b.out bubble.out bubble.4b.out dotprod.out dotprod.4b.out
disas: simple.d sieve.d 2thread.d simple.4b.d sieve.4b.d 2thread.4b.d bubble.d bubble.4b.d disas: simple.d sieve.d 2thread.d simple.4b.d sieve.4b.d 2thread.4b.d bubble.d bubble.4b.d dotprod.d dotprod.4b.d
%.4b.out : %.4b.bin %.4b.out : %.4b.bin
$(HARPEM) -a $(4BARCH) -c $< > $@ $(HARPEM) -a $(4BARCH) -c $< > $@
@@ -34,12 +34,18 @@ simple.bin : boot.HOF lib.HOF simple.HOF
sieve.bin : boot.HOF lib.HOF sieve.HOF sieve.bin : boot.HOF lib.HOF sieve.HOF
$(HARPLD) -o $@ $^ $(HARPLD) -o $@ $^
dotprod.bin : boot.HOF lib.HOF dotprod.HOF
$(HARPLD) -o $@ $^
simple.4b.bin : boot.4b.HOF lib.4b.HOF simple.4b.HOF simple.4b.bin : boot.4b.HOF lib.4b.HOF simple.4b.HOF
$(HARPLD) --arch $(4BARCH) -o $@ $^ $(HARPLD) --arch $(4BARCH) -o $@ $^
sieve.4b.bin : boot.4b.HOF lib.4b.HOF sieve.4b.HOF sieve.4b.bin : boot.4b.HOF lib.4b.HOF sieve.4b.HOF
$(HARPLD) --arch $(4BARCH) -o $@ $^ $(HARPLD) --arch $(4BARCH) -o $@ $^
dotprod.4b.bin : boot.4b.HOF lib.4b.HOF sieve.4b.HOF
$(HARPLD) --arch $(4BARCH) -o $@ $^
%.4b.bin : %.4b.HOF %.4b.bin : %.4b.HOF
$(HARPLD) --arch $(4BARCH) -o $@ $< $(HARPLD) --arch $(4BARCH) -o $@ $<

View File

@@ -12,7 +12,13 @@
.perm x .perm x
.entry .entry
.global .global
entry: /* . . . */ entry: ldi %r0, array_a;
ldi %r1, array_b;
ldi %r2, #1;
jali %r5, dotprod
ori %r7, %r0, #0;
jali %r5, printhex;
trap; trap;
@@ -20,14 +26,16 @@ entry: /* . . . */
length in r2 */ length in r2 */
dotprod: ldi %r3, #0; dotprod: ldi %r3, #0;
dploop: ld %r4, %r0, #0; dploop: ld %r4, %r0, #0;
ld %r5, %r1, #0; ld %r6, %r1, #0;
subi %r2, %r2, #1; subi %r2, %r2, #1;
addi %r0, %r0, __WORD; addi %r0, %r0, __WORD;
addi %r1, %r1, __WORD; addi %r1, %r1, __WORD;
rtop @p0, %r2; rtop @p0, %r2;
fadd %r4, %r4, %r5; fadd %r4, %r4, %r6;
fadd %r3, %r3, %r4; fadd %r3, %r3, %r4;
@p0 ? jmpi dploop; @p0 ? jmpi dploop;
ori %r0, %r3, #0;
jmpr %r5;
.perm rw .perm rw

View File

@@ -7,6 +7,24 @@
*******************************************************************************/ *******************************************************************************/
/* Library: print decimals and strings! */ /* Library: print decimals and strings! */
.perm x .perm x
.global
printhex: ldi %r8, (__WORD * 8);
ldi %r11, #1;
shli %r11, %r11, (__WORD*8 - 1);
printhex_l1: subi %r8, %r8, #4;
shr %r9, %r7, %r8;
andi %r9, %r9, #15;
subi %r10, %r9, #9;
isneg @p0, %r10;
notp @p1, @p0;
@p0 ? addi %r9, %r9, #0x30
@p1 ? addi %r9, %r10, #0x61
rtop @p0, %r8;
st %r9, %r11, #0;
@p0 ? jmpi printhex_l1;
jmpr %r5;
.global .global
printdec: ldi %r8, #1; printdec: ldi %r8, #1;
shli %r8, %r8, (__WORD*8 - 1); shli %r8, %r8, (__WORD*8 - 1);