The goal of parallel programming
Parallel programming has three main goals:
- Performance.
- Productivity.
- Versatility.
performance
Most of the work in parallel programming is to improve performance, and CDR threaded code without performance considerations is obviously a much easier solution. Performance here includes scalability (for example, performance per CPU) and efficiency (for example, performance per watt).
Another reason for the popularity of parallel software is that Moore’s Law is no longer effective at improving single-threaded performance. This means we can no longer rely on hardware performance improvements to meet our expectations.
Note, however, that parallelization is just one of many optimizations, and concurrency is not without costs (context switches consume resources, and it is difficult to maintain concurrent programs). So we usually compare the best serial algorithms before we use a concurrent algorithm for a particular problem.
productivity
First let’s make sure this is not a technical issue. Why productivity is so important in this era. Think of the early days when a computer cost millions of dollars and the annual salary of an engineer was nothing in comparison. If a team of 10 engineers can optimize the speed of the machine by 10%, that’s still a good deal. In a world where hardware prices are low and efficient use of hardware is not as attractive (and still valuable) as it once was, efficient use of developers has become just as important. So we need to take into account the fact that concurrency itself reduces productivity.
generality
Making our programs as generic as possible spreads the cost of developing software. But the problem is that generality represents higher performance losses and lower productivity. (Developing a more general-purpose program usually takes several times longer than the dedicated program.)
For example, Java has inherent multithreading capabilities but is generally considered to be inferior to C/C++ performance (although Java is getting faster). SQL has excellent performance, but it is only used for database queries.
Currently, there is no program that has performance, productivity, and versatility, and we still need to balance that. The closer the system is to the formation, the greater the need for versatility and performance. Here is a simple hierarchy:
- The application
- The middleware
- System libraries
- Operating system kernel
- The firmware
- hardware
It is important to understand that parallel programming is not the goal. Performance, productivity, versatility are.
Alternatives to parallel programming
- Multiple serial instances.
- Build applications using existing parallel software.
- Logical optimization for serial applications.
This paper mainly analyzes the second point, using existing parallel software to build applications. Web server, relational database is the typical application of this aspect. For example, a common design is for parallel software to provide users (broadly speaking) with a single processing process that is then executed in parallel on parallel software (relational databases are such a design). The Application is only responsible for the user interface, while the relational database handles concurrency and persistence. This sacrifices a bit of performance, but can significantly reduce development difficulty.
This chapter focuses on the goals of concurrent programming, and then takes a closer look at parallel programming and its applications through some of the features of Concurrent programming in Java.
Welcome to:www.renrunyun.com