- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I've recently started using TBB for some of my algorithmsand would like to know if there is some "clever" way to manage status bar updates. Imagine a loop that goes from 1 to n doing something and updating a status bar as it motors along. Let's assume this has been converted to a parallel_for - how would we update the status.
Putting a lock around the statusbar isa possibility but I dont want to resort to that. Is there a point where I can insert status bar updates as each parallel task completes ? I imagine this is a problem others have encountered and I'm interested in seeinghow this has been tackled.
Thanks for any help on this topic. This forum's great - please keep up the good work.
Regards
Sashi.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, you need to count how much of total progress is made, as the loop index does not do this job anymore. Thus you need a separate atomic variable (e.g. tbb::atomic
Second, you need to update the visual element. In general, this can only be done under lock, but you are right that it's not the best idea. However the good thing about the progress bar is that it's not precise; it does not matter if it updates on every iteration or not. Thus you might apply some techniques to reduce lock contention. How often should you update the bar so that it does not appear frozen? If once per 10 or 100 iterations is sufficient, do that (based on the atomic counter of course). Then, if some thread is updating the bar, other threads should not wait; the next update will show total progress anyway. Therefore instead of acquiring a lock, you use try-acquire, and if unsuccessful, just proceed to the next iteration without waiting.
This still will have some performance impact, but hopefully negligible or at least justified enough by the ability for users to see that your program is making progress. I've heard that some program developers got user complains about the parallel version being slower, while in fact it was faster but did not show its progress.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MADakukanov:
I've heard that some program developers got user complains about the parallel version being slower, while in fact it was faster but did not show its progress.
Well I better make sure I fix that status bar :) Thanks for the tip.
-Sashi.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page