What is a spark in Haskell

I am confused about the concept of "spark"

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

Thanks to everyone:

So, to compose, sparks are not streams, but more units of calculation (tasks for placement in terms of C # / Java). Thus, Haskell implements the parallelism task.

+46
multithreading parallel-processing haskell multicore
Jun 05 '09 at 22:33
source share
4 answers

See Gentle Introduction to Glasgow Parallel Haskell.

Parallelism is introduced in GPH by the par combinator, which takes two arguments that must be evaluated in parallel. The expression p `par` e (here we use the Haskell notation for the infix operator) has the same meaning as e , and is not strict in its first argument, i.e. bottom `par` e is e . ( bottom stands for computation without end or failure.) Its dynamic behavior is to indicate that p can be evaluated by a new parallel thread, while the parent thread continues to evaluate e . We say that p was called, and subsequently a thread can be created to evaluate it if the processor is idle. Since the stream is not necessarily created, p is like a lazy future.

[Emphasis in the original]

+32
Jun 05 '09 at 22:46
source share

Sparks are not threads. forkIO represents Haskell threads (which display fewer real OS threads). Sparks create entries in work queues for each thread, from which they will perform tasks for execution if the thread becomes inactive.

As a result, sparks are very cheap (you can have billions of them in the program, while you probably won't have more than a million Haskell threads and less than a dozen OS threads per half dozen cores).

Think of it this way:

spark model

+87
Jun 06 '09 at 4:30
source share

If I understand correctly, a spark is an entry in the queue of tasks requiring work. The thread pool receives entries from this queue and starts them. Typically, there is one thread per physical processor, so this circuit maximizes throughput and minimizes thread context switching.

+3
Jun 06 '09 at 19:49
source share

It looks like it is like a β€œtask” in Intel Threading Building Blocks.

0
Dec 16 '09 at 20:03
source share



All Articles