C++ 中类似 fork 的堆栈复制线程

编程入门 行业动态 更新时间:2024-10-23 18:35:11
本文介绍了C++ 中类似 fork 的堆栈复制线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我做一些递归计算,喜欢将工作分给多个 CPU.然而,当在一些递归工作中时,让一个新线程在我们当前所在的位置继续运行是非常复杂的,而没有对递归结构进行人工寻址方案的开销.

I do some recursive computation and like to divide the work to multiple CPUs. However, when inside some recursive work, it is very elaborate to get a new thread continue where we currently are, without the overhead of an artifical adressing-scheme to the recursed structures.

对于大规模操作,fork() 做得很好,因为结果子进程继续工作,只是根据其 id 决定其他树路径.

For large scale operations, fork() does this nicely as the resulting child process continues the work, just deciding for other tree pathes depending on its id.

对于较小的工作,fork() 过于重量级而无用,尤其是在需要复杂的内存映射来集成所有子进程的结果时.

For smaller works, fork() is too heavyweight to be useful, especially when complex memory mapping would be needed to integrate the results of all child processes.

是否有任何线程框架的作用类似于 fork() 并且可以从当前执行位置继续新线程?

Is there any thread framework that acts like fork() and may continue the new thread from the current execution location?

推荐答案

您可能需要查看英特尔的线程构建块.

You may want to look at Intel's Threading Building Blocks.

www.threadingbuildingblocks/

这里有一个案例研究,它被用于 Dreamworks 的数据调节问题,这是一个递归问题.

Here's a case study of it being used on a data conditioning problem at Dreamworks, which is a recursive problem.

software.intel/en-us/articles/case-study-parallelizing-a-recursive-problem-with-intel-threading-building-blocks

更多推荐

C++ 中类似 fork 的堆栈复制线程

本文发布于:2023-10-09 06:19:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474937.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:堆栈   线程   类似   fork

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!