'import ccall unsafe' and parallelism
Carter Schonwald
carter.schonwald at gmail.com
Thu Aug 14 16:26:58 UTC 2014
if your computation in the C call takes more than 400 nano seconds, the
overhead of the safe ffi convention is less onerous and you should do that
when applicable.
an alternative is so use forkOn to setup a worker thread on various GHC
capabilities, and have them in parallel work on different chunks of the
list. that way you're pausing ALL the capabilities (which again, you should
only use the unsafe ffi convention for computations that take <= 10
microseconds if you want things to be well behaved)
On Thu, Aug 14, 2014 at 12:21 PM, Donn Cave <donn at avvanta.com> wrote:
> I'm no judge of what's true about safe and unsafe, but this account of
> the system has at least to my ear the ring of authenticity:
>
>
> http://blog.melding-monads.com/2011/10/24/concurrency-and-foreign-functions-in-the-glasgow-haskell-compiler/
>
> The FFI section is short and readable.
>
> With respect to whether "unsafe" does or does not block other threads,
> I can never penetrate the verbiage about capabilities to know for sure
> what to expect in practice, but when I checked, in practice, "unsafe"
> blocks other threads. I use "safe" to avoid this.
>
> Donn
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20140814/5585e9da/attachment.html>
More information about the Glasgow-haskell-users
mailing list