<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 7, 2013 at 1:44 PM, Song, Ruiling <span dir="ltr"><<a href="mailto:ruiling.song@intel.com" target="_blank">ruiling.song@intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">





<div lang="ZH-CN" link="blue" vlink="purple">
<div>
<p class=""><span lang="EN-US" style="font-size:10.5pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class=""><span lang="EN-US" style="font-size:10.5pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class=""><b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif"> zhigang gong [mailto:<a href="mailto:zhigang.gong@gmail.com" target="_blank">zhigang.gong@gmail.com</a>]
<br>
<b>Sent:</b> Wednesday, August 07, 2013 1:04 PM<br>
<b>To:</b> Song, Ruiling<br>
<b>Cc:</b> <a href="mailto:beignet@lists.freedesktop.org" target="_blank">beignet@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: [Beignet] [PATCH 1/2] enable scratch memory allocation and read/write<u></u><u></u></span></p><div class="im">
<p class=""><span lang="EN-US"><u></u> <u></u></span></p>
<div>
<p class=""><span lang="EN-US">My suggestion here is to seprate the scratch OBlock read/write out. And submit the<u></u><u></u></span></p>
<div>
<p class=""><span lang="EN-US">Dword Read/Write part firstly, as OBlock read/write is not used right now, Right?<u></u><u></u></span></p>
</div>
</div>
</div><div>
<p class="" style="margin-bottom:12pt"><span lang="EN-US" style="color:rgb(31,73,125)">[Ruiling] In fact, I first use OBlock Read/Write for spill implementation. As I met some failure, so, I also implement scratch HBlock. I call it HBlock as it always read
 multiples of HWord. There are two modes of scratch RW, but I only enable DWORD </span></p></div></div></div></blockquote><div style>  I think you should use Dword to keep align with the spec.  It has reason that although it read data start from Hword alignment,</div>
<div style> but it only use the part of the data according to the data type. For example, if the data type is Dword then it only put the first 8 Dword</div><div style> of data to the destination registers.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div lang="ZH-CN" link="blue" vlink="purple"><div><div><p class="" style="margin-bottom:12pt"><span lang="EN-US" style="color:rgb(31,73,125)">mode. That is the HBlock in the patch. If you have concern about the oword block rw, I can remove OBlock RW logic.</span></p>
</div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="ZH-CN" link="blue" vlink="purple">
<div><div><div><div><div><div><div><div class="h5"><blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div><p class="">+  void GenEncoder::SCRATCH_READ_HWORD(GenRegister dst, GenRegister src, uint32_t offset, uint32_t size, uint32_t dst_num)<br></p></div></blockquote></div></div><div><div class="h5"><div><div><blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class=""><span lang="EN-US">
+  {<br>
+     assert(dst_num == 1 || dst_num ==2);<br>
+     uint32_t block_size = dst_num == 1 ? GEN_SCRATCH_BLOCK_SIZE_1 : GEN_SCRATCH_BLOCK_SIZE_2;<br>
+     GenInstruction *insn = this->next(GEN_OPCODE_SEND);<br>
+     this->setHeader(insn);<br>
+     this->setDst(insn, dst);<br>
+     this->setSrc0(insn, src);<br>
+     this->setSrc1(insn, GenRegister::immud(0));<br>
+      // here dst_num is the register that will be write-back: in terms of 32byte register<br>
+     setScratchMessage(this, insn, offset, block_size, GEN_SCRATCH_DATA_DWORD, GEN_SCRATCH_READ, 1, dst_num);<br>
+  }<br>
+<br>
+  void GenEncoder::SCRATCH_WRITE_OWORD(GenRegister msg, uint32_t size, uint32_t src_num)<br>
+  {<br>
+     GenInstruction *insn = this->next(GEN_OPCODE_SEND);<br>
+     this->setHeader(insn);<br>
+     this->setDst(insn, GenRegister::retype(GenRegister::null(), GEN_TYPE_UD));<br>
+     this->setSrc0(insn, msg);<br>
+     this->setSrc1(insn, GenRegister::immud(0));<br>
+     // here src_num means registers that will be write out: in terms of 32byte register number<br>
+     setOBlockRW(this, insn, 255, size/16, GEN_OBLOCK_WRITE, src_num+1, 0);<br>
+  }<u></u><u></u></span></p>
</blockquote>
</div>
</div>
<div>
<p class=""><span lang="EN-US"> I'm confused here, you prepared a message header for  Scratch OWord  read/write, but then you send a </span><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif">OWord Block Read</span><span lang="EN-US"><u></u><u></u></span></p>

