什么是“火花”?在Haskell [英] What is a "spark" in Haskell

查看:117
本文介绍了什么是“火花”?在Haskell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对spark的概念感到困惑

它是Haskell中的一个线程吗?或者是产生新线程的行为?

谢谢大家:

因此,总结一下,火花不是线程,而是更多的计算单位把它放在C#/ Java术语中)。所以这就是Haskell实现任务并行的方式。 解决方案

请参阅格拉斯哥并行Haskell简介


并行性由GPH中的 par 组合子引入,该组合子需要并行计算两个参数。表达式 p`par` e (这里我们使用Haskell的中缀操作符表示)具有与 e 相同的值,并且在第一个参数中不是严格的,即 bottom`par` e 的值为 e 。 ( bottom 表示一个非终止或失败的计算)。它的动态行为是指示 p 可以通过一个新的并行线程,父线程继续评估 e 。我们说 p 已经被触发,并且随后可以创建一个线程来评估处理器是否空闲。由于线程不一定是创建的,因此 p 类似于懒惰的未来

[强调原创]


I'm confused about the notion of "spark"

Is it a thread in Haskell? Or is the action of spawning a new thread ?

Thanks everybody:

So to summarize, sparks are not thread but more of unit of computation (tasks to put it in C#/Java terms). So it's the Haskell way of implementing the task parallelism.

解决方案

See A Gentle Introduction to Glasgow Parallel Haskell.

Parallelism is introduced in GPH by the par combinator, which takes two arguments that are to be evaluated in parallel. The expression p `par` e (here we use Haskell's infix operator notation) has the same value as e, and is not strict in its first argument, i.e. bottom `par` e has the value of e. (bottom denotes a non-terminating or failing computation.) Its dynamic behaviour is to indicate that p could be evaluated by a new parallel thread, with the parent thread continuing evaluation of e. We say that p has been sparked, and a thread may subsequently be created to evaluate it if a processor becomes idle. Since the thread is not necessarily created, p is similar to a lazy future.

[Emphasis in original]

这篇关于什么是“火花”?在Haskell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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