This was brought up in the lecture briefly. But why may this lead to different results from the sequential program depending on how myDiff is updated?
@kai I'd be interested in hearing the answer to this as well – I'd initially assume not, because it's generally better to maintain your locks for as short a duration as possible, but I'd be curious to hear whether this is always the case.
My assignment 2 partner and I actually made an improvement like this to get our threadpool run() methods to run fast enough. It can really help to compute things locally where possible and push them to a shared variable only occasionally.
@leopan You might get floating point error and end up with a different answer.
this trick is similar to reduce_add in the ispc code in the previous code
Please log in to leave a comment.
Is it ever a good strategy to call locks at different times if possible within threads be more efficient? Could this reduce the case where threads are stalled at a lock or is thread execution time too random to achieve this?