Greetings everybody,

I happen to be a bit confused with regards to unsafe foreign imports and
parallelism.

Assume the following C function:

foreign import ccall unsafe "cfun"
  cfun :: CInt -> IO ()

Now, cfun does some work:

go xs = unsafePerformIO $ do
  forM_ xs $ cfun
  return $ somethingUnhealthy

And I'd like to parallelize this:

parMap rdeepseq go [costly,costly]

However, due to the way ghc handles unsafe imports, namely block
everything else whenever 'cfun' is called, I happen to have only one
active 'go'. Lets assume 'cfun' is cheap and would suffer from 'ccall
safe' more than I'd be willing to pay.

Is there any fix possible?

Viele Gruesse,
Christian

PS: The real problem happens to use a bunch of different judy arrays,
each of which lives in its on thread; 300 judy arrays, 300 threads, each
up to 20 million inserts. But I think the basic problem can be reduced
to "how to parallelize 'ccall unsafe's.

Attachment: pgpl7QPupKvqT.pgp
Description: PGP signature

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to