- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I am Sheba and am just beginning to learn abt the Intel TBB & using it.
I have a written a simple program which performs color conversion. I have used the parallel_for routine.
I note that sometimes the function runs completely without hanging but most of the time, it hangs up throwing "Unidentified exception". I am not able to decipher what might be the problem. Could you please help me out.
Sheba
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Guys, you keep amazing me - you are so inventive to misuse not only TBB but basic C++ constructs :)
Try this serial loop:
[bash]for( unsigned i=0; i!=19; i+=2) printf("%dn");[/bash]
Do I need to say that the loop will never end, because the loop variable will never equal 19?
Same in your TBB program - the variable may never equal r.end() if you move throughthe loopwith a step bigger than 1. Use "less than" for comparison if you need such a step. And make sure you do NOT use "less than or equal to", because the blocked_range class represents ahalf-open interval [ r.begin(), r.end() ). In other words, the value returned by r.end() does not belong to the range being processed, and there is another range starting from this value, or the value is one past the end of iteration space.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sheba. Welcome to the forum. If you're new to forums, it would help if you know that for the kind of question you posted, there could be a lot of possible causes for the problem you're facing.
For us to be able to help you faster, or for us to be able to help you at all, you need to post the code you tried out. That'll help us figure out where the program could have a bug.
Could you start off by posting the code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I just resolved the issue. This was the code:
void operator()( const blocked_range
{
/* Local copy of the buffer for faster access */
unsigned char *temp= pcDataInBuffer;
for (size_t i = r.begin(); i != r.end(); i++)
{
.........................
}
};
Instead of i++, I had used i = i+3;
This was causing the excption. I was running the code on an 8-core machine.
But when i changed it to i++, it seems to be working fine.
Thanks.
Sheba
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cool! After seeing your code, I tried the same thing:
void operator() (const blocked_range
{
for(int i=r.begin();i!=r.end();i+=2)
{//iterates over the entire chunk
p_array_sum = p_array_a + p_array_b;
}
}
For i+=3, it shows a segmentation fault
My program is supposed to output only few lines which say how much of time the for loop took to execute, in seconds and microseconds. It prints those lines, but for i+=2, I was surprised to see a 50000 line output.
Some of it looked like this:
Grainsize=10000 and AverageIterations performed for every time calculation=5
0 seconds and 163 micro-seconds Serial time
Number of threads set=2
0 seconds and 610 micro-seconds Parallel time
1 + 1 = 2 AND 0
2 + 2 = 4 AND 0
5 + 5 = 10 AND 0
13 + 13 = 26 AND 0
34 + 34 = 68 AND 0
89 + 89 = 178 AND 0
233 + 233 = 466 AND 0
610 + 610 = 1220 AND 0
1597 + 1597 = 3194 AND 0
4181 + 4181 = 8362 AND 0
10946 + 10946 = 21892 AND 0
28657 + 28657 = 57314 AND 0
75025 + 75025 = 150050 AND 0
196418 + 196418 = 392836 AND 0
514229 + 514229 = 1028458 AND 0
1346269 + 1346269 = 2692538 AND 0
3524578 + 3524578 = 7049156 AND 0
9227465 + 9227465 = 18454930 AND 0
24157817 + 24157817 = 48315634 AND 0
63245986 + 63245986 = 126491972 AND 0
165580141 + 165580141 = 331160282 AND 0
433494437 + 433494437 = 866988874 AND 0
61161347 + 61161347 = 122322694 AND 0
823731427 + 823731427 = 1647462854 AND 0
262549288 + 262549288 = 525098576 AND 0
1037658260 + 1037658260 = 2075316520 AND 0
702941846 + 702941846 = 1405883692 AND 0
1071167278 + 1071167278 = 2142334556 AND 0
363076342 + 363076342 = 726152684 AND 0
18061748 + 18061748 = 36123496 AND 0
764850725 + 764850725 = 1529701450 AND 0
129006781 + 129006781 = 258013562 AND 0
695911441 + 695911441 = 1391822882 AND 0
884985719 + 884985719 = 1769971438 AND 0
885303893 + 885303893 = 1770607786 AND 0
697184137 + 697184137 = 1394368274 AND 0
132506695 + 132506695 = 265013390 AND 0
774077771 + 774077771 = 1548155542 AND 0
and it goes on and on
114339920 + 114339920 = 228679840 AND 0
500019140 + 500019140 = 1000038280 AND 0
311975677 + 311975677 = 623951354 AND 0
435907891 + 435907891 = 871815782 AND 0
995747996 + 995747996 = 1991495992 AND 0
403852451 + 403852451 = 807704902 AND 0
215809357 + 215809357 = 431618714 AND 0
243575620 + 243575620 = 487151240 AND 0
514917503 + 514917503 = 1029835006 AND 0
227435066 + 227435066 = 454870132 AND 0
167387695 + 167387695 = 334775390 AND 0
274728019 + 274728019 = 549456038 AND 0
656796362 + 656796362 = 1313592724 AND 0
621919244 + 621919244 = 1243838488 AND 0
135219547 + 135219547 = 270439094 AND 0
857481220 + 857481220 = 1714962440 AND 0
and on and on and ends with these lines:
58919272 + 58919272 = 117838544 AND 0
423379354 + 423379354 = 846758708 AND 0
137476967 + 137476967 = 274953934 AND 0
1062793370 + 1062793370 = 2125586740 AND 0
903419497 + 903419497 = 1806838994 AND 0
573723298 + 573723298 = 1147446596 AND 0
817750397 + 817750397 = 1635500794 AND 0
805786070 + 805786070 = 1611572140 AND 0
525865990 + 525865990 = 1051731980 AND 0
771811900 + 771811900 = 1543623800 AND 0
715827887 + 715827887 = 1431655774 AND 0
301929938 + 301929938 = 603859876 AND 0
189961927 + 189961927 = 379923854 AND 0
Well it has definitely sparked my curiosity. Any explanations from anybody?
btw, Sheba, if you're tweaking for loops, you'd probably want to know something from here: http://software.intel.com/en-us/forums/showthread.php?t=71119&o=d&s=lr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Guys, you keep amazing me - you are so inventive to misuse not only TBB but basic C++ constructs :)
Try this serial loop:
[bash]for( unsigned i=0; i!=19; i+=2) printf("%dn");[/bash]
Do I need to say that the loop will never end, because the loop variable will never equal 19?
Same in your TBB program - the variable may never equal r.end() if you move throughthe loopwith a step bigger than 1. Use "less than" for comparison if you need such a step. And make sure you do NOT use "less than or equal to", because the blocked_range class represents ahalf-open interval [ r.begin(), r.end() ). In other words, the value returned by r.end() does not belong to the range being processed, and there is another range starting from this value, or the value is one past the end of iteration space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
:) (cheeky grin)
I remember trying the so-called infinite loop with a friend a long time back. I don't recall the program, but we saw that the numbers went to a very high value, then became negative and came to zero and continued on in a cycle.
Your loop keeps going on and on when compiled with g++. But when compiled with Turbo C++ (DOS version), it outputs the numbers from 0 to 18, three times and stops. Puzzling.
Anyway, what I found strange from Sheba's tweak/error is that even though there was no line in my program where I outputted "someNumber + someNumber = sumNumber AND 0", the program printed those 50000 lines of it.
There was a time when I used to learn game programming tricks from buggy commercial games (You know how it works internally when you see it malfunction at some point and come up with some weird output). I didn't intend to do this with TBB, but this kind of an output might say something about how TBB works internally....or am I wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That output is not by TBB so it will hardly ever tell you anything about how TBB works. Use TBB source codefor that :)
- 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