Most efficient way to decode large C array of 32bit words?

[email protected] Thu, 21 Sep 2023 14:14:12 +1200
Newsgroups gmane.comp.lang.haskell.ffi
Message-ID <[email protected]>
--===============8445677347806661299==
Content-Type: multipart/alternative; boundary="=-CN/po+oeVf8A7gPE4VWQ"

--=-CN/po+oeVf8A7gPE4VWQ
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable


    <div style=3D"height: initial;" dir=3D"auto">I've got an interesting pu=
zzle I'm pulling my hair out over.<div><br></div><div>I'm writing (pure fun=
ctional) Haskell bindings for a C library which returns 2 large arrays of 3=
2bit words (or rather arrays of structs, all of who's fields are very conve=
niently aligned). But these bindings I wrote are far too slow for my uses.<=
/div><div><br></div><div>A primary performance problem identified by clear =
box benchmarking are a couple calls to `peekArray`. I've previously used `f=
orM [0..length - 1] $ peekOffset arr`, but switching away from that yielded=
 only minor performance benefit. Commenting out this `peekArray` removes al=
l the overhead I'm seeing.</div><div><br></div><div>(Strangely commenting o=
ut any usage of the returned list does likewise, even though I've verified =
that the whole list doesn't get iterated over in WHNF)</div><div><br></div>=
<div>The same benchmarks indicate that the postprocessing I'm applying over=
 those lists has imperceptible overhead.</div><div><br></div><div>In short:=
 What's the fastest `peekArray` alternative for `Ptr Word32` you recommend?=
</div><div><br></div><div>P.S. I'm inputting a nearly 1mb novel (Dracula by=
 Bram Stoker) to get an estimated 20mb * 2 worth of output.</div></div>
   =20
   =20



--=-CN/po+oeVf8A7gPE4VWQ--

--===============8445677347806661299==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KRkZJIG1haWxp
bmcgbGlzdApGRklAaGFza2VsbC5vcmcKaHR0cDovL21haWwuaGFza2VsbC5vcmcvY2dpLWJpbi9t
YWlsbWFuL2xpc3RpbmZvL2ZmaQo=

--===============8445677347806661299==--