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

C++ 中的并行循環(huán)

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

問題描述

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

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 中的并行算法,我們現(xiàn)在可以使用:

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
    });

并行計算循環(huán).第一個參數(shù)指定執(zhí)行策略

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

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

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

相關(guān)文檔推薦

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;(比較運算符的數(shù)學(xué)式鏈接-如“if((5<j<=1)))
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之間的區(qū)別與“if())
C++, variable declaration in #39;if#39; expression(C++,if 表達(dá)式中的變量聲明)
主站蜘蛛池模板: 伊大人久久 | 成人水多啪啪片 | 亚洲综合无码一区二区 | 黄网站免费入口 | 午夜黄色 | 久久看精品 | 久久大陆 | 国精产品一区一区三区免费完 | 免费性视频| 亚洲国产精品一区二区久久 | 第一av | 亚洲成人av在线播放 | 国产精品夜夜夜一区二区三区尤 | 成人1区| 99精品一区二区 | 亚洲精品在线免费看 | 日韩影音| 亚洲一区中文字幕 | 欧美a在线| 欧美一区二区三区在线观看视频 | 国产激情三区 | 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 视频一区二区在线 | 午夜影院| 欧美日韩精品专区 | 在线观看免费毛片 | 成人日韩 | 精品一区二区三区在线观看国产 | 午夜电影网址 | 伊人超碰 | 国产一区二区免费电影 | www.xxxx欧美| 中文字幕精品一区 | 91看片免费版 | 日韩av在线一区二区 | 999精品在线 | 亚洲精品一区二区另类图片 | 精品美女在线观看视频在线观看 | 免费色网址| 国产精品精品久久久 | 男人天堂网址 |