- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've tried to use tbb::concurent_vector and I've thought that if I call push_back conccurently then it's not guaranteed that insertion is serios(for example I fill vector in parallel_for), however as I've found out I was wrong(I've even make delay in a thread in order to change push_back order by others).
For more clearly short extract from my test
For more clearly short extract from my test
[bash]void test(int count, bool makeReserve) {
TBBVector arr1;
STDVector arr2;
std::cout << getExecutingTime(arr1, count, makeReserve) << '\n'
<< getExecutingTime(arr2, count, makeReserve) << '\n';
assert(std::equal(arr1.begin(), arr1.begin(), arr2.begin()) == true);
assert(false);//just to ensure that assert works properly
}
am I right?
I've attached my full test.
P.S. I use tbb3
[/bash]
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Denis, if two threads executing push_back() simultaneously, the order of elements is not defined and actually can not be serialized. So, it seems you have no parallelism there, e.g. 'count' can be too small so it is executed by only one thread without possibility for other threads to steal some work. (I don't see your full code)
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Denis, if two threads executing push_back() simultaneously, the order of elements is not defined and actually can not be serialized. So, it seems you have no parallelism there, e.g. 'count' can be too small so it is executed by only one thread without possibility for other threads to steal some work. (I don't see your full code)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
I was attaching my test, it seems I did something wrong(in my tests I used about 1000000 counts and sometimes passed to task_shceduler_init value 100.)
I was attaching my test, it seems I did something wrong(in my tests I used about 1000000 counts and sometimes passed to task_shceduler_init value 100.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Allocation of locations is serialised, but it is not guaranteed that preceding locations are already initialised.
You should not normally provide an argument to task_scheduler_init().
You should not normally provide an argument to task_scheduler_init().
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