久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

C++ 中的并行循環

Parallel Loops in C++(C++ 中的并行循環)
本文介紹了C++ 中的并行循環的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想知道是否有一種簡單直接的方法可以在 C++ 中并行計算諸如 for 和基于范圍的 for 循環之類的循環.你會如何實施這樣的事情?我從 Scala 知道 mapfilterforeach 函數,也許也可以并行執行這些函數?有沒有一種簡單的方法可以在 C++ 中實現這一點?

I wonder if there is a light, straight forward way to have loops such as for and range based-for loops compute in parallel in C++. How would you implement such a thing? From Scala I know the map, filter and foreach functions and maybe it would also be possible to perform these in parallel? Is there an easy way to achieve this in C++?

我的主要平臺是 Linux,但如果它可以跨平臺工作就好了.

My primary platform is Linux, but it would be nice if it worked cross-platform.

推薦答案

借助 C++17 中的并行算法,我們現在可以使用:

With the parallel algorithms in C++17 we can now use:

std::vector<std::string> foo;
std::for_each(
    std::execution::par_unseq,
    foo.begin(),
    foo.end(),
    [](auto&& item)
    {
        //do stuff with item
    });

并行計算循環.第一個參數指定執行策略

to compute loops in parallel. The first parameter specifies the execution policy

這篇關于C++ 中的并行循環的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What do compilers do with compile-time branching?(編譯器如何處理編譯時分支?)
Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 嗎?)
Checking for NULL pointer in C/C++(在 C/C++ 中檢查空指針)
Math-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比較運算符的數學式鏈接-如“if((5<j<=1)))
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之間的區別與“if())
C++, variable declaration in #39;if#39; expression(C++,if 表達式中的變量聲明)
主站蜘蛛池模板: 性色av一区二区三区 | 伊人久久网站 | 亚洲乱码在线 | 第一福利视频导航 | 丝袜美腿亚洲综合 | 99热这里| 中文字幕黄色片 | 三上悠亚一区 | 成人综合网站 | 一级片免费网站 | 亚洲成人中文字幕 | 黄色小视频免费看 | 丁香婷婷在线 | 91视频在线观看视频 | 亚洲视频免费在线观看 | 成人免费毛片aaaaaa片 | 老女人毛片| 美日韩精品 | 午夜在线免费观看 | 亚洲第一在线 | 亚洲欧美在线视频 | www.国产.com| 日产毛片 | 97色伦图片 | 国产日韩一区二区三区 | 这里都是精品 | 欧美 日韩 国产 成人 在线 | 日韩在线免费视频 | 国产日韩欧美在线 | 中文字幕一区二区在线播放 | 黄色a级网站 | 日韩精品极品视频在线观看免费 | 日韩免费视频一区二区 | 午夜成人影片 | 一区二区福利 | 日韩成人中文字幕 | 免费在线看黄网站 | 成人xxx | 成av人片一区二区三区久久 | 天堂中文字幕免费一区 | 亚州成人|