Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何计算cilk_产卵的时间_C++_C_Execution Time_Gprof_Cilk - Fatal编程技术网

C++ 如何计算cilk_产卵的时间

C++ 如何计算cilk_产卵的时间,c++,c,execution-time,gprof,cilk,C++,C,Execution Time,Gprof,Cilk,谢谢你看这篇文章 我正在对一些Cilk Plus代码进行基准测试,并希望计算完成“生成”操作所需的时间。我感兴趣的是只计算生成所需的时间,而不是fib()所需的计算时间。这可能吗 将计时器放在下面的代码中会像预期的那样工作吗?如果我的想法是正确的,将“//RRS”替换为timer\u start()和timer\u stop(),完成工作吗 #include <stdio.h> #include <stdlib.h>   int fib(int n) { if (n

谢谢你看这篇文章

我正在对一些Cilk Plus代码进行基准测试,并希望计算完成“生成”操作所需的时间。我感兴趣的是只计算生成所需的时间,而不是fib()所需的计算时间。这可能吗

将计时器放在下面的代码中会像预期的那样工作吗?如果我的想法是正确的,将“//RRS”替换为timer\u start()和timer\u stop(),完成工作吗

#include <stdio.h>
#include <stdlib.h>   
int fib(int n)
{
  if (n < 2) return n;
  else {
  // RRS: Start timer t1 here ??
  int x = cilk_spawn fib(n-1);
  // RRS: Stop timer t1 here ??

  int y = fib(n-2);

  // RRS: Start timer t2 here ??       
  cilk_sync;
  // RRS: Stop timer t2 here ??

  return x + y;
  }
}
 
int main(int argc, char *argv[])
{
  int n = atoi(argv[1]);
  int result = fib(n);
  printf("Fibonacci of %d is %d.\n", n, result);
  return 0;
}
#包括
#包括
整数fib(整数n)
{
如果(n<2)返回n;
否则{
//RRS:在这里启动计时器t1??
int x=cilk_产卵fib(n-1);
//RRS:在这里停止计时器t1??
int y=fib(n-2);
//RRS:在这里启动计时器t2??
cilk_同步;
//在这里停止计时器t2??
返回x+y;
}
}
 
int main(int argc,char*argv[])
{
int n=atoi(argv[1]);
int结果=fib(n);
printf(“Fibonacci的%d是%d.\n”,n,result);
返回0;
}

回答我自己的问题:

我能够在注释行“//RRS”中放置一些计时器开始/停止语句,并忠实地计算spawn的时间

谢谢你的关注