Previous | Next --- Slide 20 of 90
Back to Lecture Thumbnails
kai

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?

leopan

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?

superscalar

@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.

pinkpanther

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.

gomi

@leopan You might get floating point error and end up with a different answer.

Kecleon

this trick is similar to reduce_add in the ispc code in the previous code

Please log in to leave a comment.