- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello peoples!
So I have what seems (from my point of view) to be a perfectly fine nested group of parallel_fors:
[cpp]parallel_for(primes.begin(), (primes.end()) - 2, { if((primes.size()) < 3) return; parallel_for(MINEXP, j + 1, [=](int expo) { i = 3*(primes.front())+3; pow((double)i, 1/expo); if(!((i%1)<1)) fout << "Sum of " << primes.front() << ":" << (primes.front()) + 3 << " = " << i << "^" << expo << "\n"; }); });[/cpp]
Yet, I'm getting all sorts of errors:
[bash]1>------ Build started: Project: primeExp, Configuration: Debug Win32 ------ 1> main.cpp 1>c:\program files\intel\tbb\tbb30_196oss\include\tbb\_tbb_windef.h(60): warning : Recommend using /MD if compiling with TBB_USE_DEBUG==0 1>c:\users\\documents\visual studio 2010\projects\primeexp\primeexp\main.cpp(49): error C2143: syntax error : missing ')' before '{' 1>c:\users\\documents\visual studio 2010\projects\primeexp\primeexp\main.cpp(49): error C2059: syntax error : ')' 1>c:\users\\documents\visual studio 2010\projects\primeexp\primeexp\main.cpp(49): error C2143: syntax error : missing ';' before '{' 1>c:\users\\documents\visual studio 2010\projects\primeexp\primeexp\main.cpp(49): error C2059: syntax error : ')' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== [/bash]I think the first error is causing the rest. Am I doing something wrong?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A C++0x enabled compiler should reject the code. The problem is the third argument to the outer parallel_for is a brace-deliminted block of code. That's not alowed even in C++0x. I'm guessing that you meant to have a lambda expression there.
Also, the three-argument form of parallel_for expects arguments of integral type for the first two arguments. So either use the initial and one-past-last subscript for the first two arguments, or consider using tbb::parallel_for_each, which acts similarly to std::for_each, but with parallel semantics.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This error appears because C++0x support is not enabled in compiler. In Intel compliler this option is"/Qstd=c++0x" in windows or "-std=c++0x" in Linux.
If you use Visual Studio, go to project properties->C++->Language->Intel specific->Enable C++0x support and set "Yes".
Regards,
Kirill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A C++0x enabled compiler should reject the code. The problem is the third argument to the outer parallel_for is a brace-deliminted block of code. That's not alowed even in C++0x. I'm guessing that you meant to have a lambda expression there.
Also, the three-argument form of parallel_for expects arguments of integral type for the first two arguments. So either use the initial and one-past-last subscript for the first two arguments, or consider using tbb::parallel_for_each, which acts similarly to std::for_each, but with parallel semantics.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page