<div dir="ltr">Mohamed, vectorization is not a magic bullet. But the mail is not about that, it is about both float4 and ssef implementing same logic nowadays. It is confirmed nowadays that using global vectorization (except couple of places which gives precision issues or where loading data for instruction gives big latency) gives good performance boost. This is not default behavior in Blender 2.78b.<div><br></div><div>Milan, in fact we already have float8, it is just called avxf :)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 23, 2017 at 10:52 PM, Jaros Milan <span dir="ltr">&lt;<a href="mailto:milan.jaros@vsb.cz" target="_blank">milan.jaros@vsb.cz</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="padding-bottom:40px">
<div style="font-size:10pt">
<p dir="ltr" style="margin-top:0;margin-bottom:0">Hi Sergey,</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0"><br>
</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0">I agree with you. I am using Blender Cycles without sseX and it works very well. For example: It could help when somebody would like to add float8 and float16 in the future (for better vectorization on new
 CPUs).<br>
</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0"><br>
</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0">Best regards</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0">Milan</p>
<div id="m_-2394550403142460069SignatureBox" dir="ltr" style="font-size:10pt;min-height:0px">
<p dir="ltr"></p>
</div>
</div>
<div style="font-size:10pt">
<div id="m_-2394550403142460069LGEmailHeader" dir="ltr" style="margin-top:0;margin-bottom:0">
<p dir="ltr" style="margin-top:0;margin-bottom:0"><br>
</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0">------ Původní zpráva------</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0"><b>Od: </b>Sergey Sharybin<u></u><u></u></p>
<p dir="ltr" style="margin-top:0;margin-bottom:0"><b>Datum: </b>čt, <a href="tel:23.%203.%202017%2020" target="_blank">
23. 3. 2017 20</a>:12</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0"><b>Na: </b>Discussion list to assist Cycles render engine developers;</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0"><b>Předmět:</b>[Bf-cycles] RFC: Deprecate and remove ssef/ssei/sseb ?</p>
<p dir="ltr" style="margin-top:0;margin-bottom:0"><br>
</p>
</div><div><div class="h5">
<div dir="ltr">Hey everyone,
<div dir="ltr"><br>
</div>
<div dir="ltr">This topic is inspired by annoyance of having both float{3,4} and ssef data types in Cycles. For a long time there was a good reason for that: we did not have any vectorization on float3/4 operations because that was causing rendering slowdown.
 But since Blender 2.78b we&#39;ve got global SSE optimization enabled on AVX and AVX2 kernels and to my knowledge we can enable it for SSE4.1 kernels. This causes some redundancy and causes the following issues:</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">- There is now two almost matched code bases: one is vectorization of flaot3/4 and other one is ssef</div>
<div dir="ltr">- Such duplication is increasing risk of two code bases diverging from each other: we can fix bug in one of the code paths but not in another.</div>
<div dir="ltr">- it is not really clear now whether someone need to prefer ssef over float4 for his optimzied code.</div>
<div dir="ltr">- This often causes avoidable duplicated code paths which are ifdef-ed in the kernel (one using float4 and other one using ssef).</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Similar notes applies on ssei and sseb as well.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">I think it makes sense to prefer float3/4 nowadays (and their integer and boolean analogs) nowadays and retire sse{f,i,b} implementations. This will definitely avoid confusion about what data type to use for the new code and avoid having vectorization
 code implemented twice. There is no so many places where this types are used in the kernel and in most cases it&#39;s quite trivial to replace with float4 directly.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">However, there are following downsides:</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">- We&#39;ll need to support some vectorization instructions on float4, for example, len_squared&lt;&gt;(ssef).</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">This is quite trivial job, just needs to be done with care. Not so much of an issue.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">- In most cases ssef is passed as constant reference.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">This is a bit more tricky. From experiments, passing float4 to a force-inlined function does not always avoid copy-constructor from being called. This is giving issues in Pluecker intersection code.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Simplest solution here would be to still have code path if-dfefed and keep constant references in there. This wouldn&#39;t allow us to merge GPU and CPU code paths easily but will get us free from redundant classes without performance loss.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Introduction of constant references we&#39;ll need to raise anyway. The only stopper here is OpenCL which does not have those. Crazy approach could be to have ccl_ref macro, so we can write foo(const float4 ccl_ref bar) (similar to ccl_restrict).
 This will allow us to merge some codepaths between CPU and GPU and avoid unwanted copy-constructor overhead on CPU.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Perhaps this constant reference topic we can save for later and solve issues one by one.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">The mail is getting too long now, so let me ask this: what do you guys think? Does this ssef to float4 replacement makes sense? Do i miss something and we still need to have sse types?</div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
-- <br>
<div class="m_-2394550403142460069gmail_signature" dir="ltr">
<div dir="ltr"><span style="color:rgb(102,102,102)">With best regards, Sergey Sharybin</span></div>
</div>
</div>
</div>
</div></div></div>
</div>

<br>______________________________<wbr>_________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
<a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/<wbr>mailman/listinfo/bf-cycles</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div><span style="color:rgb(102,102,102)">With best regards, Sergey Sharybin</span></div></div>
</div>