mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-23 13:27:29 -04:00
Barrier instruction support.
This commit is contained in:
parent
129b5078db
commit
a788ea6aa4
4 changed files with 36 additions and 2 deletions
10
src/enc.cpp
10
src/enc.cpp
|
@ -164,7 +164,11 @@ Instruction *ByteDecoder::decode(const vector<Byte> &v, Size &n) {
|
|||
inst.setDestPReg(readByte(v, n));
|
||||
inst.setSrcPReg(readByte(v, n));
|
||||
break;
|
||||
default:
|
||||
case Instruction::AC_2REGSRC:
|
||||
inst.setSrcReg(readByte(v, n));
|
||||
inst.setSrcReg(readByte(v, n));
|
||||
break;
|
||||
default:
|
||||
decodeError("Unknown argument class.");
|
||||
}
|
||||
|
||||
|
@ -331,6 +335,10 @@ Instruction *WordDecoder::decode(const std::vector<Byte> &v, Size &idx) {
|
|||
inst.setSrcPReg((code>>i3)&pMask);
|
||||
inst.setSrcPReg((code>>(i3-r))&pMask);
|
||||
break;
|
||||
case Instruction::AC_2REGSRC:
|
||||
inst.setSrcReg((code>>i2)&rMask);
|
||||
inst.setSrcReg((code>>i3)&rMask);
|
||||
break;
|
||||
defualt:
|
||||
cout << "Unrecognized argument class in word decoder.\n";
|
||||
exit(1);
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "types.h"
|
||||
#include "archdef.h"
|
||||
|
@ -84,6 +86,7 @@ namespace Harp {
|
|||
Word interruptEntry;
|
||||
|
||||
std::vector<Warp> w;
|
||||
std::map<Word, std::set<Warp *> > b; // Barriers
|
||||
};
|
||||
|
||||
class Warp {
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Harp {
|
|||
JMPRT, LD, ST, LDI, RTOP, ANDP, ORP, XORP, NOTP, ISNEG,
|
||||
ISZERO, HALT, TRAP, JMPRU, SKEP, RETI, TLBRM,
|
||||
ITOF, FTOI, FADD, FSUB, FMUL, FDIV, FNEG, WSPAWN,
|
||||
SPLIT, JOIN };
|
||||
SPLIT, JOIN, BAR };
|
||||
enum ArgClass {
|
||||
AC_NONE, AC_2REG, AC_2IMM, AC_3REG, AC_3PREG, AC_3IMM, AC_3REGSRC,
|
||||
AC_1IMM, AC_1REG, AC_3IMMSRC, AC_PREG_REG, AC_2PREG, AC_2REGSRC
|
||||
|
|
|
@ -360,6 +360,29 @@ void Instruction::executeOn(Warp &c) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case BAR: if (sjOnce) {
|
||||
sjOnce = false;
|
||||
Word id(reg[rsrc[0]]), n(reg[rsrc[1]]);
|
||||
set<Warp*> &b(c.core->b[id]);
|
||||
|
||||
// Add current warp to the barrier and halt.
|
||||
b.insert(&c);
|
||||
c.shadowActiveThreads = c.activeThreads;
|
||||
nextActiveThreads = 0;
|
||||
|
||||
D(2, "Barrier " << id << ' ' << b.size() << " of " << n);
|
||||
|
||||
// If the barrier's full, reactivate warps waiting at it
|
||||
if (b.size() == n) {
|
||||
set<Warp*>::iterator it;
|
||||
for (it = b.begin(); it != b.end(); ++it)
|
||||
(*it)->activeThreads = (*it)->shadowActiveThreads;
|
||||
c.core->b.erase(id);
|
||||
nextActiveThreads = c.shadowActiveThreads;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
cout << "ERROR: Unsupported instruction: " << *this << "\n";
|
||||
exit(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue