- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
I was waiting zip_iterator since a long time. I discover there are part of TBB now. Unfortunately, I get issue with GCC 7.4 (but working with my Mac/clang).
The following example work on my Mac with last version of Apple-clang (Apple clang version 11.0.0 (clang-1100.0.33.16)) but it does not compile with GCC 7.4 on my ubuntu station. I get the following error
/usr/include/c++/7/bits/predefined_ops.h:215:11: note: candidate: bool (*)(const std::tuple<float&, float&>&, const std::tuple<float&, float&>&) <conversion> /usr/include/c++/7/bits/predefined_ops.h:215:11: note: candidate expects 3 arguments, 3 provided main.cpp:30:102: note: candidate: main()::<lambda(const std::tuple<float&, float&>&, const std::tuple<float&, float&>&)> std::sort(start, end, [](const std::tuple<float&, float&>& v, const std::tuple<float&, float&>& w) { ^
#include <algorithm> #include <iostream> #include <tuple> #include <vector> #include <random> #include <tbb/iterators.h> int main() { const int N = 10; std::vector<float> a(N), b(N); // First create an instance of an engine. std::random_device rnd_device; // Specify the engine and distribution. std::mt19937 mersenne_engine {rnd_device()}; // Generates random integers std::uniform_int_distribution<int> dist {1, 52}; auto gen = [&dist, &mersenne_engine](){ return dist(mersenne_engine); }; generate(begin(a), end(a), gen); generate(begin(b), end(b), gen); auto start = tbb::make_zip_iterator(a.begin(), b.begin()); auto end = tbb::make_zip_iterator(a.end(), b.end()); std::sort(start, end, [](const std::tuple<float&, float&>& v, const std::tuple<float&, float&>& w) { return std::get<1>(v) < std::get<1>(w); }); for (int i=0; i< N; ++i) std::cout << a << " " << b << std::endl; return 0; }
Any suggestions ?
All the best
++T
- Tags:
- CC++
- Development Tools
- General Support
- Intel® Threading Building Blocks
- Optimization
- Parallel Computing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I asked internally developer of this feature to comment why 2019.8 version works vs. 2019.2.
Can you work with 2019.8 (in other words, there is no requirement in your case to work with previous version)?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hum I have been able to run the example by updated my TBB 2019.2 to TBB 2019.8 and removing the reference into the tupple
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I asked internally developer of this feature to comment why 2019.8 version works vs. 2019.2.
Can you work with 2019.8 (in other words, there is no requirement in your case to work with previous version)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you for the answer, indeed I have no problem to work with 2019.8. By the way I also remark that the sort is not "stable" following the STL implementation. Currently, GCC 7.4 and Clang-apple provide different sorting. It is not an issue, but good to know.
Have a good day, and merry xmas
++t
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your feedback. We improved TBB's zip iterator from 2019 Update 5: https://github.com/intel/tbb/blob/tbb_2020/CHANGES
It works now with algorithms such as sort that swap values via iterators.
If you're interested in C++ parallel algorithm extensions, you might want to check out Parallel STL: https://github.com/intel/parallelstl. Current version is using TBB's fancy iterators such as zip-iterator, and TBB as a backend for Threading (par and par_unseq policy)
-Pablo
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page