</div>
<p class=""><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif"> message. I don't think it's going to work as desired. You can check the  "OWord Block Read/Write" in the spec, you can find</span><span lang="EN-US"><u></u><u></u></span></p>

</div></div></div><div><div class="h5">
<div>
<p class=""><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif"> a restriction there:</span><span lang="EN-US"><u></u><u></u></span></p>
</div>
<div>
<p class=""><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif">   the only surface type allowed is SURFTYPE_BUFFER.</span><span lang="EN-US"><u></u><u></u></span></p>
</div>
</div></div><div><div><div class="h5">
<p class=""><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif"> And here, the surface is a scratch buffer.</span><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif"><u></u><u></u></span></p>

</div></div><p class=""><span lang="EN-US" style="font-size:10.5pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">[Ruiling] scratch buffer is stateless buffer, i.e.
</span><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif">SURFTYPE_BUFFER. It is more preferred to call “OWord block read/write” instead of “scratch OWord block read/write”. This is not what written as oword mode under scratch memory
 read/write.</span></p></div></div></div></div></div></div></div></blockquote><div><br></div><div style> You are right, the scratch buffer is one type of SURFTYPE_BUFFER and can be accessed by OWord block read/write.</div>
<div style> What confused me is you are using <span style="color:rgb(80,0,80)">SCRATCH_WRITE_</span><span style="color:rgb(80,0,80)">OWORD as the function name. You know there are real</span></div><div style><span style="color:rgb(80,0,80)"> Scratch Block Read/Write for OWord which is quite different</span><span style="color:rgb(80,0,80)"> from this OWord Bloc read. Right? They have different</span></div>
<div style><span style="color:rgb(80,0,80)"> message descriptor and different payload/writeback message.</span></div><div style><br></div><div style><span style="color:rgb(80,0,80)"> Ben had implemented the OBlock read/write extension before. And for some reason he removed those implementations.</span></div>
<div style><span style="color:rgb(80,0,80)"> If you really want to use OBlock read/write here, it may worth to find what Ben already implemented before and see what we</span></div><div style><span style="color:rgb(80,0,80)"> can reuse here.  And maybe you can get some hint that why you failed to use the OBlock read/write to implement the spill/unspill.</span></div>
<div style><span style="color:rgb(80,0,80)"><br></span></div><div style><span style="color:rgb(80,0,80)"> Anyway, use scratch_write/read_oword is quite misleading here, and should be corrected. What do you think?</span></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="ZH-CN" link="blue" vlink="purple"><div><div><div>
<div><div><div><p class=""><span style="color:rgb(80,0,80)"> </span></p></div></div></div></div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div lang="ZH-CN" link="blue" vlink="purple"><div><div><div><div><div><div><div><div class="h5">
<div>
<p class=""><span lang="EN-US"> I'm thinking of is there a way to test the scratch read/write directly?  Maybe it's not so straightforward as it's only<u></u><u></u></span></p>
</div>
<div>
<p class=""><span lang="EN-US"> used when spill/unspill occurs.  And if a kernel triggers spill/unspill, it means the kernel is not very simple and can't<u></u><u></u></span></p>
</div>
<div>
<p class=""><span lang="EN-US"> be a proper unit test case for scratch read/write. Any good idea?<u></u><u></u></span></p>
</div>
</div></div><div>
<p class=""><span lang="EN-US" style="color:rgb(31,73,125)">[Ruiling] this is also a problem I met. At last I only can manually call spillReg() to select one virtual register I want, so, I don’t have to face a complex kernel. But I don’t have good way of
 verifying scratch RW.</span><span lang="EN-US" style="color:rgb(136,136,136)"><u></u><u></u></span></p>
</div><div class="im">
<div>
<p class=""><span lang="EN-US" style="color:rgb(136,136,136)"> - Zhigang<u></u><u></u></span></p>
</div>
<div>
<blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class=""><span lang="EN-US" style="color:rgb(136,136,136)">--<br>
1.7.9.5<br>
<br>
_______________________________________________<br>
Beignet mailing list<br>
<a href="mailto:Beignet@lists.freedesktop.org" target="_blank">Beignet@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/beignet" target="_blank">http://lists.freedesktop.org/mailman/listinfo/beignet</a></span><span lang="EN-US"><u></u><u></u></span></p>
</blockquote>
</div>
</div></div>
<p class=""><span lang="EN-US"><u></u> <u></u></span></p>
</div>
</div>
</div>
<p class=""><span lang="EN-US"><u></u> <u></u></span></p>
</div>
</div>
</div>

</blockquote></div><br></div></div>