我想利用英特尔 TBB 的库做这样的事情(伪代码):
some function( int index, Mat data, vector<int> other ) {
}
int start = 0
int end = 100
int step = 5
parallel_for( start, end, step, some function )
但是我不确定如何将附加参数传递给“某些函数”。我应该怎么做才能将我的额外数据传递给并行函数,而不是将它们设为静态/全局?
我知道您可以使用 C++ 的 lambda 函数来做到这一点,但是由于某些情况(与其他库冲突),我无法使用它。
除此之外,我知道我们可以使用 Range 来指定循环范围,但是,有什么方法可以将循环步骤设置在 Range 内?
我想提前谢谢你!
最佳答案
请参阅 http://software.intel.com/sites/products/documentation/doclib/tbb_sa/help/hh_goto.htm#tbb_userguide/parallel_for.htm 中的示例.它展示了如何为 parallel_for 手动滚动仿函数。
关于c++ - 如何在英特尔 TBB 的 parallel_for 循环中指定循环步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16011600/