<div dir="ltr">you cant provide > 1 word alignment guarantees if the bytearray isnt pinned, ... at least with the current RTS setup. (though that would be pretty handy if possible)<div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 26, 2014 at 8:55 PM, Erik de Castro Lopo <span dir="ltr"><<a href="mailto:mle+hs@mega-nerd.com" target="_blank">mle+hs@mega-nerd.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>Brandon Simmons wrote:<br>
<br>
> In my tests, using calloc from:<br>
><br>
>     <a href="https://hackage.haskell.org/package/missing-foreign-0.1.1/docs/Foreign-Marshal-MissingAlloc.html" target="_blank">https://hackage.haskell.org/package/missing-foreign-0.1.1/docs/Foreign-Marshal-MissingAlloc.html</a><br>
><br>
> was about twice as fast as allocating and zeroing the same amount of<br>
> memory with `newByteArray` + any of `copy/set/fillMutableByteArray`<br>
> (all three were nearly identical). Is there a way I can reasonably<br>
> define my own `newByteArray` that uses calloc?<br>
><br>
> FWIW here are a couple of the benchmarks I'm working with in criterion:<br>
><br>
>     arrTestSet :: Int -> IO ()<br>
>     arrTestSet len = do<br>
>         let eBytes = (P.sizeOf (undefined::Int))*len<br>
>         a <- P.newAlignedPinnedByteArray<br>
<br>
</span>Why pinned memory?<br>
<span><font color="#888888"><br>
Erik<br>
--<br>
----------------------------------------------------------------------<br>
Erik de Castro Lopo<br>
<a href="http://www.mega-nerd.com/" target="_blank">http://www.mega-nerd.com/</a><br>
</font></span><div><div>_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org" target="_blank">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
</div></div></blockquote></div><br></div></div>