OpenACC for Programmers by Sunita Chandrasekaran

OpenACC for Programmers by Sunita Chandrasekaran

Author:Sunita Chandrasekaran
Language: eng
Format: epub
Publisher: Pearson Education
Published: 2018-04-15T04:00:00+00:00


8.1 Programming Models

This section offers a short description of each of the most relevant programming models. For this purpose, the models are also distinguished with respect to their implementation strategy (language features, directives, language extensions, or C++ abstraction), and their supported parallelization models (thread parallelism, task parallelism, and data parallelism).

In thread parallelism models, parallelism is introduced via concurrent execution of streams, which can coordinate via data exchange or explicit synchronization. Thread parallelism models are the most flexible way of expressing parallelism and can be used to implement both data parallelism and task parallelism execution schemes. However, these models are also the most cumbersome to use when you are implementing math or science algorithms.

Task parallelism–based systems are also flexible. They handle both functional and data parallelism. Furthermore, they can naturally expose parallelism in situations with complex data and synchronization dependencies.

Data parallelism is the most constrained model but is simpler to use than thread parallelism, and generally it has less runtime overhead than task parallelism–based systems. Data parallelism models describe work mainly via an index space, which can be iterated over in parallel. This does not necessarily mean that the iteration scheme is directly associated with a corresponding data structure. The data could be calculated during the execution of the program based on the iteration index.

Some programming models provide capabilities from all three areas. For example, OpenMP allows for thread parallelism and data parallelism as well as task parallelism.

As noted, all types of programming models can be implemented through various means.

Language features are the capabilities within the language itself that allow expressions of parallelism. Examples of those are the DO CONCURRENT concept in Fortran 2008, std::thread in C++11, and for_each in C++17. The advantage of using programming models that are implemented as language features is that they are part of the official programming language standard. Usually this means that they work well together with all other capabilities of a language. Additionally, they don’t require any other third-party tools in addition to the compiler itself. However, native parallelism in language standards is usually many years behind programming models implemented through other means with respect to its scope.

OpenACC is one example of the directive-based approach. Directives have the benefit that they can be ignored if the code is compiled in an environment that does not require the parallelism, or where no compiler exists that understands the directives. Furthermore, it is usually possible to incrementally introduce directives into an application. In addition to OpenACC, the most widely used directive-based programming model is OpenMP.

Language extensions add capabilities to an existing programming language that are not part of the language standard. These require specialized compilers, which often are provided only by a single party. Examples are CUDA, OpenCL, and C++ AMP. Applications written in those models cannot be compiled by standard compilers, something that can lead to a vendor lock-in. Often these models have restrictions with respect to which language features can be utilized within parallel regions of the code.

The last set of programming models is implemented through C++ abstractions.



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.