Hi cafe,<br><br>
I want to add the ability to use AES-NI instructions on Intel 
architectures to GHC.  Mainly I&#39;d like to do splittable random number 
generators based on AES as was suggested at the outset of this email.  (I met Burton Smith last week and this topic 
came up.)  <br><br>I was just reading the below thread about the plugin architecture which got me thinking about what the right way to add AES-NI is.  (Disregarding for a moment portability and the issue of where to test cpuid...)<br>

   <a href="http://www.haskell.org/pipermail/glasgow-haskell-users/2011-January/019874.html">http://www.haskell.org/pipermail/glasgow-haskell-users/2011-January/019874.html</a><br><br>The FFI is always an option.  But after reading the first N pages I could come across from google I&#39;m still not totally clear on whether &quot;unsafe&quot; foreign calls can happen simultaneously from separate Haskell threads (and with sufficiently low overhead for this purpose).<br>

<br>I also ran across the phrase &quot;compiler primitive&quot; somewhere wrt GHC:<br>    <a href="http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations">http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations</a><br>

<br>Is that the right way to go?  Or would the compiler plugin mechanism possibly allowing doing this without modifying mainline GHC?<br><br>Thanks,<br>  -Ryan<br><br><div class="gmail_quote">On Fri, Nov 12, 2010 at 6:26 PM, wren ng thornton <span dir="ltr">&lt;<a href="mailto:wren@freegeek.org">wren@freegeek.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On 11/12/10 5:33 AM, Richard Senington wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
It does not give the results you would want. This may have something to<br>
do with picking &quot;good&quot; parameters for the mkLehmerTree function.<br>
For example, using a random setup, I just got these results<br>
result expected range<br>
16.814 expected = 16.0 (1,31)<br>
16.191 expected = 16.5 (1,32)<br>
16.576 expected = 17.0 (1,33)<br>
17.081 expected = 17.5 (1,34)<br>
17.543 expected = 18.0 (1,35)<br>
</blockquote>
<br></div>
Have you run any significance tests? I wouldn&#39;t be surprised to see +/-0.5 as within the bounds of expected randomness. I&#39;m more worried about it seeming to be consistently on the -0.5 end of things, than I am about it not matching expectation (how many samples did you take again?). For small ranges like this, a consistent -0.5 (or +0.5) tends to indicate off-by-one errors in the generator.<br>


<br>
-- <br>
Live well,<br><font color="#888888">
~wren</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>