如何计算cilk_spawn的时间
How to calculate time for a cilk_spawn
感谢您查看帖子
我正在对一些 Cilk Plus 代码进行基准测试,并希望计算完成"生成"操作所需的时间。我只对计算生成所需的时间感兴趣,而不是 fib() 所需的计算时间。这可能吗?
将计时器放在以下代码中会按预期工作吗?如果我的想法是正确的,将"//RRS"替换为timer_start()和timer_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;
}
回答我自己的问题:
我能够在注释行"//RRS"中放置一些计时器开始/停止语句,并忠实地计算生成时间。
感谢您的关注。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- 从持续时间构造std::chrono::system_clock::time_point
- 向量 <int> a {N, 0} 和 int arr a[N] = {0} 的时间复杂度有什么区别
- while循环中while循环的时间复杂度是多少
- 使用简单类型列表实现的指数编译时间.为什么
- 是否可以在编译时初始化数组,以便在运行时不会花费时间?
- 在已经使用Git的情况下减少编译时间
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 如何将包含epoch时间的十六进制字符串转换为time_t
- 从文本文件中读取时钟时间和事件时间并进行处理
- 具有未知值时的时间复杂性
- 如何减少花费的时间
- C++在变量给定的指定时间内关闭电脑
- rcpp函数中的清理时间很长
- C++:floor unix时间戳到UTC月份
- 如何在c++中录制具有精确帧时间戳的视频
- 在两台机器之间进行时间戳的最佳c++chrono函数是什么
- KMP算法和LPS表构造的运行时间
- 为什么std::互斥需要很长的、非常不规则的时间来共享
- 使用Boost Interprocess创建托管共享内存需要很长时间