14th Chapter Parallel Function Program
This chapter describes
Simplifying parallelization with non-volatile data (parallelization)
Processing Task Parallel Libraries (Task Parallel Library)
Declaratively express parallelism in LINQ (parallelism)
Implementing the overloaded (overloaded) operator
In favor of functional programming arguments, we have seen many. One reason is that the degree of parallelism is now becoming more and more important. Writing can adapt to a large number of core code, compared with the typical command-style method, with a much easier function.
Two concepts from the functional world are essential, parallel computing is declarative programming style, and the use of immutable data structures is closely related. When using immutable data, the code becomes more declarative because the code is more concerned with the expected results than copying and altering the details of the data. Both concepts are important to achieve parallelization in different ways.
With declarative styles, most code can easily parallelize collections, because declarative styles do not describe how the code works, so that, without much effort, you can replace the serial in parallel. Immutable data structures and function without side effects are important because the code has no side effects, and we can easily determine which code does not depend on each other. By doing this, you can run code snippets in parallel using task-based parallelism. Both C # and F # can use mutable data types, and in the tenth chapter we learn how to hide mutable states and make the whole program functional. In some cases, for example, if an array is handled in some way, this hidden command-isolated code can also be easily parallelized.
It can be found that there are many things worth studying. We start with a brief demonstration of all these techniques and explain the use of each one. After that, look at two more complex sample applications, demonstrating the use of parallel functional programming for large-scale applications. We cannot accommodate two complete examples of code in a chapter, and in the book we omit some of the less significant details, and we will pay particular attention to the areas of architecture, directly related to parallelism. From the book's website you can get the complete source code, which complements the missing part.
14th Chapter Parallel Function Program