Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/128.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.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++ [inclusive/exclusive]并行扫描算法<;算法>;提案N3554_C++_Algorithm_Parallel Processing_C++14 - Fatal编程技术网

C++ [inclusive/exclusive]并行扫描算法<;算法>;提案N3554

C++ [inclusive/exclusive]并行扫描算法<;算法>;提案N3554,c++,algorithm,parallel-processing,c++14,C++,Algorithm,Parallel Processing,C++14,C++14的提案,提出(除其他事项外)当前版本的并行版本,例如: 模板< 类执行策略, 类输入计算器, 类输出程序, 类二进制操作> 输出计数器包含式\u扫描( ExecutionPolicy&exec, 输入者优先, 最后输入, 输出结果, 二进制操作(二进制操作); 带着解释 效果:对于[result,result+(last-first)]中的每个迭代器i,执行*i=前缀_和, 其中,前缀_sum是对应的sum init+*iter_0+*iter_1+*iter_2的结果+ …或二进制

C++14的提案,提出(除其他事项外)当前版本的并行版本,例如:

模板<
类执行策略,
类输入计算器,
类输出程序,
类二进制操作>
输出计数器包含式\u扫描(
ExecutionPolicy&exec,
输入者优先,
最后输入,
输出结果,
二进制操作(二进制操作);
带着解释

效果:对于[result,result+(last-first)]中的每个迭代器i,执行*i=前缀_和, 其中,前缀_sum是对应的sum init+*iter_0+*iter_1+*iter_2的结果+ …或二进制运算(init,二进制运算(*iter_0,二进制运算(*iter_1,二进制运算(*iter_2,…)) 对于[first,first+(i-result)-1]范围内的每个迭代器Iterj,总和的操作数顺序未指定


这个操作怎么可能是并行的呢?几乎从定义上看,每个输出前缀_和都必须计算出来,以便下一个要计算的输出前缀_和——基本上导致了一个串行操作



编辑非常感谢Aasmund Eldhuset的回答。就我个人而言,我发现这是非常有用的。

是一种经典的分布式编程算法,它优雅地使用了一个简化后的分布(如本文所示)。关键的观察是,你可以在知道前导项之前计算部分和。

谢谢你的有趣链接!@AmiTavory:很高兴你喜欢这篇文章(而且我需要刷新我自己的记忆)!看起来像是一篇很好的、容易理解的论文;谢谢!
template<
    class ExecutionPolicy,
    class InputIterator,
    class OutputIterator,
    class BinaryOperation>
OutputIterator inclusive_scan(
    ExecutionPolicy &&exec,
    InputIterator first,
    InputIterator last,
    OutputIterator result,
    BinaryOperation binary_op);