An automatic parallelization tool is a computer program aiding in automatic parallelization of existing sequential (single-threaded) code into parallel (multithreaded or vectorized) code. It aims to facilitate re-use of already written software with the performance benefits of parallelization, reducing the amount of software rewriting needed, and saving the need to rewrite all of it. In the past, parallel hardware was only implemented in high-end machines or by means of distributed computing, but with the advent of graphics processing units (GPUs) and multi-core central processing units (CPUs) in consumer devices it has become widespread in low-end computers also. Hence, it has become desirable to automate the process of converting older, single-threaded applications to exploit parallel hardware. Further, automatic parallelization tools can enable a focus on writing applications in a single-threaded manner while still benefiting from parallelization. Some caveats in the conversion include handling issues such as synchronization and deadlock avoidance, which do not arise in single-threaded computing.
Need for automatic parallelization Past methods provided solutions for languages like Fortran and C; however, these were not enough. These methods dealt with parallelizing sections for specific systems, such as loops or given sections of code. Identifying opportunities for parallelizing is a critical step while generating multithreaded application. This need to parallelize applications is partly addressed by tools that analyze code to exploit parallelism. These tools use methods for either compile time or run time. These methods are built-in in some parallelizing compilers but a user needs to identify parallelize code and mark the code with special language constructs. The compiler identifies these language constructs and analyzes the marked code for parallelizing. Some tools parallelize only special forms of code, such as loops. Hence, a fully automatic tool for converting sequential code to parallel code is needed.
General procedure of parallelization 1. The process starts with identifying code sections that have parallelism possibilities. Often this task is difficult since the programmer working to parallelize the code did not originally write the code under consideration, or is new to the application domain. Thus, though this first stage in the parallelizing process seems easy, at first it may not be so. 2. The next stage is to shortlist code sections out of the identified ones that can truly be parallelized. This stage is again most important and difficult since it involves much analysis, generally for codes in C and C++ where pointers are involved and difficult to analyze. Many special methods such as pointer alias analysis and function side effect analysis are needed to conclude whether a section of code is dependent on any other code. The more dependencies exist in the identified code sections, the more the possibilities of parallelizing decrease. 3. Sometimes the dependencies are removed by changing the code and this is the next stage in parallelizing. Code is transformed such that the function, and hence output, is unchanged, but the dependency, if any, on other code section(s) or other instruction(s) is removed. 4. The last stage in parallelizing is generating the parallel code. This code is always functionally similar to the original sequential code, but has added constructs or code sections which, when executed, create multiple threads or processes.
Automatic parallelization method See also main article automatic parallelization.
Scan This is the first stage where the scanner reads the input source files to identify all static and external uses. Each line in the file is checked against predefined patterns to segregate into tokens. These tokens will be stored in a file which is used later by the grammar engine. The grammar engine will check patterns of tokens that match with predefined rules to identify variables, loops, control statements, functions, etc., in the code.
Analyze The analyzer is used to identify sections of code that can be executed concurrently. The analyzer uses the static data information provided by the scanner-parser. The analyzer will first find out all the functions that are independent of each other and mark them as individual tasks. Then an analyzer finds which tasks are having dependencies.
Schedule The scheduler lists all the tasks and their dependencies on each other as to execution and start times. The scheduler produces an optimal schedule as to the number of processors to use or the total time of execution for the application.
Code generation The scheduler generates a list of all the tasks and the details of the cores on which they will execute along with the time for which they will execute. The code Generator will insert special constructs in the code that will be read during execution by the scheduler. These constructs will instruct the scheduler on which core a given task will execute along with the start and end times.
Parallelization tools There are many automatic parallelizing tools for Fortran, C, C++, and several other languages.
YUCCA YUCCA is a sequential-to-parallel automatic code conversion tool developed by KPIT Technologies Ltd., Pune. It takes input as C source code which may have multiple source and header files. It gives output as transformed multi-threaded parallel code using POSIX Threads (pthreads) functions and OpenMP constructs. The YUCCA tool does task- and loop-level parallelizing.
Par4All Par4All is an automatic parallelizing and optimizing compiler (workbench) for C and Fortran sequential programs. This source-to-source compiler adapts existing applications to various hardware targets such as multicore systems, high performance computers and GPUs. It creates a new source code and thus allows the original source code of the application to remain unchanged.
… excerpt ends here. Continue reading the full article.