- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See code snipet below:
[cpp]for(list::iterator iter = (*block_list).begin(); iter != (*block_list).end(); iter++) { // Do someing }[/cpp]
When for loop iterate all member inside block_list variable, ideally, it should be stopped and exited, but I found that the new thread has come and start iteration again! How do I terminate all threads when it ends iteration? Thanks very much.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - nuntawat
See code snipet below:
[cpp]for(list::iterator iter = (*block_list).begin(); iter != (*block_list).end(); iter++) { // Do someing }[/cpp]
When for loop iterate all member inside block_list variable, ideally, it should be stopped and exited, but I found that the new thread has come and start iteration again! How do I terminate all threads when it ends iteration? Thanks very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Robert Reed (Intel)
I fear there's just not enough context here to make much of a guess about what may be going on with your code. Could you provide more of the details, showing at least how you engaged your iterator in the context of a parallel_reduce call?
There is a lot of codes, but I captured only codes used to determine condition and iterate loop inside.
[cpp]
public:
static currentMutex_t mutex;
static point_t current_point;
void operator() (const blocked_range& range) const { // Begin Queuing Mutex Lock currentMutex_t::scoped_lock lock(mutex, false); int block_num = 0; for(list ::iterator iter = (*block_list).begin(); iter != (*block_list).end(); iter++) { local_work(*iter, &block_num, lock); } } void local_work(unsigned char **xc, int *block_num, currentMutex_t::scoped_lock &lock) const { int tmp_x_pos, tmp_y_pos; tmp_x_pos = current_point.x_pos; tmp_y_pos = current_point.y_pos;
for(int i = tmp_y_pos; i < tmp_y_pos + pixel_per_block; i++) { for(int j = tmp_x_pos; j < tmp_x_pos + pixel_per_block; j++) {
// Do sometasks... } }
if((current_point.x_pos + pixel_per_block) < ncols) { if(((current_point.y_pos + pixel_per_block) <= nrows) || (current_point.y_pos == nrows)) { lock.scoped_lock::upgrade_to_writer();
current_point.x_pos += pixel_per_block; current_point.y_pos -= pixel_per_block;
lock.downgrade_to_reader(); } } else if (current_point.y_pos != nrows) { lock.scoped_lock::upgrade_to_writer(); current_point.x_pos = 0; (*block_num)++; lock.downgrade_to_reader(); } }
[/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have only briefly glanced at the code, but it seems highly problematic that you want to use blocked_range without actually using the parameter range. That's after I never understood what a linear list was doing here, and I still don't see it. Plus there's the current_point navigation: are you certain this wouldn't work better with blocked_range2d on the pixels?

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