Hi.sorry for the bad english it's not my native languauge.
I just started to discover cilk plus,but I'm already stucked.
I got visual studio 2010 on my win 7.
I installed intel parralell composer 2011 xehttp://software.intel.com/en-us/articles/intel-parallel-studio-xe/
Also installed cilk sdkhttp://software.intel.com/en-us/articles/intel-cilk-plus-software-development-kit/
After then I started new project set the compiler to intel c++, and checked the settings like enable cilk keywords etc, as they are in the tutorial.
When I use the cilk keywords, my visual studio says
1 IntelliSense: identifier "_Cilk_spawn" is undefined
But i can run the program after all.
I implented the two version of fibonachi. the one with serial,and the one with parralel programing. I put a timer on the code, but after a couple of tests, the one with cilk words seems slower,than the serial one.I tested them on two different pc with different dual core processors.Pls Can anybody help me, what am i doing wrong? here are my codes.
Parralel with cilk keywords:
int Pfib(int n)
{
if(n <= 1)
{
return n;
}
else
{
int x,y;
x = _Cilk_spawn Pfib(n-1);
y = Pfib(n-2);
_Cilk_sync;
return x + y;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
int n, result;
n = 40;
LARGE_INTEGER frequency; // ticks per second
LARGE_INTEGER t1, t2; // ticks
double elapsedTime;
// get ticks per second
QueryPerformanceFrequency(&frequency);
// start timer
QueryPerformanceCounter(&t1);
///
result = Pfib(n);
///
QueryPerformanceCounter(&t2);
// compute and print the elapsed time in millisec
elapsedTime = (t2.QuadPart - t1.QuadPart) * 1000.0 / frequency.QuadPart;
cout << elapsedTime << " ms.\\n";
///
printf ("Result: %d\\n", result);
system("PAUSE");
return 0;
}
Serial:
int fib (int n)
{
if (n<2) return (n);
else
{
int x, y;
x = fib (n-1);
y = fib (n-2);
return (x+y);
}
}
int main (int argc, char *argv[])
{
int n, result;
n = 40;
///
LARGE_INTEGER frequency; // ticks per second
LARGE_INTEGER t1, t2; // ticks
double elapsedTime;
// get ticks per second
QueryPerformanceFrequency(&frequency);
// start timer
QueryPerformanceCounter(&t1);
///
result = fib (n);
///
QueryPerformanceCounter(&t2);
// compute and print the elapsed time in millisec
elapsedTime = (t2.QuadPart - t1.QuadPart) * 1000.0 / frequency.QuadPart;
cout << elapsedTime << " ms.\\n";
printf ("Result: %d\\n", result);
system("pause");
return 0;
}
Visual studio 2010 errors
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.



