TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Extend the life of threads with synchronization (C++11)

16 点作者 indatawetrust将近 9 年前

1 comment

obi1kenobi将近 9 年前
My two cents -- just use Cilk Plus: <a href="https:&#x2F;&#x2F;www.cilkplus.org&#x2F;tutorial-cilk-plus-keywords#spawn_and_sync" rel="nofollow">https:&#x2F;&#x2F;www.cilkplus.org&#x2F;tutorial-cilk-plus-keywords#spawn_a...</a><p>Why I like it:<p>- easy to learn (3 keywords total: cilk_spawn, cilk_sync, cilk_for)<p>- runtime handles thread creation, deciding appropriate number of threads based on hardware<p>- provably efficient work-stealing scheduler<p>- natively supported in GCC 5, branches available for GCC 4.8&#x2F;4.9 and Clang<p>- comes with a race detector (guaranteed to discover determinacy&#x2F;data races)<p>- trivial to convert your parallel code to serial (#define spawn&#x2F;sync keywords -&gt; empty string, and cilk_for -&gt; for)