1) When you work with numerics, you have to take into account that 
numerical operations are typically order(s) of magnitude faster and consume 
much less resources per element than any of those concurrency mechanisms.
2) It is important whether the problem you're working on parallelizable in 
itself. Some algorithms are embarrassingly parallelizable, some are 
inherently sequential. The first step is to find out where your algorithm 
falls in this spectrum, and whether there is a more parallelizable 
algorithm, or any clever trick that could help with your problem.
3) Most of the mechanisms you mention are intended to work with heavier 
objects, not primitive numbers one-by-one. If you want to work with 
millions of numbers in parallel, you either separate them in batches, as 
Alex suggested, or have to go with optimized CPU solutions or GPUs.

On Tuesday, January 31, 2017 at 4:44:06 AM UTC+1, Brian Craft wrote:
>
> I think java locks may be the only good answer. I can't usefully divide 
> the vector, because the distribution of updates is uniform along the length 
> of it.
>
> Perhaps there's a solution with queues, with multiple threads generating 
> potential placements, and a single thread updating the vector and 
> re-queuing any conflicting placements.
>
> On Monday, January 30, 2017 at 7:11:03 PM UTC-8, Alex Miller wrote:
>>
>> One technique is to batch locks at a coarser granularity. You've explored 
>> both ends of the spectrum - 1 lock and N locks. You can also divide the 
>> overall vector into any group of refs between 1 and N.
>>
>> If refs are too heavy, there are several other locking mechanisms on the 
>> JVM. You could try Clojure atoms or Java locks. Atoms can only be used to 
>> protect a single value so you would need a protocol for locking acquisition 
>> to deal with that. For something like that, you'd probably end up using a 
>> mutable data structure like a Java array.
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to