1484244796 by Unknown

1484244796 by Unknown

Author:Unknown
Language: eng
Format: epub
Published: 2019-04-25T15:38:33+00:00


Chapter 8 Working in Several CoreS

efficiently. A standard approach to this problem is to introduce an intermediate message broker. AMQP is a common protocol for dealing with message queues. There are several implementations; RabbitMQ is a widely used one. The amqp-worker package provides a

simple interface for exchanging messages via this protocol and leverages several Haskell-

specific techniques.

Tip “Concurrency is about dealing with lots of things at once. parallelism is about doing a lot of things at once.” – rob pike

The fields of parallel, concurrent, and distributed programming in Haskell are

much wider than what will be shown in this chapter. The libraries explained here can

be used in many other ways, and many other packages are available in Hackage. For

parallel programming you have the parallel package, which features the strategies

approach. Parallelism is not only available for processors. Accelerate builds code to be

run in a GPU. Haskell’s base package features low-level functionality for concurrency

in the Control.Concurrent module, including mutable memory locations (MVars) and

semaphores. The distributed-process set of packages introduces Erlang-style actors

which can share both code and data. The book Parallel and Concurrent Programming

in Haskell by Simon Marlow describes several of these techniques in much more depth than this chapter.

The Par Monad

This section will focus on the parallel programming package called monad-par. The

functions in that library revolve around the Par monad and the use of IVars for

communication results. As you will see, computation can be modeled in two ways with

this package: as futures or as dataflow programs.

Futures

Let’s start with a simple task that aims to produce the factorization into primes of

several numbers. The algorithm for factorizing one number is simple. You try to divide

by increasing natural numbers. If at some point the division has zero remainder, that

number is a prime factor. Thus, the original number can be divided by that prime factor,

271



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.