- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
History of my query can be found here :
So, My query is regarding the pushback API in Intel latest Tbb version. In the older version of tbb (libtbb2.4.2~20130725), we were able to get an index while doing push_back.
like in this code example :
vector<my_data_structure> sample_vector;
int sizes = sample_vector.size();
index_of_pushed_element = sample_vector.push_back(my_data_structure_element);
and code of push_back api in older version of tbb is:
In this function k variable returning index of last inserted element in vector.
But in the newer version of tbb(oneapi-tbb-2021.6.0-lin.tgz) Intel has changed the code of push_back API. where we get only the iterator of the last push_back element.
push_back function code in new tbb(oneapi-tbb-2021.6.0-lin.tg) :
So my query is how we can get the index of elements while doing push_back in vector in a multithreaded system?
Note: We tried to get an index by computing (iter- v.begin().
iter is iterator of last index element in v vector.
but there is one problem that this will not work in multithread system because the v.begin() value can changed by other threads.
this is link of - operator of vector_iterator class.
I have one suggestion if possible please check this:
In vector_iterator class of new tbb(oneapi-tbb-2021.6.0-lin.tgz) which defined in concurrent_vector.h file. In that class my_index is defined and this is the value of the index in the iterator but the problem is, it is defined in private so we can't access it from iterator directly.
private:
// concurrent_vector over which we are iterating.
vector_type* my_vector;
// Index into the vector
size_type my_index;
// Caches my_vector *it;
// If my_item == nullptr cached value is not available use internal_subscript(my_index)
mutable value_type* my_item;
}; // class vector_iterator
link of that line of my_index.
So my suggestion is that , if possible please make this variable ( my_index ) public or add some getter function to get this index of iterator so we can get index of element while push_back it by using iterator.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for posting in Intel Communities.
We kindly request that you provide us with further details to assist us in resolving your issue. Specifically, we would appreciate if you could provide the following information:
1. A sample reproducer and the steps you followed.
2. Please provide information on how you are attempting to set up multiple threads.
3. We would like to understand how the application's behavior differs when multiple threads are utilized.
4. Have you tried running your code with oneTBB 2021.8.0? If yes, Please do share the results.
Thanks & Regards,
Vankudothu Vaishnavi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you. Could you please provide us with an update on your issue?
Thanks & Regards,
Vankudothu Vaishnavi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you, so we will close this inquiry now. If you need further assistance, please post a new question.
Thanks & Regards,
Vankudothu Vaishnavi.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page