I have put 3 tasks in parallel: print min, max, and average of two numbers. The first task prints min value twice, and I expect it's output to be contiguous.
int wmain()
{
__int64 elapsed;
elapsed = time_call([&]
{
double a = 1.0;
double b = 5.0;
parallel_invoke(
[&]{for( size_t i = 0; i < 2; ++i )
{
PrintMinValue(a, b);
}},
[&]{PrintMaxValue(a, b);},
[&]{PrintAvgValue(a, b);});
});
wcout << L"parallel time: " << elapsed << L" ms" << endl << endl;
}
I ran this program several times. All outputs such as 5, 3, 1, 1 or 3, 1, 1, 5 are understandable. However, some outputs such as 1, 5, 3, 1 are not obvious. It means that the first task that must print "1" (min value) twice in a contiguous block is split. Why?