问题描述
我想在 Common Lisp 中并行实现我的粒子过滤算法.粒子过滤和采样可以并行化,我想为我的 4 核机器执行此操作.我的问题是在 CL 中并行编程是否可行,如果可行,是否有任何关于 CL 中并行计算入门的好读物和教程.
I want to implement my particle filtering algorithm in parallel in Common Lisp. Particle Filtering and sampling can be parallelized and I want to do this for my 4-core machine. My question is whether programming in parallel is feasible in CL or not and if it is feasible are there any good readings, tutorials about getting started to parallel computing in CL.
推荐答案
绝对可行!
波尔多线程项目为许多实现提供线程原语;我建议使用它而不是 SBCL 的特定于实现的原语(特别是如果您不在 SBCL 上!).
The Bordeaux Threads project provides thread primitives for a number of implementations; I would suggest using it instead of SBCL's implementation-specific primitives (especially if you aren't on SBCL!).
bt 提供的线程原语是非常原始的.我已经使用并喜欢 Eager Future2,它建立在 bt 之上,使用期货提供并发特性.您可以创建延迟计算、急切(立即)或推测性计算的期货.投机期货由可自定义大小的线程池计算.
The thread primitives are provided by bt are, however, quite primitive. I've used and enjoyed Eager Future2 which builds on bt to provide concurrency features using futures. You can create futures that are computed lazily, eagerly (immediately), or speculatively. The speculative futures are computed by a thread pool whose size can be customized.
我开始了一个小项目来提供使用 EF2 的 CL 函数的并行版本,但到目前为止它只有大约三个函数,所以它对任何人都没有多大用处.我当然欢迎其他编码人员对它进行 hack 并提交 pull request,我希望在未来做更多的工作.
I started a little project to provide parallel versions of CL functions using EF2, but it's only about three functions so far, so it won't be of much use to anyone. I do of course welcome other coders to hack on it and submit pull requests, and I hope to do more work on it in the future.
还有许多其他库在 Cliki 上列出,但我自己没有尝试过.
There are many other libraries listed on Cliki that I haven't tried myself.
就教程而言,我不知道有任何教程,但在其他语言中也可以找到提供的并发功能,并且好的算法和实践通常不是特定于语言的.
As far as tutorials, I don't know of any, but the concurrency features provided are found in other languages as well and good algorithms and practices are not generally language-specific.
如果您有兴趣阅读一本书,我推荐并发 C 编程语言.作者描述了一种基于 C 的新编程语言,将并发性作为语言特性.当然,由于 CL 的性质,很可能无需创建新的编译器就可以实现这些功能.在我看来,这本书展示了出色的并发概念,并解决了您在编写并发程序时可能遇到或未考虑到的许多问题.
If you're interested in reading a book, I recommend The Concurrent C Programming Language. The authors describe a new programming language, based on C, with concurrency as a language feature. Of course, due to the nature of CL, it would likely be possible to implement these features without resorting to creating a new compiler. In my opinion the book presents excellent concurrency concepts, and addresses many of the problems you may encounter or fail to consider in writing concurrent programs.
这篇关于Common Lisp 并行编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!