<div dir="ltr">that said it does occur to me that there is an alternative solution that may be acceptable for everyone!<div><br></div><div style>what about providing a pseudo compatible way called -fllvm-experimentalAVX (or something), and simply require that for it to be used, the user has an llvm Patched with the YMM simd in register fun call support? internally that could just be an llvm way that trips the logic that puts the first few AVX values in those YMM1-6 slots if they are the first args, so only the stack spilling logic needs be changed?</div>

<div style><br></div><div style>(ie it wouldn&#39;t be tied to an llvm version, but rather this pseduo way flag)</div><div style><br></div><div style>does that make sense?</div><div style><br></div><div style>either way, i&#39;d really like having avx even if its always spilled to stack at funcalls with standard LLVMs!</div>

<div style><br></div><div style>cheers</div><div style>-carter</div><div style><br></div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 12, 2013 at 2:28 AM, Carter Schonwald <span dir="ltr">&lt;<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Geoff, <div><br></div><div><div>a prosaic reason why there *might* be a fundamentally breaking change would be the following idea nathan howell suggested to me this afternoon: change the Sp and SPLim register so that the X86/x86_64 target can use the CPU&#39;s Push and (maybe) Pop instructions for the  stack manipulations, rather than MOV and fam.  see <a href="http://ghc.haskell.org/trac/ghc/ticket/8272" target="_blank">http://ghc.haskell.org/trac/ghc/ticket/8272</a> (which is just what i&#39;ve said). Thats one change thats pretty simple but deep, but likely worth exploring. </div>


</div><div><br></div><div><br></div><div>i&#39;m saying any ABI change for GHC 7.10, would likely entail patching LLVM 3.4, because thats the only LLVM version likely to come out between now and whenever we get 7.10 out (assuming 7.10 lands within the next 8-12 months, which is reasonable since we&#39;ve got noticeably more (amazing) people  helping out lately). Thus, any change there entails either asking the llvm folks to support &gt;1 GHC convention per architecture, or replace the current one!  I&#39;d rather do the latter than the former, when it comes to asking other people to maintain it :)</div>


<div>(and llvm engineers do in fact help out maintaining that code)</div><div><br><div><br></div><div>have you run a Nofib, or even benchmarks restricted to your multivector code, for the current calling convention (including the spilling AVX vectors to the stack thats the current plan i gather) VS passing in registers with an LLVM built using the patches i worked out ~ 2 months ago?  it&#39;d be really easy to build that custom llvm, then run the benchmarks! (i&#39;m happy to help, and ultimately, benchmarks will reveal if its worth while or not! And if the main goal is for your talk, its still valid even if its not in the merge window over the next 4 days). </div>


<div><br></div><div>I really think its not obvious what the &quot;best&quot; abi change would be! It really will require coming up with a list of variants, implementing them, and running nofib with each variant, which i lack the compute/human time resources to do this week. Modern hardware is complex enough that for something like an ABI change, the only healthy attitude can be &quot;lets benchmark it!&quot;. <br>


<div>
<br></div><div>i&#39;d really like any change in calling convention to also improve perf on codes that aren&#39;t explicitly simd! (and a conservative simd only change, blocks/conflicts with that augmentation going forward, and not just for the stack pointer example i mention early)</div>


<div><br></div><div> Not just scalar floats in simd registers , but perhaps also words/ints !</div><div><br></div><div>(though that latter bit  might be pretty ambitious and subtle, i&#39;ll need to investigate that a bit to see how feasible it may be). </div>


<div>SIMD has great support for  ints/words, and any partial abi change on the llvm backend now would make it hard to support that later well (or at least, thats what it looks like to me).  actually effectively using simd for scalar ints and words should be doable, but might force us to be a bit more thoughtful on how GHC internally distinguishes ints used for address arithmetic, vs ints used as data.  (interestingly, i&#39;m not sure if any current extent x86 calling convention does that!)</div>


<div><br></div><div><br></div><div>    That single change would make 7.10 require a completely different llvm and native code gen convention from our current one, plus touch all of the code gen on x86 architectures.</div>


<div><br></div><div><br></div><div>basically: we&#39;re lucky that everyone builds haskell code from source, so ABI compat across GHC versions is a non issue. BUT, any ABI changes should be backed by benchmarks (at least when the change is performance motivated). Likewise, because we use LLVM as an external dep for the -fllvm backend, we really need to keep how their release cycle interacts with our release cycle, because people use haskell and ghc! which as many like to say, is both a boon and a pain ;). </div>


<div><br></div><div>Having people hit ghc acting broken with an llvm that was &quot;supported before&quot; is  risky support problem to deal with. having an LLVM head variant support a modified ABI, and then later needing to break it for 7.10 (for one of the possible exploratory reasons above) would lead to a support headache I don&#39;t wish on anyone.</div>


<div><br></div><div>pardon the verbose answer, but thats my offhand take</div><div><br></div><div>cheers</div></div></div><span class="HOEnZb"><font color="#888888"><div>-Carter</div></font></span></div><div class="HOEnZb">

<div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Sep 11, 2013 at 10:10 PM, Geoffrey Mainland <span dir="ltr">&lt;<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>We support compiling some code with -fllvm and some not in the same<br>
</div>executable. Otherwise how could users of the Haskell Platform link their<br>
-fllvm-compiled code with native-codegen-compiled libraries like base, etc.?<br>
<br>
In other words, the LLVM and native back ends use the same calling<br>
convention. With my SIMD work, they still use the same calling<br>
conventions, but the native codegen can never generate code that uses<br>
SIMD instructions.<br>
<br>
Geoff<br>
<div><br>
On 09/11/2013 10:03 PM, Johan Tibell wrote:<br>
&gt; OK. But that doesn&#39;t create a problem for the code we output with the<br>
&gt; LLVM backend, no? Or do we support compiling some code with -fllvm and<br>
&gt; some not in the same executable?<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Sep 11, 2013 at 6:56 PM, Geoffrey Mainland<br>
</div><div>&gt; &lt;<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a> &lt;mailto:<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     We definitely have interop between the native codegen and the LLVM<br>
&gt;     back<br>
&gt;     end now. Otherwise anyone who wanted to use the LLVM back end<br>
&gt;     would have<br>
&gt;     to build GHC themselves. Interop means that users can install the<br>
&gt;     Haskell Platform and still use -fllvm when it makes a performance<br>
&gt;     difference.<br>
&gt;<br>
&gt;     Geoff<br>
&gt;<br>
&gt;     On 09/11/2013 07:59 PM, Johan Tibell wrote:<br>
&gt;     &gt; Do nothing different than you&#39;re doing for 7.8, we can sort it out<br>
&gt;     &gt; later. Just put a comment on the primops saying they&#39;re<br>
&gt;     LLVM-only. See<br>
&gt;     &gt; e.g.<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     <a href="https://github.com/ghc/ghc/blob/master/compiler/prelude/primops.txt.pp#L181" target="_blank">https://github.com/ghc/ghc/blob/master/compiler/prelude/primops.txt.pp#L181</a><br>
&gt;     &gt;<br>
&gt;     &gt; for an example how to add docs to primops.<br>
&gt;     &gt;<br>
&gt;     &gt; I don&#39;t think we need interop between the native and the LLVM<br>
&gt;     &gt; backends. We don&#39;t have that now do we (i.e. they use different<br>
&gt;     &gt; calling conventions).<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; On Wed, Sep 11, 2013 at 4:51 PM, Geoffrey Mainland<br>
&gt;     &gt; &lt;<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a> &lt;mailto:<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a>&gt;<br>
</div><div>&gt;     &lt;mailto:<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a> &lt;mailto:<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a>&gt;&gt;&gt; wrote:<br>


&gt;     &gt;<br>
&gt;     &gt;     On 09/11/2013 07:44 PM, Johan Tibell wrote:<br>
&gt;     &gt;     &gt; On Wed, Sep 11, 2013 at 4:40 PM, Geoffrey Mainland<br>
&gt;     &gt;     &lt;<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a> &lt;mailto:<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a>&gt;<br>
</div><div><div>&gt;     &lt;mailto:<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a> &lt;mailto:<a href="mailto:mainland@apeiron.net" target="_blank">mainland@apeiron.net</a>&gt;&gt;&gt; wrote:<br>



&gt;     &gt;     &gt; &gt; Do you mean we need a reasonable emulation of the SIMD<br>
&gt;     primops for<br>
&gt;     &gt;     &gt; &gt; the native codegen?<br>
&gt;     &gt;     &gt;<br>
&gt;     &gt;     &gt; Yes. Reasonable in the sense that it computes the right<br>
&gt;     result.<br>
&gt;     &gt;     I can<br>
&gt;     &gt;     &gt; see that some code might still want to #ifdef (if the<br>
&gt;     fallback isn&#39;t<br>
&gt;     &gt;     &gt; fast enough).<br>
&gt;     &gt;<br>
&gt;     &gt;     Two implications of this requirement:<br>
&gt;     &gt;<br>
&gt;     &gt;     1) There will not be SIMD in 7.8. I just don&#39;t have the<br>
&gt;     time. In fact,<br>
&gt;     &gt;     what SIMD support is there already will have to be removed if we<br>
&gt;     &gt;     cannot<br>
&gt;     &gt;     live with LLVM-only SIMD primops.<br>
&gt;     &gt;<br>
&gt;     &gt;     2) If we also require interop between the LLVM back-end and<br>
&gt;     the native<br>
&gt;     &gt;     codegen, then we cannot pass any SIMD vectors in<br>
&gt;     registers---they all<br>
&gt;     &gt;     must be passed on the stack.<br>
&gt;     &gt;<br>
&gt;     &gt;     My plan, as discussed with Simon PJ, is to not support SIMD<br>
&gt;     primops at<br>
&gt;     &gt;     all with the native codegen. If there is a strong feeling that<br>
&gt;     &gt;     this *is<br>
&gt;     &gt;     not* the way to go, the I need to know ASAP.<br>
&gt;     &gt;<br>
&gt;     &gt;     Geoff<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>