[Beignet] [PATCH] add sends support for printf
Guo, Yejun
yejun.guo at intel.com
Mon Dec 19 06:36:31 UTC 2016
Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
---
backend/src/backend/gen_context.cpp | 21 +++++++++++----------
backend/src/backend/gen_context.hpp | 2 +-
backend/src/backend/gen_insn_selection.cpp | 25 ++++++++++++++++++++-----
backend/src/backend/gen_insn_selection.hpp | 1 +
4 files changed, 33 insertions(+), 16 deletions(-)
diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index c8019e3..cb25b73 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -3477,13 +3477,13 @@ namespace gbe
}
void GenContext::emitPrintfLongInstruction(GenRegister& addr, GenRegister& data,
- GenRegister& src, uint32_t bti) {
+ GenRegister& src, uint32_t bti, bool useSends) {
p->MOV(GenRegister::retype(data, GEN_TYPE_UD), src.bottom_half());
- p->UNTYPED_WRITE(addr, addr, GenRegister::immud(bti), 1, false);
+ p->UNTYPED_WRITE(addr, data, GenRegister::immud(bti), 1, useSends);
p->ADD(addr, addr, GenRegister::immud(sizeof(uint32_t)));
p->MOV(GenRegister::retype(data, GEN_TYPE_UD), src.top_half(this->simdWidth));
- p->UNTYPED_WRITE(addr, addr, GenRegister::immud(bti), 1, false);
+ p->UNTYPED_WRITE(addr, data, GenRegister::immud(bti), 1, useSends);
p->ADD(addr, addr, GenRegister::immud(sizeof(uint32_t)));
}
@@ -3495,6 +3495,7 @@ namespace gbe
GenRegister addr = GenRegister::retype(tmp0, GEN_TYPE_UD);
GenRegister data = GenRegister::retype(tmp1, GEN_TYPE_UD);
+ bool useSends = insn.extra.printfSplitSend;
if (!insn.extra.continueFlag) {
p->push(); {
@@ -3505,18 +3506,18 @@ namespace gbe
p->MOV(data, GenRegister::immud(insn.extra.printfSize + 12));
} p->pop();
- p->ATOMIC(addr, GEN_ATOMIC_OP_ADD, addr, addr, GenRegister::immud(insn.extra.printfBTI), 2, false);
+ p->ATOMIC(addr, GEN_ATOMIC_OP_ADD, addr, data, GenRegister::immud(insn.extra.printfBTI), 2, useSends);
/* Write out the header. */
p->MOV(data, GenRegister::immud(0xAABBCCDD));
- p->UNTYPED_WRITE(addr, addr, GenRegister::immud(insn.extra.printfBTI), 1, false);
+ p->UNTYPED_WRITE(addr, data, GenRegister::immud(insn.extra.printfBTI), 1, useSends);
p->ADD(addr, addr, GenRegister::immud(sizeof(uint32_t)));
p->MOV(data, GenRegister::immud(insn.extra.printfSize + 12));
- p->UNTYPED_WRITE(addr, addr, GenRegister::immud(insn.extra.printfBTI), 1, false);
+ p->UNTYPED_WRITE(addr, data, GenRegister::immud(insn.extra.printfBTI), 1, useSends);
p->ADD(addr, addr, GenRegister::immud(sizeof(uint32_t)));
p->MOV(data, GenRegister::immud(insn.extra.printfNum));
- p->UNTYPED_WRITE(addr, addr, GenRegister::immud(insn.extra.printfBTI), 1, false);
+ p->UNTYPED_WRITE(addr, data, GenRegister::immud(insn.extra.printfBTI), 1, useSends);
p->ADD(addr, addr, GenRegister::immud(sizeof(uint32_t)));
}
@@ -3526,14 +3527,14 @@ namespace gbe
src = ra->genReg(insn.src(i));
if (src.type == GEN_TYPE_UD || src.type == GEN_TYPE_D || src.type == GEN_TYPE_F) {
p->MOV(GenRegister::retype(data, src.type), src);
- p->UNTYPED_WRITE(addr, addr, GenRegister::immud(insn.extra.printfBTI), 1, false);
+ p->UNTYPED_WRITE(addr, data, GenRegister::immud(insn.extra.printfBTI), 1, useSends);
p->ADD(addr, addr, GenRegister::immud(sizeof(uint32_t)));
} else if (src.type == GEN_TYPE_B || src.type == GEN_TYPE_UB ) {
p->MOV(GenRegister::retype(data, GEN_TYPE_UD), src);
- p->UNTYPED_WRITE(addr, addr, GenRegister::immud(insn.extra.printfBTI), 1, false);
+ p->UNTYPED_WRITE(addr, data, GenRegister::immud(insn.extra.printfBTI), 1, useSends);
p->ADD(addr, addr, GenRegister::immud(sizeof(uint32_t)));
} else if (src.type == GEN_TYPE_L || src.type == GEN_TYPE_UL ) {
- emitPrintfLongInstruction(addr, data, src, insn.extra.printfBTI);
+ emitPrintfLongInstruction(addr, data, src, insn.extra.printfBTI, useSends);
}
}
}
diff --git a/backend/src/backend/gen_context.hpp b/backend/src/backend/gen_context.hpp
index fe7317d..7fd40d1 100644
--- a/backend/src/backend/gen_context.hpp
+++ b/backend/src/backend/gen_context.hpp
@@ -243,7 +243,7 @@ namespace gbe
void calcGlobalXYZRange(GenRegister& reg, GenRegister& tmp, int flag, int subFlag);
virtual void subTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp);
virtual void addTimestamps(GenRegister& t0, GenRegister& t1, GenRegister& tmp);
- virtual void emitPrintfLongInstruction(GenRegister& addr, GenRegister& data, GenRegister& src, uint32_t bti);
+ virtual void emitPrintfLongInstruction(GenRegister& addr, GenRegister& data, GenRegister& src, uint32_t bti, bool useSends);
private:
CompileErrorCode errCode;
diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 128c2bc..99a1922 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -2227,7 +2227,6 @@ namespace gbe
void Selection::Opaque::PRINTF(uint8_t bti, GenRegister tmp0, GenRegister tmp1,
GenRegister src[8], int srcNum, uint16_t num, bool isContinue, uint32_t totalSize) {
SelectionInstruction *insn = this->appendInsn(SEL_OP_PRINTF, 2, srcNum);
- SelectionVector *vector = this->appendVector();
for (int i = 0; i < srcNum; i++)
insn->src(i) = src[i];
@@ -2235,10 +2234,26 @@ namespace gbe
insn->dst(0) = tmp0;
insn->dst(1) = tmp1;
- vector->regNum = 2;
- vector->reg = &insn->dst(0);
- vector->offsetID = 0;
- vector->isSrc = 0;
+ if (hasSends()) {
+ insn->extra.printfSplitSend = 1;
+ SelectionVector *vector = this->appendVector();
+ vector->regNum = 1;
+ vector->reg = &insn->dst(0);
+ vector->offsetID = 0;
+ vector->isSrc = 0;
+
+ vector = this->appendVector();
+ vector->regNum = 1;
+ vector->reg = &insn->dst(1);
+ vector->offsetID = 1;
+ vector->isSrc = 0;
+ } else {
+ SelectionVector *vector = this->appendVector();
+ vector->regNum = 2;
+ vector->reg = &insn->dst(0);
+ vector->offsetID = 0;
+ vector->isSrc = 0;
+ }
insn->extra.printfSize = static_cast<uint16_t>(totalSize);
insn->extra.continueFlag = isContinue;
diff --git a/backend/src/backend/gen_insn_selection.hpp b/backend/src/backend/gen_insn_selection.hpp
index 01999a2..49d33e1 100644
--- a/backend/src/backend/gen_insn_selection.hpp
+++ b/backend/src/backend/gen_insn_selection.hpp
@@ -158,6 +158,7 @@ namespace gbe
uint32_t printfBTI:8;
uint32_t continueFlag:8;
uint16_t printfSize;
+ uint16_t printfSplitSend:1;
};
uint32_t workgroupOp;
} extra;
--
1.9.1
More information about the Beignet
mailing list