On Thu, Sep 1, 2016 at 2:17 PM, digxx <diger_d...@hotmail.com> wrote:
> Do you have a "simple" example of how to write something "thread safe" if > I plan to use @threads ? > Some parts of the runtime are still not threasafe. I also don't think there's a meaningful "simple example" of writing something "thread safe". It strongly depend on what you want to do. > > > Am Mittwoch, 31. August 2016 07:35:06 UTC+2 schrieb Chris Rackauckas: >> >> That's pretty much it. Threads are shared memory, which have less >> overhead (and are thus faster), and can share variables between them. >> @parallel is multiprocessing, i.e. each worker process has its own set of >> defined variables which do not overlap, and data has to be transferred >> between them. @parallel has the advantage that it does not have to be >> local: different processes can be on completely different computers/nodes. >> But it has a higher startup cost and is thus better suited to larger >> parallelizable problems. >> >> However, as Yichao states, @threads is still experimental. For one, since >> the memory is shared, you have have to make sure everything is >> "thread-safe" in order to be correct and not fail (example: two threads >> can't write to the same spot at once or else it can be non-deterministic as >> to what the result is). But also, the internals still have some rough >> edges. Just check out the repo for bug reports and you'll see that things >> can still go wrong, or that your performance can even decrease due to >> type-inference bugs. <https://github.com/JuliaLang/julia/issues/17395> Thus >> it is something to play around with, but it definitely isn't something that >> you should put into production yet (though in many cases it is already >> looking pretty good!). >> >> On Tuesday, August 30, 2016 at 5:46:57 PM UTC-7, Andrew wrote: >>> >>> I have also been wondering this. I tried @threads yesterday and it got >>> me around a 4-fold speedup on a loop which applied a function to each >>> element in an array, and I conveniently didn't need to bother using >>> SharedArrays as I would with @parallel. >>> >>> On Tuesday, August 30, 2016 at 7:20:36 PM UTC-4, digxx wrote: >>>> >>>> Sorry if there is already some information on this though I didnt find >>>> it... >>>> So: What is the difference between these? >>>> I have used @parallel so far for parallel loops but recently saw this >>>> @threads all in some video and I was wondering what the difference is? >>>> Could anyone elaborate or give me a link with some info? >>>> Thanks digxx >>>> >>>