C++ 中类似 fork 的堆栈复制线程 [英] fork-like stack copying threads in C++

查看:66
本文介绍了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.

https://www.threadingbuildingblocks.org/

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

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

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

这篇关于C++ 中类似 fork 的堆栈复制线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