Critical section uses a shared variable so any case you have multiple threads writing to a variable you should have a critical section, it's very general. I don't have much experience with reduction but it seems geared towards all loops preforming the same function as part of a larger function and they take approximately the same amount of time to complete plus are expected to start and end together. Something like parallelizing an integral by spliting it into ranges would be simpler with reduction. Also if the threads need to read and write to the global, seems like that would need a critical section.
this post was submitted on 13 Jun 2023
9 points (100.0% liked)
Programming
13387 readers
13 users here now
All things programming and coding related. Subcommunity of Technology.
This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.
founded 2 years ago
MODERATORS