<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I think that’s a good change. All external code that I’ve written that uses Cycles only used float3/float4 and not the SSE types.<div class="">Eventually, someone may port the code to a different SIMD instruction set (ARM NEON?), and in that case it would be awkward to use types with SSE in the name.</div><div class=""><div class=""><br class=""></div><div class="">-Stefan</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 23 Mar 2017, at 20:11, Sergey Sharybin &lt;<a href="mailto:sergey.vfx@gmail.com" class="">sergey.vfx@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hey everyone,<div class=""><br class=""></div><div class="">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'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 class=""><br class=""></div><div class="">- There is now two almost matched code bases: one is vectorization of flaot3/4 and other one is ssef</div><div class="">- 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 class="">- it is not really clear now whether someone need to prefer ssef over float4 for his optimzied code.</div><div class="">- This often causes avoidable duplicated code paths which are ifdef-ed in the kernel (one using float4 and other one using ssef).</div><div class=""><br class=""></div><div class="">Similar notes applies on ssei and sseb as well.</div><div class=""><br class=""></div><div class="">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's quite trivial to replace with float4 directly.</div><div class=""><br class=""></div><div class="">However, there are following downsides:</div><div class=""><br class=""></div><div class="">- We'll need to support some vectorization instructions on float4, for example, len_squared&lt;&gt;(ssef).</div><div class=""><br class=""></div><div class="">This is quite trivial job, just needs to be done with care. Not so much of an issue.</div><div class=""><br class=""></div><div class="">- In most cases ssef is passed as constant reference.</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Simplest solution here would be to still have code path if-dfefed and keep constant references in there. This wouldn't allow us to merge GPU and CPU code paths easily but will get us free from redundant classes without performance loss.</div><div class=""><br class=""></div><div class="">Introduction of constant references we'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 class=""><br class=""></div><div class="">Perhaps this constant reference topic we can save for later and solve issues one by one.</div><div class=""><br class=""></div><div class="">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 class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div class=""><span style="color:rgb(102,102,102)" class="">With best regards, Sergey Sharybin</span></div></div>
</div></div>
_______________________________________________<br class="">Bf-cycles mailing list<br class=""><a href="mailto:Bf-cycles@blender.org" class="">Bf-cycles@blender.org</a><br class="">https://lists.blender.org/mailman/listinfo/bf-cycles<br class=""></div></blockquote></div><br class=""></div></div></body></html>