1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 \chapter{Parallel Architectures and Iterative Applications}
10 %\lettrine[lines=2]{A}{u}
12 \section{Introduction}
14 Traditionally, most of the software applications are structured as sequential programs according to the Von Neumann report in 1993 \cite{ref50}. The structure of the program code is understandable by the human brain as a series of instructions that executed one after the other. From many years until a short time,
15 with each new generation of microprocessors the users of the sequential applications have believed that these applications run faster over them.
16 Nowadays, this idea is no longer valid because the recent release of the microprocessors have many computing units embedded in one chip and these programs are only run over one computing unit sequentially.
17 Consequently, traditional applications have not improved their performance a lot over the new architectures, whereas the new applications run faster over them in a parallel. The parallel application is executed over all available computing units at the same time to improve its performance. Furthermore, the concurrency revolution has been referred to the drastically improvement in the performance of new applications side by side to new parallel architectures \cite{ref51}. Therefore, parallel applications and parallel architectures are closely tied together. It is hard to think about any of parallel applications without thinking of the parallel hardware executed them.
18 For example, the energy consumption of a parallel system mainly depends on both of the parallel application and the parallel architecture executes this application. Indeed, an energy consumption model or any measurement system depends on many specifications, some of them are concerning parallel hardware features such as the frequency of the processor, the power consumption of the processor and the communication model. The others are concerning the parallel application such as the computation and communication times of the application.
20 In this work, the iterative parallel applications are interested and running them over different parallel architectures to optimize their energy consumptions is the main goal.
21 As a result, this chapter is aimed to give a brief overview of parallel hardware architectures, parallel iterative applications and an energy model from the other authors used to measure the energy consumption of these applications.
22 The reminder of this chapter is organized as follows: section \ref{ch1:2} is devoted
23 to describe types of parallelism and types of parallel platforms. It also gives some information about parallel programming models. Section \ref{ch1:3} explains both of a synchronous and asynchronous parallel iterative methods and comparing them. Section \ref{ch1:4}, presents a well accepted energy model from the state of the art that can be used to measure the energy consumption of parallel iterative applications when changing the frequency of the processor. Finally, section \ref{ch1:5} summaries this chapter.
26 \section{Parallel Computing Architectures}
28 The process of the simultaneous execution of calculations is called the parallel computing.
29 Its main principle refer to the ability of dividing the large problem into smaller sub-problems that can be solved at the same time \cite{ref2}.
30 Mainly, solving sub-problems of the main problem in a parallel computing are carried out on multiple parallel processors.
31 Indeed, the parallel processors architecture is a computer system composed of many processing elements connected via network model in addition to software tools required to make the processing units work together \cite{ref1}.
32 Consequently, the parallel computing architecture consist of a software and hardware resources.
33 Hardware resources are processing units and the memory model in addition to the network system connecting them. Software resources include the specific operating system, the programming language and the compiler, or the runtime libraries. Furthermore, the parallel computing can have different levels of parallelism that can be performed in a software or a hardware level. There are five types of parallelism as follows:
36 \item \textbf{Bit-level parallelism (BLP)}: The appearance of the very-large-scale integration (VLSI) in 1970s has been considered the first step towards the parallel computing. It is used to increase the number of bits in the word size being processed by a processor as in the figure~\ref{fig:ch1:1}. For many successive years, the number of bits have increased starting from 4 bit microprocessors reaching until 64 bit microprocessors. For example, the recent x86-64 architecture becomes the most familiar architecture nowadays. Therefore, the biggest word size gives more parallelism level and thus less instructions to be executed by a processor at the same time.
40 \includegraphics[scale=1]{fig/ch1/bits-para.pdf}
41 \caption{Bit-level parallelism }
45 \item \textbf{Data-level parallelism (DLP)}: Data parallelism is a process of distributing the data vector between different parallel processors and each one performs same operations on its data sub-vector. Therefore, many arithmetic operations can be performed on the same data vector in a simultaneous manner. This type of parallelism can be used in many programs, especially from the area of scientific computing. Usually, data-parallel operations are only provided for arrays operations, for example see figure \ref{fig:ch1:2}. As an example about the applications use this type of parallelism are vectors multiplication, image and signal processing.
49 \includegraphics[scale=1]{fig/ch1/data-para.pdf}
50 \caption{Data-level parallelism }
54 \item \textbf{Instruction-level parallelism (ILP)}: Generally, the sequential program composed of many instructions. These instructions can be executed in a parallel at the same time, if each of them is independent from the others. In particular, the parallelism can be achieved in the instruction level by using pipeline. It means all the independent instructions of the program are overlapped the execution of each others. For example, if we have two instructions $I_1$ and $I_2$, they are independent if there is no control and data dependency between them.
55 In pipeline stages, the execution of each instruction is divided into multiple steps that can be overlapped with the steps of other instructions by the pipeline hardware unit.
56 Figure~\ref{fig:ch1:3} demonstrates four instructions each one has four steps denoted as fetch, decode, execute and write, which are implemented in hardware units by pipeline.
60 \includegraphics[scale=1]{fig/ch1/pipelines.pdf}
61 \caption{Instruction-level parallelism by pipelines}
67 \item \textbf{Thread-level parallelism (TLP)}: It is also known as a task-level parallelism.
68 According to the Moore’s law \cite{ref9}, the processor can have number of transistors by a double
69 each two years to increase the frequency of the processor and thus its performance. Besides, cache and main memories sizes are must increased together to satisfy this increased.
70 But, this leads to some limits come from two main reasons, the first one is when the cache size is drastically increased leading to a larger access time. The second is related to the big increase in the number of the transistors per CPU that can be increased significantly the heat dissipation. As a result, programmers subdivided their programs into multiple tasks which can be executed in parallel over distributed processors or shared multi-cores processors to improve the performance of the program, see figure~\ref{fig:ch1:4}. Each processor can has a multiple or an individual thread dedicated for each task. A thread can be defined as a part of the parallel program which shares processor resources with other threads.
74 \includegraphics[scale=1]{fig/ch1/thread-para.pdf}
75 \caption{Thread-level parallelism}
79 Therefore, we can consider the execution time of a sequential program composed of $N$ tasks as sum of the execution times of all tasks as follows:
83 Sequential~execution~time = \sum_{i=1}^{N} T_i
86 Whereas, if tasks are executed synchronously over multiple processing units in a parallel, the execution time of the program is the execution time of the task that has maximum execution time (the slowest task) as follows:
90 Parallel~execution~time = \max_{i=1,\dots,N} T_i
93 \item \textbf{Loop-level parallelism (LLP)}:
94 The numerical algorithms and many other algorithms are executed iteratively the same program portion, computation, using different forms of the loop statements allowed in the programming languages. At each iteration, the program need to scan a large data structure such as an array structure to make the arithmetic calculations. Inside the loop structure there are many instructions, which are independent or dependent. In a sequential loop execution the $i$ iteration must be executed after the completion of
96 Whereas, if each iteration is independent from the others, then all the iterations are distributed over many processors to be executed in a parallel,
97 for example see figure\ref{fig:ch1:5}. In the parallel programming languages this type of a loop is called $parallel~loop$.
101 \includegraphics[scale=0.8]{fig/ch1/loop-para.pdf}
102 \caption{Loop-level parallelism}
106 The execution time of the parallel loop portion can be computed as
107 the execution time of a sequential loop portion has $N_{iter}$ iterations divided by the number of the processing units $N_{processors}$ as follows:
111 Parallel~loop~time = \frac{Sequential~loop~time}{N_{processors}}
112 =\frac{\sum_{i=1}^{N_{iter}} Time~of~iter_i}
116 For more detail about the levels of parallelism see \cite{ref3,ref4,ref6,ref7}.
119 \subsection{Types of Parallel platforms}
121 The main goal behind using a parallel computers is to solve bigger problem faster.
122 A collection of processing elements composing them must to work together to perform the final solution of the main problem. However, many different architectures have been proposed
123 and classified according to the parallelism in the instruction and data
124 streams. In 1966, Michel Flynn has been proposed a simple model of categorizing all computers that still useful until know \cite{ref10}. His taxonomy considered the data and the operations performed on these data to produce four types of computer systems as follows:
128 \item \textbf{Single instruction, single data (SISD) stream}: A single processor executes a single instruction stream executing one data stream stored in an individual memory model, see figure \ref{fig:ch1:6}. As an example of this type is the conventional sequential computer system according to the Von Neumann model, it is also called the Uniprocessors.
131 \includegraphics[scale=1]{fig/ch1/sisd.pdf}
132 \caption{SISD machine architecture}
136 \item \textbf{Single instruction, multiple data (SIMD) stream}: All the processors execute the same instructions on different data.
137 Each processor stores the data in its local memory, the processor communicates with each others typically via a simple communication model, see figure \ref{fig:ch1:7}. Many scientific and engineering
138 applications are suitable to this type of parallel scheme.
139 Vector and array processors are well know examples of this type.
140 As an example about the applications executed over this architecture are graphics processing, video compression and medical image analysis applications.
144 \includegraphics[scale=1]{fig/ch1/simd.pdf}
145 \caption{SIMD machine architecture}
149 \item \textbf{Multiple instruction, single data (MISD) stream}: Many operations from multiple processing elements are executed over the same data stream. Each processing element has its local memory to store the private program instructions applied to unique global memory data stream as in figure \ref{fig:ch1:8}. While the MISD machine is not commonly used, there are some interesting uses such as the systolic arrays and dataflow machines.
153 \includegraphics[scale=1]{fig/ch1/misd.pdf}
154 \caption{MISD machine architecture}
159 \item \textbf{Multiple instruction, Multiple data (MIMD) stream}: There are multiple processing elements each of which has a separate instructions and local data memories.
160 At any time, different processing elements may be executing different instructions on different data fragment, see figure \ref{fig:ch1:9}. There are two types of MIMD machines: the share memory and the massage passing MIMD machines.
161 In the share memory architectures, a processors are communicated via a share memory model, while in the message passing architecture each processor has its own local memory and all processors communicate via a communication network model. The multi-core processors, local
162 clusters and grid systems are an examples for MIMD machine.
163 Many applications have been conducted over this architecture
164 such as computer-aided design, computer-aided manufacturing, simulation, modeling, iterative applications and so on.
168 \includegraphics[scale=1]{fig/ch1/mimd.pdf}
169 \caption{MIMD machine architecture}
173 For more details about this architectural taxonomy see \cite{ref11,ref5,ref13,ref14}.
175 The work of this thesis is dedicated to MIMD machines architecture. Therefore, we discuss in
176 this chapter some of the commonly used parallel architectures that belong to MIMD machines.
177 As explained before, MIMD architectures can be classified into two types, the shared memory and the distributed message passing ones. Furthermore, these classifications are based on
178 how MIMD processors access the memory model. The shared MIMD machines communication topology can be bus-based, extended or hierarchical type. Whereas, the distributed memory MIMD machines may have hypercube or mesh inter connected networks. In the following are some well known MIMD parallel computing platforms:
181 \item \textbf{Multi-core processors}:
182 The multi-core processor is a single chip component with two or more processing units.
183 These processing units are called cores, which connected with each other via main memory model as in the figure \ref{fig:ch1:10}. Each individual core has its cache memory to store its data and execute different data or instructions stream in parallel. Moreover, each core can have one or more threads to execute a specific programming task as shown in the thread-level parallelism. Historically, the multi-cores of the CPU began as two-core processors, with increase in the number of cores approximately by double with each semiconductor process generation \cite{ref12}. The very quick improvements in the performance and thus the increase in the number of cores is devoted in the graphical processing unit (GPU). A current exemplar of GPU is the NVIDIA GeForce TITAN Z with 5700 cores in year of 2015 \cite{ref17}. While the general-purpose microprocessors (CPU) has less number of the cores, for example the TILE-MX processor from Tilera has 100 cores in the same year \cite{ref16}.
184 For more details about the multi-core processors see \cite{ref15}.
188 \includegraphics[scale=1]{fig/ch1/multicores.pdf}
189 \caption{Multi-core processor architecture}
194 \item \textbf{Local Cluster}:
195 is generally collection of independent computers that are connected
196 to each other via standard network switches and cables, which is a high speed
197 local area networks (LAN) with low latency and big bandwidth. Moreover, each node is distributed from each other and it communicates with other nodes using distributed massage passing model. All the nodes in the cluster must be controlled by one node called the master node, which is a specific node uses to handle the scheduling and management of the other nodes as shown in the figure \ref{fig:ch1:11}. Usually, the hardware specifications of all nodes are homogeneous in term of the computing power and memory and thus it is called tightly-coupled fashion. Also, each computing node in the cluster has the same copy of the operating system. See \cite{ref18, ref19} for more information about the cluster and its applications.
201 \includegraphics[scale=1]{fig/ch1/cluster.pdf}
202 \caption{Local cluster architecture}
207 \item \textbf{Grid (Distributed clusters)}:
208 Grid is a collection of local computing clusters from different sites connected via wide area network (WAN), which can be appeared virtually to the benefit users as a complete computing system \cite{ref20}.
209 In particular, different local clusters composing the grid are geographically faraway from each others. Usually, each local cluster composed from homogeneous nodes, which are different from the nodes of the others cluster located in different sites. These nodes can be different in the hardware and software specifications such as the computing power, memory size, operating system, local network latency and bandwidth. Figure \ref{fig:ch1:12} presents an example of the grid composed of three heterogeneous local clusters located in different sites which are connected throw a wide area network. Furthermore, the grid can be referred to an infrastructure applies the integration and the collaboration by using collection of different computers, networks, databases servers and scientific devices belong to many companies and universities. Therefore, wide heterogeneous computing resources are allowed to many users simultaneously. While the only bottleneck of the grid is the high latency communications between the nodes from different sites. The grid is also called the loosely-coupled fashion platform. However, the fault tolerance is required to guarantee the process of sending and receiving the messages between the computing nodes and thus keeps all the messages from the lost.
213 \includegraphics[scale=0.85]{fig/ch1/grid.pdf}
214 \caption{Grid architecture}
221 \includegraphics[scale=1]{fig/ch1/grid5000.pdf}
222 \caption{Grid5000's sites distribution in France and Luxembourg}
228 Grid'5000 \cite{ref21} can be considered as a good example for this distributed platform.
229 It is a large-scale testbed that consists of ten sites distributed
230 all over metropolitan France and Luxembourg. These sites are: Grenoble, Lille, Luxembourg, Lyon, Nancy, Reims, Rennes , Sophia, Toulouse, Bordeaux. Figure \ref{fig:ch1:13} shows the geographical distribution of grid'5000 sites over France and Luxembourg. All the sites are connected together via a special long distance network called RENATER, which is the French
231 National Telecommunication Network for Technology. Each site in the grid is
232 composed of a few heterogeneous computing clusters and each cluster contains
233 many homogeneous nodes. In total, Grid'5000 has about one thousand heterogeneous nodes and eight thousand cores. In each site, the clusters and their nodes
234 are connected via high speed local area networks. Two types of local networks
235 are used, Ethernet or Infiniband networks, which have different characteristics
236 in terms of bandwidth and latency.
237 Grid'5000 is dedicated as a test-bed for grid computing and thus users can book the required nodes from different sites. It allows the user to deploy his configured image of the operating system over the reserved nodes. Therefore, many software tools are available to the user to control and manage the reservation and deployment processes from his local machine. For example, OAR \cite{ref22} is a batch scheduler used to manage the heterogeneous resources of the grid'5000.
240 \subsection{Parallel programming Models}
242 There are many parallel programming languages and libraries have been developed
243 to explore the computing power of the parallel architectures. In this section,
244 the parallel programming languages are divided into two main types,
245 which is the shared and the distributed programming models. Moreover, each type is divided into two subcategories according to its support level for the number of computing units composing the parallel platform.
246 Figure \ref{fig:ch1:14} presents this classification hierarchy of the parallel programming
247 models. It is also showed three parallel languages examples for each subcategory.
252 \includegraphics[scale=0.75]{fig/ch1/classification.pdf}
253 \caption{The classification of the parallel Programming Models}
258 Many programming interfaces and libraries have been developed to compile and run the
259 parallel applications over the parallel architectures. In the following are
260 some examples for each type of the parallel programming models:
263 \item \textbf{Local cluster programming models}
265 \item \textbf{MPI} \cite{ref23} is the Message Passing Interface and it considers a
267 dedicated for message passing in distributed memory environment.
268 The first version of MPI designated by a group of researchers in
269 1991. It is a library, not a language and its subroutines
270 can be called from many programming languages such as C, Fortran and
271 Java. The programmes that users write in these languages are
272 compiled with ordinary compilers and linked with the MPI library.
273 Its library functions are not only for peer to peer operations throw
274 send and receive messages, but it allowed many others collective
275 operations such as gathering and reduction operations. MPI user feel
276 free form the network topology, synchronization and communication
277 functionality between group of processes. Furthermore, it has an
278 asynchronous point to point operations, which make the computations
279 to overlap with communications. While MPI is not devoted to a grid,
280 \textbf{MPICH} is one of the most
281 popular implementations of MPI dedicated for grid computing. It uses
282 as an extended version for MPI, which implements a fault tolerance
283 \cite{ref52}. In this work, both of MPI and MPICH programming libraries
284 have used for programming our algorithms and applications which called
285 inside both of Fortran and C programming languages.
287 \item \textbf{PVM} \cite{ref25} is for Parallel Virtual Machine, which is a collection
288 of software tools and libraries to allow users working over a
289 heterogeneous set of machines to operate as a single high performance
290 parallel platform. It is dedicated for a group of machine that are
291 distributed and heterogeneous in the operating system environments.
292 The PVM system is elementarily for parallel programming to be used with
293 C, C++, and Fortran languages.
294 It is considered more robust in fault tolerance than MPI, easier to
295 add or delete the crashed nodes in the host pool
296 \cite{ref26}. While MPI has more communication messages support and asynchronous
297 operations which are not allowed in PVM.
300 \item \textbf{BLACS} \cite{ref27} is for Basic Linear Algebra Communication Subprograms.
301 It has a collection of libraries that used to built a linear algebra messages
302 communication model which is applied effectively over distributed memory architectures.
303 The primary goal of using BLACS is mapping a liner set or processors or any distributed
304 machines into two dimensional array or grid, which offers an easy tool for building a
305 linear algebra applications.
309 \item \textbf{Grid programming models}
311 \item \textbf{Gridsolve} \cite{ref28} is the first middleware for a grid and the
312 high performance computing that offers a good tool to solve a complex
313 scientific applications using distinct distributed machines. It applies the
314 fault tolerance and load balancing features to ensure the reliability of the
315 applications when running over a geographically distributed resources.
316 It works with different programming languages such as C,C++, Java and Fortran.
318 \item \textbf{GLOBAS} \cite{ref29,ref30} is the most widely standardization tool kit
319 for a grid computing. It permits the users to share their computing resources securely.
320 While the GLOBAS toolkit is allowed to work with a grid, it offers a fault
321 detection mechanism to ensure the delivery of the messages.
322 The first version of Globus toolkit appeared
323 in 1998 and now the sixth version is available \cite{ref31}.
326 \item \textbf{Legion} \cite{ref32,ref33} is an object-based and meta-systems software project
327 at the University of Virginia on November 1997.
328 It implements many features such as security, portability and fault tolerance.
329 Moreover, it is created to support a wide degree of parallelism throw an easy
330 programming tools to built the parallel applications.
335 \item \textbf{Multi-core CPU programming models}
337 \item \textbf{OpenMP} \cite{ref34} is a parallel programming tool for shared memory
338 architectures. The main goal of using this programming model is to provide
339 a standard and portable API (application programming interface) for writing
340 shared memory parallel programs. It can be used with programming languages such
341 as C, C++ and Fortran to support different types of shared memory platforms
342 such as multi-core processors.
343 OpenMP uses multi-threading, which is a method of parallel programming
344 that uses a master thread to control set of slave threads. Each
345 thread can be executed in a parallel by allocating it to a processor.
346 Moreover, OpenMP can be used with MPI to support hybrid platforms that have
347 shared and distributed memory models at the same time.
349 \item \textbf{Cilk} \cite{ref13,ref35} is a linguistic and runtime technology for algorithmic
350 multi-threaded programming originally developed at MIT.
351 It allows the programmer to focus on building the program in a structured way
352 to discover the inherent parallelism. Many specifications are used in Cilk
353 such as the load balancing, synchronization and communication protocols.
359 \item \textbf{TBB} \cite{ref36} is for Threading Building Blocks, is a software library used with
360 C++ programming language for multi-core parallel programming developed by Intel.
361 It woks on the principle of dividing the computations into many tasks that can be
362 executed in a parallel.
363 It also has a management library to schedule the parallel task execution.
364 The difference between OpenMP and TBB, is the latter uses a task-based scheduling
365 mechanism. Furthermore, TBB is more popular with C++ programming language than
366 others languages. It is designed to work with any compiler environments, and thus
367 it is easily ported to a new platform. Hence, TBB has been ported to
368 different types of operating systems and processors. While, it has limited
369 support to vector processing architecture and then it is connected with OpenMP
370 and Cilk to support this platform.
375 \item \textbf{GPU programming models}
377 \item \textbf{CUDA} \cite{ref37} Modern graphical processing units (GPUs) have increased its chip-level
378 parallelism. Current NVIDIA GPUs are many-cores processor having thousands
379 of core. According to this massively cores parallelism, the NVIDIA in 2007 developed
380 a parallel programming language called CUDA , which is for Compute Unified Device
381 Architecture. A CUDA program has two parts, the first one is called a host which is a
382 set of threads that executed sequentially over the CPU. The second part is called the
383 kernels, which are a set of threads that can be executed in a parallel over the GPUs.
385 \item \textbf{OpenCL}\cite{ref38} is for Open Computing Language. It is a parallel
386 programming language dedicated for heterogeneous platform composed
387 of CPUs and GPUs. The first release initially developed by Apple
388 in 2008. Functions executed on an OpenCL device is called kernel,
389 which can be portably executes on any computing hardware such as CPU or GPU cores.
390 This parallel programming language supports the homogeneous shared memory
391 platforms and the multi-core processors by using one core for control
392 and the others for computing.
394 \item \textbf{HLSL} \cite{ref39} is for High Level Shading Language, is the shader
395 programming language for Direct3D, which is a part of
396 Microsoft’s DirectX API. It supports the shader design with
397 C language syntax, types, expressions, statements, and functions and it
398 provides a graphical pipeline parallelism.
399 The last version of HLSL is version 5.0 for DirectX 11, which adds a new
400 general-purpose GPU functions like CUDA. Recently, the new OpenCL
401 version starts to replace CUDA as a multi-platform GPU language.
408 \section{Iterative Methods}
410 Numerical methods are a scientific computations for solving linear and non-linear problems.
411 Almost of the numerical problems can be represented by mathematical equation form with relations between its components. For example, solving linear equations which is well known in the scientific area is generally expressed in the following form:
418 Where $A$ is a two dimensional matrix of size $N \times N$, $x$ is the unknown vector,
419 and $b$ is a vector of constant, each of size $N$. There are two types of solution methods for solving this linear system.
420 The first method is called \textbf{Direct methods}, which is a finite number of steps depending on the
421 size of the linear system to give the exact solution. If the problem size is very big this methods are expensive or their
422 solutions are impossible in some cases. The second type is called \textbf{Iterative methods}, which is computed
423 many times the same block of the operations starting from the initial vector until reaching to the acceptable
424 approximation of the exact solution. However, the iterative methods are faster than direct methods and can be
425 applied in parallel. Moreover, iterative methods can be used to solve both of the linear and non-linear equations.
426 In our work, we are interested in parallelizing the iterative methods because they are more popular and effective than direct ones.
428 The sequential iterative algorithm is typically organized as a series of steps essentially of the form:
432 X^{(k+1)} \longleftarrow F(X^k)
435 Where $F$ is one or set of operations applied to the data vector $X^k$ to produce the new data vector $X^{(k+1)}$. This operation $F$ is applied sequentially many times until convergence condition is satisfy as in the algorithm \ref{sia}.
439 \begin{algorithm}[h!]
440 \begin{algorithmic}[1]
442 \State Initialize the vector $X^0$ randomly
443 \For {$k:=1$ to \textit{convergence}}
445 \State $X^{(k+1)} = F(X^k)$
448 \caption{The iterative sequential algorithm}
453 The sequential iterative algorithm at each iteration computes the value of the relative error, which is called the residual that denoted as $R$. This error value is the maximum difference between the data components of the vectors of the last two successive iterations as follows:
457 R = \max_{i=1, \dots, N} \abs{X_i^{(k+1)} - X_i^k}
459 Where $N$ is the size of the vector $X$. Then, the iterative sequential algorithm stops its iterations if the maximum error between the last two successive solutions vectors, as in \ref{eq:res}, is less than or equal to the some threshold value. Otherwise, it replaces the new vector $X^{(k+1)}$ with the old vector $X^k$ and computes the new iteration.
461 \subsection{Synchronous Parallel Iterative method}
463 The sequential iterative algorithm \ref{sia}, can be parallelized by executing it on many computing units. To solve this algorithm on $M$ computing units, first the elements of the problem vector $X$ must be subdivided into $M$ sub-vectors, $X^k=(X_1^k,\dots,X_M^k)$.
464 Each sub-vector can be solved independently on one computing unit as follows:
468 X_i^{k+1}= F_i(X_1^k,\dots,X_M^k) \hspace{1cm} where \hspace{0.2cm} i=1,\dots, M
471 Where $X_i^k$ is the sub-vector executed over the $i^{th}$ computing unit at the iteration $k$.
473 \begin{algorithm}[h!]
474 \begin{algorithmic}[1]
476 \State Initialize the sub-vectors $(X_1^0,\dots,X_M^0)$ randomly
477 \For {$k:=1$ step $1$ to \textit{convergence}}
478 \For {$i:=1$ to \textit{M}}
479 \State $X^{(k+1)} = F(X^k)$
485 \caption{The synchronous parallel iterative algorithm}
490 The algorithm \ref{spia}, represents the synchronous parallel iterative algorithm. Similarly to
491 the sequential iterative algorithm \ref{spia}, this algorithm stops its iterations when the convergence condition is satisfied and it computes the residual value $R$ as follows:
495 R = \max_{i=1, \dots, M} (\max_{j=1, \dots, m}\abs{X_{ij}^{(k+1)} - X_{ij}^k})
497 This algorithm need to satisfy some convergence condition which is called the global convergence condition. In order to detect the global convergence overall computing units, first we need to compute
498 at each iteration the local residual and store it in the local variable at the computing unit $i$. Then at the end of each iteration, all the local residuals from $M$ computing units must be reduced to one maximum value represented by the global residual, which represents the global maximum errors overall maximum local errors from $M$ computing units. Where $m$ is the size of the $i$ sub-vector.
499 For example, in MPI this operation is directly applied using a high level communication procedure called \textit{AllReduce}. The goal of this communication procedure is to apply the reduction operation on all local variables computed by the computing units.
504 \includegraphics[scale=0.75]{fig/ch1/sisc.pdf}
505 \caption{The SICS Model}
510 In synchronous iterative algorithm, computing processors needs to communicate with each others to
511 exchange data at each iteration. Algorithm \ref{spia} can be used synchronous iterations and synchronous communications and denoted as \textbf{SISC} model. At each iteration, the computing processor waits until
512 it has receive all the data computed at the previous iteration from the other processors to perform the next iteration. This type of communication model uses if there are a dependencies between the parallel tasks. Figure \ref{fig:ch1:15}, shows that using SICS model in a heterogeneous platform may results in a big periods of the idle times represented by the white dashed spaces between two successive iterations. Indeed, this happens when the fast computing processor waits for the slow ones to finish their iterations to be able to synchronously send its data to them. This operation wastes a big amount of the computing power of the faster processors and thus their energy consumptions. The increased in the level of the heterogeneity between the computing powers of the computing processors may increased propositionally these idle times.
513 Accordingly, this algorithm is effectively implemented over a local cluster where a high speed local network is used to reduce these idle times.
518 \includegraphics[scale=0.75]{fig/ch1/siac.pdf}
519 \caption{The SIAS Model}
523 Furthermore, the communications of the synchronous iterative algorithm can be implemented asynchronously. Therefore, this algorithm is called the synchronous iteration and asynchronous
524 communication algorithm and denoted as \textbf{SIAC} algorithm. The main principle of this algorithm is to use a synchronized iterations while exchanging the data between the computing units asynchronously.
525 Moreover, each computing unit not has to wait for its neighbours to receive the data messages
526 that its has sent, while it only waits for receiving the data from them. This can be implemented in SISC algorithm programmed in MPI by replacing the synchronous send of the messages by asynchronous ones and keeps
527 the synchronous receive of the data messages. The only advantage of this technique is to reduce the idle times between the iterations by making the communications to overlap partially
528 with computations, see figure \ref{fig:ch1:16}. The idle times are not totally eliminated because the
529 fast computing nodes still have to wait for slow ones to send their data messages.
530 Both of the SISC and SIAC algorithms are not tolerate to the loss of data messages. Consequently, if one node is crashed, all the other computing nodes are blocked together and all the system is crashed.
534 \subsection{Asynchronous Parallel Iterative method}
536 The asynchronous iterations mean that all processors perform their iterations without considering the works of the other processors. Each processor not has to wait for receiving
537 the data messages from the others processors and continue computing the next iteration depending on its own data received at a specific time. While all processors not have to wait
538 for data delivery from each other, there are not existence for the idle times at all between the iterations as in figure \ref{fig:ch1:17}. This figure indicates that the fast processors can perform more iterations than the others at the same time.
539 Hence, the asynchronous iterative algorithm uses asynchronous communications is called \textbf{AIAC} algorithm. Likewise the SISC algorithm, the AIAC algorithm subdivides the global Vectors $X$ into $M$ sub-vectors between the computing units. The main different between the two algorithm is that these $M$ sub-vectors are not updated at each iteration in the AIAC algorithm because both of the iterations and communications are asynchronous.
540 However, there are two mechanisms to update the data vectors in AIAC algorithm as follows:
542 \item The local vectors can be updated randomly on the order of $M$ computing units.
543 This leads to some of these local vectors to not update at a certain time.
544 \item According to the time period $t$, each computing unit checks if one of the its
545 dependencies components have been updated. If the computing node detects any update
546 case, it updates its own local vector data using the last received data messages.
547 Otherwise, it does nothing at the time $t$.
553 \includegraphics[scale=0.75]{fig/ch1/aiac.pdf}
554 \caption{The AIAC Model}
558 The global convergence of the parallel iterative method depend on the scientific application.
559 For more information about the convergence detection techniques of the asynchronous iterative methods,
560 we refer to \cite{ref40,ref41,ref42,ref43} for more details.
563 The implementation of the AIAC method is not easy, but it gives many advantages over the traditional synchronous iterative method:
566 \item It prevents the existence of the idle times because each processor not has to wait
567 for the others to receive the data messages. Then, there is no idle times between each two
568 successive iterations.
570 \item Less sensitive for the heterogeneous communications and nodes' computing powers. In
571 heterogeneous platform, the fast nodes not have to wait for the slow ones and so it
572 performs more iterations than them. While in the traditional synchronous iterative
573 methods, the fast computing nodes perform the same number of iterations as the slow ones
574 because they are blocked together.
576 \item The loss of the data messages is totally tolerant because each computing unit is not
577 blocked with the others. If the message is lost, the destination node not has to wait
578 for this data message and it uses the last received data to perform its iteration
581 \item In the distributed grid architecture, the local clusters from different sites are
582 connected via slow network with a high latency. On the other hand, the use of the AIAC model
583 reduces the delay of sending the data message over such slow network link and thus the performance
584 of the applications is improved.
588 In addition to the difficulty of applying the asynchronous iterative method, it has some
589 disadvantages as follows:
592 \item It is not compatible to all types of the iterative applications because some of these
593 applications need to receive the data messages from its neighbours at each iteration.
594 Therefore, they required a fix number of iterations to converge. Otherwise, the
595 application is perform infinity number of iterations and then all of the system
598 \item The application of an asynchronous iterative method requires more iterations compared
599 to the synchronous ones to converge when it is executed over the local cluster.
600 The increase in the number of the iterations may increases proportionally
601 the execution time of the application.
602 Especially, the local computing cluster uses a high speed network, then running the
603 synchronous version over such platform is quicker to converge.
605 \item While the process not receive the new data messages at each iteration, the mechanism of
606 synchronous iterative methods for detecting the global convergence cannot be used for
607 asynchronous ones. Therefore, in AIAC algorithm a process can performs many iterations
608 without receiving any data messages from its neighbours. The absence of receiving new
609 data messages makes the data component not vary at the computing units and thus it detect
610 a false local convergence. This mean that the local residual value is less than the
611 required threshold. This fake convergence is conflicted at the reception of the first data message
612 because the local subsystem will locally diverges after computing the next iteration.
613 Therefore, special mechanisms are required for detecting the global convergence of a parallel
614 iterative algorithm implemented according to the asynchronous iteration model.
619 Generally, the interested readers can find more details about both of synchronous and asynchronous
620 iterative methods in \cite{ref44,ref45}.
622 In our works, we are interested to implement both of a synchronous and asynchronous
623 iterative methods for solving different problems over local homogeneous cluster, local heterogeneous cluster and distributed grid. Accordingly, the process of optimizing their energy consumptions and performance is the main objective of this work as shown in the next chapters.
626 \section{The energy consumption model of the parallel applications }
629 Many researchers~\cite{ref46,ref47,ref48,ref49} divide the power consumed by a processor into
630 two power metrics: the static and the dynamic power. The first one is
631 consumed as long as the computing unit is on, the latter is only consumed during
632 computation times. The dynamic power $P_{dyn}$ is related to the switching
633 activity $\alpha$, load capacitance $C_L$, the supply voltage $V$ and
634 operational frequency $F$, as shown in EQ~(\ref{eq:pd}).
637 P_\textit{dyn} = \alpha \cdot C_L \cdot V^2 \cdot F
639 The static power $P_{static}$ captures the leakage power as follows:
642 P_\textit{static} = V \cdot N_{trans} \cdot K_{design} \cdot I_{leak}
644 Where V is the supply voltage, $N_{trans}$ is the number of transistors,
645 $K_{design}$ is a design dependent parameter and $I_{leak}$ is a
646 technology-dependent parameter.
649 The dynamic voltage and frequency scaling technique (\textbf{DVFS}) is a process that is allowed in modern processors to reduce the dynamic
650 power by scaling down the voltage and frequency. Its main objective is to
651 reduce the overall energy consumption of the CPU~\cite{ref77}. The operational frequency $F$
652 depends linearly on the supply voltage $V$ as follows:
658 Where $\beta$ is some of constant. This equation is used to study the change of the dynamic
659 voltage with respect to various frequency values in~\cite{ref47}. The reduction
660 process of the frequency can be expressed by the scaling factor $S$ which is the
661 ratio between the maximum and the new frequency as in EQ~(\ref{eq:s}).
664 S = \frac{F_\textit{max}}{F_\textit{new}}
666 The value of the scaling factor $S$ is greater than 1 when changing the
667 frequency of the CPU to any new frequency value~(\emph{P-state}) in the
668 governor. The CPU governor is an interface driver supplied by the operating
669 system's kernel to lower a core's frequency \cite{ref8}.
671 Depending on the equation \ref{eq:s}, the new frequency $F_{new}$ can be calculates as follows:
675 F_\textit{new}= S^{-1} \cdot F_\textit{max}
679 Replacing $V$ in \ref{eq:pd} as in \ref{eq:v} gives the following equation of the dynamic power consumption
680 as a function of the constant $\beta$ instead of $V$:
684 P_{dyn}= \alpha \cdot C_L \cdot (\beta \cdot F) ^2 \cdot F =\alpha \cdot C_L \cdot \beta^2 \cdot F^3
687 Replacing $F_{new}$ in \ref{eq:pd-beta} as in \ref{eq:fnew} gives the following equation for dynamic power consumption:
691 P_{dynNew} = \alpha \cdot C_L \cdot \beta^2 \cdot F_{new}^3 =
692 \alpha \cdot C_L \cdot \beta^2 \cdot F_{max}^3 \cdot S^{-3} =
693 \alpha \cdot C_L \cdot (\beta \cdot F_{max})^2 \cdot F_{max} \cdot S^{-3} \\
694 {} =\alpha \cdot C_L \cdot V^2 \cdot F_{max} \cdot S^{-3} = P_{dyn} \cdot S^{-3}
697 Where $P_{dynNew}$ and $P_{dyn}$ are the dynamic power consumed with the
698 new frequency and the maximum frequency respectively.
700 According to (\ref{eq:pdnew}) the dynamic power is reduced by a factor of
701 $S^{-3}$ when reducing the frequency of a processor by a factor of $S$.
702 The energy consumption is measured in Joule, and can be calculated by
703 multiplying the power consumption, measured in watts, by the execution time of the program as follows:
707 Energy = Power \cdot T
710 According to the equation \ref{eq:E}, the dynamic energy consumption of the program executed in the time $T$ over one processor is the dynamic power multiply by the execution time. Moreover, the frequency scaling factor $S$ increases the execution time of the processor linearly, then the new dynamic energy consumption can be computed as follows:
714 E_{dynNew} = P_{dyn} \cdot S^{-3} \cdot (T \cdot S)= S^{-2} \cdot P_{dyn} \cdot T
718 According to \cite{ref46,ref47}, the static power consumption $P_{static}$ is not changes when the frequency of the processors is scaled down. Therefore, the static energy consumption can be computed as follows:
721 E_{static} = S \cdot P_{static} \cdot T
725 Therefore, the energy consumption of the individual task running over one processor
726 is the sum of both static and dynamic energies that can be computed as follows:
729 E_{ind} = E_{dynNew} + E_{static} = S^{-2} \cdot P_{dyn} \cdot T + S \cdot P_{static} \cdot T
733 Depending on \ref{eq:Eind}, the total energy consumption of $N$ parallel task running on $N$ processors is the summation of the individual energies consumed by all processors. This model is developed and used by Rauber and Rünger~\cite{ref47}. They modeled
734 the total energy consumption for a parallel tasks running on a homogeneous platform by sorting the execution time of the all parallel tasks in a descending order, then their model can be written as a function of the scaling factor $S$, as in EQ~(\ref{eq:energy}).
738 E_\textit{~all~tasks} = P_\textit{dyn} \cdot S_1^{-2} \cdot
739 \left( T_1 + \sum_{i=2}^{N} \frac{T_i^3}{T_1^2} \right) +
740 P_\textit{static} \cdot T_1 \cdot S_1 \cdot N
744 Where $N$ is the number of parallel tasks, $T_i$ for $i=1,\dots,N$ are
745 the execution times of the sorted tasks. Therefore, $T1$ is
746 the time of the slowest task, and $S_1$ its scaling factor which should be the
747 highest because they are proportional to the time values $T_i$.
748 Finally, model \ref{eq:energy} can be used to measure the energy consumed by any parallel application such as the iterative parallel applications with respect to the new scaled frequency value.
750 There are two drawbacks of this energy model as follows:
752 \item The message passing iterative program consists of the communication and computation times.
753 This energy model is assumed that the dynamic power consumes during both these times.
754 While the processor during the communication times involved remain idle and only consumes the static
755 power, for more details see \cite{ref53}.
758 \item It is not well adapted to a heterogeneous architectures when there are different
759 types of the processors, which are consumed different dynamic and static powers. Then, this model is
760 not able to measured the energy consumption of all the parallel system because it depends on
761 one value for each of the static and dynamic powers.
764 Therefore, one of the more important goals of this work is to develop an energy models that
765 has be taken into consideration the communication times in addition to computation times to modelize and measure the energy consumptions of the parallel iterative methods. These models are dedicated to all parallel architectures such as the homogeneous and heterogeneous platforms, which may be local or distributed computing clusters.
769 In this chapter, three sections have been presented for describing the parallel hardware architectures, parallel iterative applications and the energy consumption model used to measure the energies of these applications.
770 In the first section, different types of parallelism levels that can be implemented in a software and hardware techniques have explained. Furthermore, the types of the parallel architectures are demonstrated and classified according to how their computing units are connected to a memory model.
771 Both of the shared and distributed platforms are demonstrated and depending on them the parallel programming models have categorized.
772 In the second section, the two types of parallel iterative methods are described as synchronous and asynchronous iterative methods. The synchronous iterative methods are well implemented over local homogeneous cluster with a high speed network link, while the asynchronous iterative methods are more conventional to implement over the distributed heterogeneous clusters.
773 Finally in the third section, an energy consumption model used for measuring the energy consumption of the parallel applications from the related literature has described. This model cannot be used for all types of parallel architectures. Indeed, it assumes measuring the dynamic power during both of the communication and computation times, while the processor involved remains idle during the communication times and only consumes the static power. Moreover, it is not well adapted to heterogeneous architectures when there are different types of the processors, which are consumed different dynamic and static powers at the same time.
775 However, in the next chapters of this thesis a new energy consumption models are developed, and how these
776 energy models are used for modeling and measuring the energy consumptions by parallel iterative methods running on both homogeneous and heterogeneous architectures. Furthermore, these energy models use in a methods for optimizing both of the energy consumption and the performance of the iterative message passing applications.