OpenCL 适合基于代理的模拟吗?

发布于 2024-09-11 23:10:49 字数 198 浏览 8 评论 0原文

我正在学习 Scala,目的是使用参与者并发编写基于代理的模拟。我目前对 OpenCL 知之甚少,在我深入研究之前,谁能告诉我它是否适合/与基于代理的模拟兼容?

如果是这样,那么 ScalaCL 看起来非常有吸引力。

I'm learning Scala with the aim of writing agent based simulations using actor concurrency. I currently know very little about OpenCL, and before I dive in can anyone tell me if it is likely to be appropriate/compatible with agent based simulations?

If so, then ScalaCL looks very attractive.

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

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

发布评论

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

评论(2

橘亓 2024-09-18 23:10:49

如果您有一些可以并行化的重量级计算,并且您希望使用显卡来完成它(或其中的一部分),那么您应该使用 OpenCL。
它有一个有点奇怪的计算模型(至少如果你只知道“一般”编程而不知道 GPU 是如何工作的,或者如果你在某些数学领域有很强的背景),并且对你能做什么/如何做有相当多的限制。

所以我认为这不太可能是您正在寻找的。

Actor 与 OpenCL 关系不大,我认为两者唯一的共同点是它们都解决并行计算的问题,但从非常不同的角度来看。在我看来,actor 模型更容易理解,也可能更容易使用它(但这只是一个猜测,因为到目前为止我还没有真正与 OpenCL 发生过任何业务)。

如果您想实现基于代理的系统,那么参与者可能非常有用。您可以查看标准 scala actor 或替代实现:

  • Akka,还提供了许多附加功能演员 + 不错的文档以及
  • scalaz 中的一些演员教程

You should use OpenCL if you have some heavy weight computations that can be parallelized and you want to use your graphic card to do it (or parts of it).
It has a bit strange model of computation (at least if you know just "general" programming and not how the GPU works or if you have strong background in some areas of math), and quite some limitations what/how you can do.

So I think it's quite unlikely that's what you are looking for.

Actors have very little to do with OpenCL, I think the only commonality of the two that they both address the problem of parallel computation, but from a very different perspective. IMO the actor model is much easier to understand and probably also to use it (but it's just a guess as I didn't really have any business with OpenCL so far).

If you want to implement an agent based system then actors can be quite useful. You could have a look at standard scala actors, or alternative implementations:

  • Akka, also offering many additional functionality on top of actors + nice docs with some tutorials
  • actors in scalaz
你不是我要的菜∠ 2024-09-18 23:10:49

OpenCL 通常只适用于加速涉及使用不同数据多次执行相同操作的程序。如果您的代理都同时做同样的事情,那么它可能是合适且兼容的。

否则,两者就不能很好地结合在一起,并且 OpenCL 可能会使事情运行得更慢而不是更快。

OpenCL is generally only good for speeding up programs that involve doing the same thing many times with different data. If your agents will all be doing the same thing at the same time, then yes it might be appropriate and compatible.

Otherwise, the two just don't fit well together, and OpenCL will probably make things run slower rather than faster.

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