使用哪个线程并行接口来使用堆栈进行任务共享和拆分?

发布于 2024-12-17 20:33:14 字数 172 浏览 1 评论 0原文

我计划编写一个代码,我想使用可以拆分的任务来共享工作。在串行版本中,我使用用根任务初始化的堆栈。通过重复弹出任务来清空堆栈,然后执行或拆分该任务,并将子任务推回到堆栈上。并行实现此功能的最佳(最有效且最轻松)的方式和接口(tbb、openmp 等)是什么?任何线程并行接口都明确支持这样的并行堆栈(或者是否有更好的堆栈替代方案)?

I am planning to write a code where I want to share the work using tasks which can be split. In a serial version, I use a stack initialised with the root task. The stack is emptied by repeatedly popping a task, which is then either performed or split and the sub-tasked pushed back on the stack. What is the best (most efficient and effortless) way and interface (tbb, openmp, etc) to implement this in parallel? Is a parallel stack like this explicitly supported by any thread-parallel interface (or is there a better alternative to a stack)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小伙你站住 2024-12-24 20:33:14

您实际上描述的是一个工作窃取队列。这首先是 Cilk 编程语言 (http://en.wikipedia.org/wiki/Cilk),然后是英特尔编译器一部分的 Cilk++。您可以获得 Linux 的免费评估版本。

英特尔 TBB 还具有工作窃取队列,并支持自动拆分任务,如果您想自己拆分任务,还可以进行额外的控制。 OpenMP没有这种控制,但我不认为这是不可能做到的。

还有来自 Sandia 的 qthreads (https://code.google.com/p/qthreads/),这是一个很好的软件包,允许您拥有 M:N 调度程序(N 个操作系统线程上的 M 个用户级线程)。

What you are actually describing is a work-stealing queue. This has started with the Cilk programming language (http://en.wikipedia.org/wiki/Cilk) and continues with Cilk++ that is part of the Intel Compiler. You can get a free evaluation version for Linux.

Intel TBB also features a work-stealing queue and supports automatic splitting of tasks, plus additional control if you want to split them yourself. OpenMP does not have this kind of control but I don't think it is impossible to do.

There is also qthreads from Sandia (https://code.google.com/p/qthreads/) which a nice package that allows you to have an M:N scheduler (M user level threads on N OS threads).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文