Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
535 views
in Technique[技术] by (71.8m points)

multithreading - fork-like stack copying threads in C++

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.

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.

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

https://www.threadingbuildingblocks.org/

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...