diff --git a/doc/harp_iset.tex b/doc/harp_iset.tex index ef8918ae..4cd881f4 100644 --- a/doc/harp_iset.tex +++ b/doc/harp_iset.tex @@ -32,7 +32,7 @@ An \texttt{ArchID} uniquely identifies a HARP ISA. \section{Architecture Identifier String (\texttt{ArchID})} The best way to understand the multifaceted parameterizablity of the HARP ISAs is to study the architecture identifier strings used to uniquely identify a single HARP instruction set architecture. -We'll start by breaking down Harptool's default \texttt{ArchID}: \texttt{8w32/32/8}: +We'll start by breaking down Harptool's default \texttt{ArchID}: \texttt{8w32/32/8/8}: \begin{center} \begin{tabular}{rl} @@ -43,10 +43,11 @@ We'll start by breaking down Harptool's default \texttt{ArchID}: \texttt{8w32/32 \texttt{32}&32 general-purpose registers per lane\\ \texttt{32}&32 predicate registers per lane\\ \texttt{8} &8 SIMD lanes\\ +\texttt{8} &8 warps (thread groups)\\ \end{tabular} \end{center} -All ArchIDs have a similar format, although the SIMD lanes field can be omitted, as object files are still fully compatible even if the number of lanes changes. +All ArchIDs have a similar format, although the final two fields can be omitted, as object files are still fully compatible even if the dimensions of the core change. \section{HarpTool} The assembler/linker/emulator/disassembler program for HARP is called HarpTool. diff --git a/src/core.cpp b/src/core.cpp index f775ec68..8bdf0a0c 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -32,7 +32,7 @@ void Harp::reg_doWrite(Word cpuId, Word regNum) { Core::Core(const ArchDef &a, Decoder &d, MemoryUnit &mem, Word id): a(a), iDec(d), mem(mem) { - for (unsigned i = 0; i < 8; ++i) + for (unsigned i = 0; i < a.getNWarps(); ++i) w.push_back(Warp(this)); w[0].activeThreads = 1; diff --git a/src/harptool.cpp b/src/harptool.cpp index 8d82bfec..10efd1a5 100644 --- a/src/harptool.cpp +++ b/src/harptool.cpp @@ -49,7 +49,7 @@ HarpToolMode findMode(int argc, char** argv) { } int asm_main(int argc, char **argv) { - string archString("8w32/32/8"), outFileName("a.out.HOF"), + string archString("8w32/32/8/8"), outFileName("a.out.HOF"), inFileName(argv[argc-1]); bool showHelp; @@ -136,7 +136,7 @@ int asm_main(int argc, char **argv) { int disasm_main(int argc, char **argv) { bool showHelp; - string outFileName("a.out.s"), archString("8w32/32/8"); + string outFileName("a.out.s"), archString("8w32/32/8/8"); /* Get command line arguments. */ @@ -206,7 +206,7 @@ int disasm_main(int argc, char **argv) { } int emu_main(int argc, char **argv) { - string archString("8w32/32/8"), imgFileName("a.out.bin"); + string archString("8w32/32/8/8"), imgFileName("a.out.bin"); bool showHelp; /* Read the command line arguments. */ @@ -249,7 +249,8 @@ int emu_main(int argc, char **argv) { int ld_main(int argc, char **argv) { bool showHelp, mustResolveRefs(true); - string outFileName("a.out.bin"), archString("8w32/32/8"), formatString("bin"); + string outFileName("a.out.bin"), archString("8w32/32/8/8"), + formatString("bin"); Size nObjects; Addr binOffset(0); diff --git a/src/include/archdef.h b/src/include/archdef.h index b7cf97e7..2384d55a 100644 --- a/src/include/archdef.h +++ b/src/include/archdef.h @@ -28,7 +28,9 @@ namespace Harp { if (!iss || sep != '/') { extent = EXT_REGS; return; } iss >> sep >> nThds; if (!iss || sep != '/') { extent = EXT_PREGS; return; } - extent = EXT_THDS; + iss >> sep >> nWarps; + if (!iss || sep != '/') { extent = EXT_THDS; return; } + extent = EXT_WARPS; } operator std::string () const { @@ -40,14 +42,25 @@ namespace Harp { if (extent >= EXT_REGS ) oss << nRegs; if (extent >= EXT_PREGS ) oss << '/' << nPRegs; if (extent >= EXT_THDS ) oss << '/' << nThds; + if (extent >= EXT_WARPS ) oss << '/' << nWarps; return oss.str(); } bool operator==(const ArchDef &r) const { - return (extent == r.extent) && (wordSize == r.wordSize) && - (encChar == r.encChar) && (nRegs == r.nRegs) && - (nPRegs == r.nPRegs) && (nThds == r.nThds); + Extent minExtent(r.extent > extent ? extent : r.extent); + + // Can't be equal if we can't specify a binary encoding at all. + if (minExtent < EXT_PREGS) return false; + + if (minExtent >= EXT_WORDSIZE) { if (wordSize!=r.wordSize) return false; } + if (minExtent >= EXT_ENC ) { if (encChar != r.encChar) return false; } + if (minExtent >= EXT_REGS ) { if (nRegs != r.nRegs) return false; } + if (minExtent >= EXT_PREGS ) { if (nPRegs != r.nPRegs) return false; } + if (minExtent >= EXT_THDS ) { if (nThds != r.nThds) return false; } + if (minExtent >= EXT_WARPS ) { if (nWarps != r.nWarps) return false; } + + return true; } bool operator!=(const ArchDef &r) const { return !(*this == r); } @@ -71,14 +84,20 @@ namespace Harp { ThdNum getNThds() const { if (extent < EXT_THDS) throw Undefined(); else return nThds; } + + ThdNum getNWarps() const { + if (extent < EXT_WARPS) throw Undefined(); else return nWarps; + } private: - enum { - EXT_NULL, EXT_WORDSIZE, EXT_ENC, EXT_REGS, EXT_PREGS, EXT_THDS - } extent; + enum Extent { + EXT_NULL, EXT_WORDSIZE, EXT_ENC, EXT_REGS, EXT_PREGS, EXT_THDS, EXT_WARPS + }; + + Extent extent; Size wordSize; - ThdNum nThds; + ThdNum nThds, nWarps; RegNum nRegs, nPRegs; char encChar; }; diff --git a/src/obj.cpp b/src/obj.cpp index 19fb3feb..bdb66edc 100644 --- a/src/obj.cpp +++ b/src/obj.cpp @@ -657,7 +657,8 @@ Obj *HOFReader::read(std::istream &input) { string archString(inputString(input)); ArchDef fileArch(archString); if (fileArch != arch) { - cout << "File arch does not match reader arch in HOFReader::read().\n"; + cout << "File arch " << archString << " does not match reader arch " + << string(arch) << " in HOFReader::read().\n"; exit(1); } diff --git a/src/test/Makefile b/src/test/Makefile index 2c2c8b75..9e69e374 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -2,7 +2,7 @@ HARPLD = ../harptool -L HARPAS = ../harptool -A HARPEM = ../harptool -E HARPDIS = ../harptool -D -4BARCH = 4b16/16/2 +4BARCH = 4b16/16/2/1 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 matmul.bin matmul.4b.bin \ matmul-mt.s lfsr.bin diverge.bin