\documentclass[conference]{IEEEtran}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{algpseudocode}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{subfig}
\usepackage{amsmath}

\usepackage{url}
\DeclareUrlCommand\email{\urlstyle{same}}

\usepackage[autolanguage,np]{numprint}
\AtBeginDocument{%
  \renewcommand*\npunitcommand[1]{\text{#1}}
  \npthousandthpartsep{}}

\usepackage{xspace}
\usepackage[textsize=footnotesize]{todonotes}
\newcommand{\AG}[2][inline]{%
  \todo[color=green!50,#1]{\sffamily\textbf{AG:} #2}\xspace}
\newcommand{\JC}[2][inline]{%
  \todo[color=red!10,#1]{\sffamily\textbf{JC:} #2}\xspace}

\newcommand{\Xsub}[2]{\ensuremath{#1_\textit{#2}}}

\newcommand{\Dist}{\textit{Dist}}
\newcommand{\Eind}{\Xsub{E}{ind}}
\newcommand{\Enorm}{\Xsub{E}{Norm}}
\newcommand{\Eoriginal}{\Xsub{E}{Original}}
\newcommand{\Ereduced}{\Xsub{E}{Reduced}}
\newcommand{\Fdiff}{\Xsub{F}{diff}}
\newcommand{\Fmax}{\Xsub{F}{max}}
\newcommand{\Fnew}{\Xsub{F}{new}}
\newcommand{\Ileak}{\Xsub{I}{leak}}
\newcommand{\Kdesign}{\Xsub{K}{design}}
\newcommand{\MaxDist}{\textit{Max Dist}}
\newcommand{\Ntrans}{\Xsub{N}{trans}}
\newcommand{\Pdyn}{\Xsub{P}{dyn}}
\newcommand{\PnormInv}{\Xsub{P}{NormInv}}
\newcommand{\Pnorm}{\Xsub{P}{Norm}}
\newcommand{\Tnorm}{\Xsub{T}{Norm}}
\newcommand{\Pstates}{\Xsub{P}{states}}
\newcommand{\Pstatic}{\Xsub{P}{static}}
\newcommand{\Sopt}{\Xsub{S}{opt}}
\newcommand{\Tcomp}{\Xsub{T}{comp}}
\newcommand{\TmaxCommOld}{\Xsub{T}{Max Comm Old}}
\newcommand{\TmaxCompOld}{\Xsub{T}{Max Comp Old}}
\newcommand{\Tmax}{\Xsub{T}{max}}
\newcommand{\Tnew}{\Xsub{T}{New}}
\newcommand{\Told}{\Xsub{T}{Old}} 
\begin{document} 

\title{Energy Consumption Reduction in heterogeneous architecture using DVFS}

\author{%
  \IEEEauthorblockN{%
    Jean-Claude Charr,
    Raphaël Couturier,
    Ahmed Fanfakh and
    Arnaud Giersch
  }
  \IEEEauthorblockA{%
    FEMTO-ST Institute\\
    University of Franche-Comté\\
    IUT de Belfort-Montbéliard,
    19 avenue du Maréchal Juin, BP 527, 90016 Belfort cedex, France\\
    % Telephone: \mbox{+33 3 84 58 77 86}, % Raphaël
    % Fax: \mbox{+33 3 84 58 77 81}\\      % Dept Info
    Email: \email{{jean-claude.charr,raphael.couturier,ahmed.fanfakh_badri_muslim,arnaud.giersch}@univ-fcomte.fr}
   }
  }

\maketitle

\begin{abstract}
  
\end{abstract}

\section{Introduction}
\label{sec.intro}


\section{Related works}
\label{sec.relwork}




\section{The performance and energy consumption measurements on heterogeneous architecture}
\label{sec.exe}

% \JC{The whole subsection ``Parallel Tasks Execution on Homogeneous Platform'',
%   can be deleted if we need space, we can just say we are interested in this
%   paper in homogeneous clusters}

\subsection{The execution time of message passing distributed iterative applications on a heterogeneous platform}

In this paper, we are interested in reducing the energy consumption of message
passing distributed iterative synchronous applications running over
heterogeneous platforms. We define a heterogeneous platform as a collection of
heterogeneous computing nodes interconnected via a high speed homogeneous
network. Therefore, each node has different characteristics such as computing
power (FLOPS), energy consumption, CPU's frequency range, \dots{} but they all
have the same network bandwidth and latency.


\begin{figure}[t]
  \centering
    \includegraphics[scale=0.6]{fig/commtasks}
  \caption{Parallel tasks on a heterogeneous platform}
  \label{fig:heter}
\end{figure}

 The  overall execution time  of a distributed iterative synchronous application over a heterogeneous platform  consists of the sum of the computation time and the communication time for every iteration on a node. However, due to the heterogeneous computation power of the computing nodes, slack times might occur when fast nodes have to
 wait, during synchronous communications, for  the slower nodes to finish  their computations (see Figure~(\ref{fig:heter})). 
 Therefore,  the overall execution time  of the program is the execution time of the slowest
 task which have the highest computation time and no slack time.
 
Dynamic Voltage and Frequency Scaling (DVFS) is a process, implemented in modern processors, that reduces the energy consumption
of a CPU by scaling down its voltage and frequency.  Since DVFS lowers the frequency of a CPU and consequently its computing power, the execution time of a program running over that scaled down processor might increase, especially if the program is compute bound.  The frequency reduction process can be  expressed by the scaling factor S which is the ratio between  the maximum and the new frequency of a CPU as in EQ (\ref{eq:s}).
\begin{equation}
  \label{eq:s}
 S = \frac{F_\textit{max}}{F_\textit{new}}
\end{equation}
 The execution time of a compute bound sequential program is linearly proportional to the frequency scaling factor $S$. 
 On the other hand,  message passing distributed applications consist of two parts: computation and communication. The execution time of the computation part is linearly proportional to the frequency scaling factor $S$ but  the communication time is not affected by the scaling factor because  the processors involved remain idle during the  communications~\cite{17}. The communication time for a task is the summation of periods of time that begin with an MPI call for sending or receiving   a message till the message is synchronously sent or received.

Since in a heterogeneous platform, each node has different characteristics,
especially different frequency gears, when applying DVFS operations on these
nodes, they may get different scaling factors represented by a scaling vector:
$(S_1, S_2,\dots, S_N)$ where $S_i$ is the scaling factor of processor $i$. To
be able to predict the execution time of message passing synchronous iterative
applications running over a heterogeneous platform, for different vectors of
scaling factors, the communication time and the computation time for all the
tasks must be measured during the first iteration before applying any DVFS
operation. Then the execution time for one iteration of the application with any
vector of scaling factors can be predicted using EQ (\ref{eq:perf}).
\begin{equation}
  \label{eq:perf}
 \textit  T_\textit{new} = 
 \max_{i=1,2,\dots,N} ({TcpOld_{i}} \cdot S_{i}) +  MinTcm
\end{equation}
where $TcpOld_i$ is the computation time  of processor $i$ during the first iteration and $MinTcm$ is the communication time of the slowest processor from the first iteration.  The model computes the maximum computation time 
 with scaling factor from each node  added to the communication time of the slowest node, it means  only the
 communication time without any slack time. Therefore, we can consider the execution time of the iterative application is equal to the execution time of one iteration as in EQ(\ref{eq:perf}) multiplied by the number of iterations of that application.

This prediction model is based on our model for predicting the execution time of message passing distributed applications for homogeneous architectures~\cite{45}. The execution time prediction model is used in our method for optimizing both energy consumption and performance of iterative methods, which is presented in the following sections.


\subsection{Energy model for heterogeneous platform}

Many researchers~\cite{9,3,15,26} divide the power consumed by a processor into
two power metrics: the static and the dynamic power.  While the first one is
consumed as long as the computing unit is turned on, the latter is only consumed during
computation times.  The dynamic power $P_{d}$ is related to the switching
activity $\alpha$, load capacitance $C_L$, the supply voltage $V$ and
operational frequency $F$, as shown in EQ(\ref{eq:pd}).
\begin{equation}
  \label{eq:pd}
  P_\textit{d} = \alpha \cdot C_L \cdot V^2 \cdot F
\end{equation}
The static power $P_{s}$ captures the leakage power as follows:
\begin{equation}
  \label{eq:ps}
   P_\textit{s}  = V \cdot N_{trans} \cdot K_{design} \cdot I_{leak}
\end{equation}
where V is the supply voltage, $N_{trans}$ is the number of transistors,
$K_{design}$ is a design dependent parameter and $I_{leak}$ is a
technology-dependent parameter.  The energy consumed by an individual processor
to execute a given program can be computed as:
\begin{equation}
  \label{eq:eind}
   E_\textit{ind} =  P_\textit{d} \cdot Tcp + P_\textit{s} \cdot T
\end{equation}
where $T$ is the execution time of the program, $T_{cp}$ is the computation
time and $T_{cp} \leq T$.  $T_{cp}$ may be equal to $T$ if there is no
communication and no slack time.

The main objective of DVFS operation is to
reduce the overall energy consumption~\cite{37}.  The operational frequency $F$
depends linearly on the supply voltage $V$, i.e., $V = \beta \cdot F$ with some
constant $\beta$.  This equation is used to study the change of the dynamic
voltage with respect to various frequency values in~\cite{3}.  The reduction
process of the frequency can be expressed by the scaling factor $S$ which is the
ratio between the maximum and the new frequency as in EQ~(\ref{eq:s}).
The CPU governors are power schemes supplied by the operating
system's kernel to lower a core's frequency. we can calculate the new frequency 
$F_{new}$ from EQ(\ref{eq:s}) as follow:
\begin{equation}
  \label{eq:fnew}
   F_\textit{new} = S^{-1} \cdot F_\textit{max}
\end{equation}
Replacing $F_{new}$ in EQ(\ref{eq:pd}) as in EQ(\ref{eq:fnew}) gives the following equation for dynamic 
power consumption:
\begin{multline}
  \label{eq:pdnew}
   {P}_\textit{dNew} = \alpha \cdot C_L \cdot V^2 \cdot F_{new} = \alpha \cdot C_L \cdot \beta^2 \cdot F_{new}^3 \\
   {} = \alpha \cdot C_L \cdot V^2 \cdot F_{max} \cdot S^{-3} = P_{dOld} \cdot S^{-3}
\end{multline}
where $ {P}_\textit{dNew}$  and $P_{dOld}$ are the  dynamic power consumed with the new frequency and the maximum frequency respectively.

According to EQ(\ref{eq:pdnew}) the dynamic power is reduced by a factor of $S^{-3}$ when 
reducing the frequency by a factor of $S$~\cite{3}. Since the FLOPS of a CPU is proportional to the frequency of a CPU, the computation time is increased proportionally to $S$.  The new dynamic energy is the  dynamic power multiplied by the new time of computation and is given by the following equation:
\begin{equation}
  \label{eq:Edyn}
   E_\textit{dNew} = P_{dOld} \cdot S^{-3} \cdot (Tcp \cdot S)= S^{-2}\cdot P_{dOld} \cdot  Tcp 
\end{equation}
The static power is related to the power leakage of the CPU and is consumed during computation and even when idle. As in~\cite{3,46}, we assume that the static power of a processor is constant during idle and computation periods, and for all its available frequencies. 
The static energy is the static power multiplied by the execution time of the program. According to the execution time model in EQ(\ref{eq:perf}), 
the execution time of the program is the summation of the computation and the communication times. The computation time is linearly related  
to the frequency scaling factor, while this scaling factor does not affect the communication time. The static energy 
of a processor after scaling its frequency is computed as follows: 
\begin{equation}
  \label{eq:Estatic}
 E_\textit{s} = P_\textit{s} \cdot (Tcp \cdot S  + Tcm)
\end{equation}

In the considered heterogeneous platform, each processor $i$ might have different dynamic and static powers, noted as $Pd_{i}$ and $Ps_{i}$ respectively. Therefore, even if the distributed message passing iterative application is load balanced, the computation time of each CPU $i$ noted $Tcp_{i}$ might be different and different frequency  scaling factors might be computed in order to decrease the overall energy consumption of the application and reduce the slack times. The communication time of a processor $i$ is noted as $Tcm_{i}$ and could contain slack times if it is communicating with slower nodes, see figure(\ref{fig:heter}). Therefore, all nodes do not have equal communication times. While the dynamic energy is computed according to the frequency scaling factor and the dynamic power of each node as in EQ(\ref{eq:Edyn}), the static energy is computed as the sum of the execution time of each processor multiplied by its static power. The overall energy consumption of a message passing  distributed application executed over a heterogeneous platform during one iteration is the summation of all dynamic and static energies for each  processor.  It is computed as follows:
\begin{multline}
  \label{eq:energy}
 E = \sum_{i=1}^{N} {(S_i^{-2} \cdot Pd_{i} \cdot  Tcp_i)} + {} \\
 \sum_{i=1}^{N} (Ps_{i} \cdot (\max_{i=1,2,\dots,N} (Tcp_i \cdot S_{i}) +
  {MinTcm))}
 \end{multline}

Reducing the frequencies of the processors according to the vector of
scaling factors $(S_1, S_2,\dots, S_N)$ may degrade the performance of the
application and thus, increase the static energy because the execution time is
increased~\cite{36}. We can measure the overall energy consumption for the iterative 
application by measuring  the energy consumption for one iteration as in EQ(\ref{eq:energy}) multiplied by 
the number of iterations of that application.


\section{Optimization of both energy consumption and performance}
\label{sec.compet}

Using the lowest frequency for each processor does not necessarily gives the most energy efficient execution of an application. Indeed, even though the dynamic power is reduced while scaling down the frequency of a processor, its computation power is proportionally decreased and thus the execution time might be drastically increased during which dynamic and static powers are being consumed. Therefore,  it might cancel any gains achieved by scaling down the frequency of all nodes to the minimum  and the overall energy consumption of the application might not be the optimal one. It is not trivial to select the appropriate frequency scaling factor for each processor while considering the characteristics of each processor (computation power, range of frequencies, dynamic and static powers) and the task executed (computation/communication ratio) in order to reduce the overall energy consumption and not significantly increase the execution time. In our previous work~\cite{45}, we  proposed a method that selects the optimal 
frequency scaling factor for a homogeneous cluster executing a message passing iterative synchronous application while giving the best trade-off
 between the energy consumption and the performance for such applications. In this work we are interested in 
heterogeneous clusters as described above. Due to the heterogeneity of the processors, not one but a  vector of scaling factors should be selected and it must  give the best trade-off between energy consumption and performance. 

The relation between the energy consumption and the execution
time for an application is complex and nonlinear, Thus, unlike the relation between the execution time 
and the scaling factor, the relation of the energy with the frequency scaling
factors is nonlinear, for more details refer to~\cite{17}.  Moreover, they are
not measured using the same metric.  To solve this problem, we normalize the
execution time by computing the ratio between the new execution time (after scaling down the frequencies of some processors) and the initial one (with maximum frequency for all nodes,) as follows:
\begin{multline}
  \label{eq:pnorm}
  P_\textit{Norm} = \frac{T_\textit{New}}{T_\textit{Old}}\\
       {} = \frac{ \max_{i=1,2,\dots,N} (Tcp_{i} \cdot S_{i}) +MinTcm}
           {\max_{i=1,2,\dots,N}{(Tcp_i+Tcm_i)}}
\end{multline}


In the same way, we normalize the energy by computing the ratio between the consumed energy while scaling down the frequency and the consumed energy with maximum frequency for all nodes:
\begin{multline}
  \label{eq:enorm}
  E_\textit{Norm} = \frac{E_\textit{Reduced}}{E_\textit{Original}} \\
  {} = \frac{ \sum_{i=1}^{N}{(S_i^{-2} \cdot Pd_i \cdot  Tcp_i)} +
 \sum_{i=1}^{N} {(Ps_i \cdot T_{New})}}{\sum_{i=1}^{N}{( Pd_i \cdot  Tcp_i)} +
 \sum_{i=1}^{N} {(Ps_i@+eYd162 \cdot T_{Old})}}
\end{multline} 
Where $T_{New}$ and $T_{Old}$ are computed as in EQ(\ref{eq:pnorm}).

 While the main 
goal is to optimize the energy and execution time at the same time, the normalized energy and execution time curves are not in the same direction. According 
to the equations~(\ref{eq:enorm}) and~(\ref{eq:pnorm}), the vector  of frequency
scaling factors $S_1,S_2,\dots,S_N$ reduce both the energy and the execution
time simultaneously.  But the main objective is to produce maximum energy
reduction with minimum execution time reduction.  

Many researchers used different strategies to solve this nonlinear problem for example
in~\cite{19,42}, their methods add big overheads to the algorithm to select the
suitable frequency.  In this paper we  present a method to find the optimal
set of frequency scaling factors to simultaneously optimize both energy and execution time
 without adding a big overhead. \textbf{put the last two phrases in the related work section}
 
  
Our solution for this problem is to make the optimization process for energy and execution time follow the same
direction.  Therefore, we inverse the equation of the normalized execution time which gives 
the normalized performance equation, as follows:
\begin{multline}
  \label{eq:pnorm_inv}
  P_\textit{Norm} = \frac{T_\textit{Old}}{T_\textit{New}}\\
          = \frac{\max_{i=1,2,\dots,N}{(Tcp_i+Tcm_i)}}
            { \max_{i=1,2,\dots,N} (Tcp_{i} \cdot S_{i}) + MinTcm} 
\end{multline}


\begin{figure}
  \centering
  \subfloat[Homogeneous platform]{%
    \includegraphics[width=.22\textwidth]{fig/homo}\label{fig:r1}}%
  \qquad%
  \subfloat[Heterogeneous platform]{%
    \includegraphics[width=.22\textwidth]{fig/heter}\label{fig:r2}}
  \label{fig:rel}
  \caption{The energy and performance relation}
\end{figure}

Then, we can model our objective function as finding the maximum distance
between the energy curve EQ~(\ref{eq:enorm}) and the  performance
curve EQ~(\ref{eq:pnorm_inv}) over all available sets of scaling factors.  This
represents the minimum energy consumption with minimum execution time (maximum 
performance) at the same time, see figure~(\ref{fig:r1}) or figure~(\ref{fig:r2}) .  Then our objective
function has the following form:
\begin{equation}
  \label{eq:max}
  Max Dist = 
  \max_{i=1,\dots F, j=1,\dots,N}
      (\overbrace{P_\textit{Norm}(S_{ij})}^{\text{Maximize}} -
       \overbrace{E_\textit{Norm}(S_{ij})}^{\text{Minimize}} )
\end{equation}
where $N$ is the number of nodes and $F$ is the  number of available frequencies for each nodes. 
Then we can select the optimal set of scaling factors that satisfies EQ~(\ref{eq:max}).  Our objective function can
work with any energy model or any power values for each node (static and dynamic powers).
However, the most energy reduction gain can be achieved when the energy curve has a convex form as shown in~\cite{15,3,19}.

\section{The scaling factors selection algorithm for heterogeneous platforms }
\label{sec.optim}

In this section we  propose algorithm~(\ref{HSA}) which selects the frequency scaling factors vector that gives the best trade-off between minimizing the energy consumption  and maximizing the performance of a message passing synchronous iterative application executed on a heterogeneous platform.  
It works online during the execution time of the iterative message passing program.  It uses information gathered during the first iteration such as the computation time and the communication time in one iteration for each node. The algorithm is executed  after the first iteration and returns a vector of optimal frequency scaling factors   that satisfies the objective function EQ(\ref{eq:max}). The program apply DVFS operations to change the frequencies of the CPUs according to the computed scaling factors.  This algorithm is called just once during the execution of the program. Algorithm~(\ref{dvfs}) shows where and when the proposed scaling algorithm is called in the iterative MPI program.


The nodes in a heterogeneous platform have different computing powers, thus while executing message passing iterative synchronous applications, fast nodes have to wait for the slower ones to finish their computations before being able to synchronously communicate with them as in figure (\ref{fig:heter}). These periods are called idle or slack times.
Our algorithm takes into account this problem and tries to reduce these slack times when selecting the frequency scaling factors vector. At first, it selects initial frequency scaling factors that increase the execution times of fast nodes and  minimize the  differences between  the  computation times of fast and slow nodes. The value of the initial frequency scaling factor  for each node is inversely proportional to its computation time that was gathered from the first iteration. These initial frequency scaling factors are computed as   a ratio between the computation time of the slowest node and the computation time of the node $i$ as follows:
\begin{equation}
  \label{eq:Scp}
 Scp_{i} = \frac{\max_{i=1,2,\dots,N}(Tcp_i)}{Tcp_i}
\end{equation}
Using the initial  frequency scaling factors computed in EQ(\ref{eq:Scp}), the algorithm computes the initial frequencies for all nodes as a ratio between the 
maximum frequency of node $i$  and the computation scaling factor $Scp_i$ as follows:
\begin{equation}
  \label{eq:Fint}
 F_{i} = \frac{Fmax_i}{Scp_i},~{i=1,2,\cdots,N}
\end{equation}
If the computed initial frequency for a node is not available in the gears of that node, the computed initial frequency is replaced by the nearest available frequency.
In  figure (\ref{fig:st_freq}), the nodes are  sorted by their computing powers in ascending order and the frequencies of the faster nodes are scaled down according to the computed initial frequency scaling factors. The resulting new frequencies are coloured in blue in  figure (\ref{fig:st_freq}). This set of frequencies can be considered as a higher bound for the search space of the optimal vector of frequencies because selecting frequency scaling factors higher than the higher bound will not improve the performance of the application and it will increase its overall energy consumption. Therefore the frequency selecting factors algorithm starts its search method from these initial frequencies and takes a downward search direction. If the algorithm starts to search from the first frequencies of all nodes, regardless the higher bound frequencies, at each step the predicted performance and energy  are degreased  together, then the best distance be unreachable. This case is similar to homogeneous scaling algorithm when all nodes in the cluster has the same computing power, therefore there is a smaller distance between the performance and the energy curves, while in a heterogeneous cluster the distance is bigger and the energy saving against smaller execution time is higher, as an example see figure~(\ref{fig:r1} and \ref{fig:r2}). The algorithm iterates on all left frequencies, from the higher bound until all nodes reach their minimum frequencies, to compute their overall energy consumption and performance, and select the optimal frequency scaling factors vector. At each iteration the algorithm determines the slowest node according to EQ(\ref{eq:perf}) and keeps its frequency unchanged, while it lowers the frequency of  all other nodes by one gear. The new overall energy consumption and execution time are computed according to the new scaling factors. The optimal set of frequency scaling factors is the set that gives the highest distance according to  the objective function EQ(\ref{eq:max}).
\begin{figure}[t]
  \centering
    \includegraphics[scale=0.5]{fig/start_freq}
  \caption{Selecting the initial frequencies}
  \label{fig:st_freq}
\end{figure}





\begin{algorithm}
  \begin{algorithmic}[1]
    % \footnotesize
    \Require ~
    \begin{description}
    \item[$Tcp_i$] array of all computation times for all nodes during one iteration and with highest frequency.
    \item[$Tcm_i$] array of all communication times for all nodes during one iteration and with highest frequency.
    \item[$Fmax_i$] array of the maximum frequencies for all nodes.
    \item[$Pd_i$] array of the dynamic powers for all nodes.
    \item[$Ps_i$] array of the static powers for all nodes.
    \item[$Fdiff_i$] array of the difference between two successive frequencies for all nodes.
    \end{description}
    \Ensure $Sopt_1,Sopt_2 \dots, Sopt_N$ is a vector of optimal scaling factors

    \State $ Scp_i \gets \frac{\max_{i=1,2,\dots,N}(Tcp_i)}{Tcp_i} $
    \State $F_{i} \gets  \frac{Fmax_i}{Scp_i},~{i=1,2,\cdots,N}$
    \State Round the computed initial frequencies $F_i$ to the closest one available in each node.
    \If{(not the first frequency)}
          \State $F_i \gets F_i+Fdiff_i,~i=1,\dots,N.$
    \EndIf 
    \State $T_\textit{Old} \gets max_{~i=1,\dots,N } (Tcp_i+Tcm_i)$
    \State $E_\textit{Original} \gets \sum_{i=1}^{N}{( Pd_i \cdot  Tcp_i)} +\sum_{i=1}^{N} {(Ps_i \cdot T_{Old})}$
    \State $Dist \gets 0$
    \State  $Sopt_{i} \gets 1,~i=1,\dots,N. $
    \While {(all nodes not reach their  minimum  frequency)}
        \If{(not the last freq. \textbf{and} not the slowest node)}
        \State $F_i \gets F_i - Fdiff_i,~i=1,\dots,N.$
        \State $S_i \gets \frac{Fmax_i}{F_i},~i=1,\dots,N.$
        \EndIf
       \State $T_{New} \gets max_\textit{~i=1,\dots,N} (Tcp_{i} \cdot S_{i}) + MinTcm $
       \State $E_\textit{Reduced} \gets \sum_{i=1}^{N}{(S_i^{-2} \cdot Pd_i \cdot  Tcp_i)} + $  \hspace*{43 mm} 
               $\sum_{i=1}^{N} {(Ps_i \cdot T_{New})} $
       \State $ P_\textit{Norm} \gets \frac{T_\textit{Old}}{T_\textit{New}}$
       \State $E_\textit{Norm}\gets \frac{E_\textit{Reduced}}{E_\textit{Original}}$
      \If{$(\Pnorm - \Enorm > \Dist)$}
        \State $Sopt_{i} \gets S_{i},~i=1,\dots,N. $
        \State $\Dist \gets \Pnorm - \Enorm$
      \EndIf
    \EndWhile
    \State  Return $Sopt_1,Sopt_2,\dots,Sopt_N$
  \end{algorithmic}
  \caption{Heterogeneous scaling algorithm}
  \label{HSA}
\end{algorithm}

\begin{algorithm}
  \begin{algorithmic}[1]
    % \footnotesize
    \For {$k=1$ to \textit{some iterations}}
      \State Computations section.
      \State Communications section.
      \If {$(k=1)$}
        \State Gather all times of computation and\newline\hspace*{3em}%
               communication from each node.
        \State Call algorithm from Figure~\ref{HSA} with these times.
        \State Compute the new frequencies from the\newline\hspace*{3em}%
               returned optimal scaling factors.
        \State Set the new frequencies to nodes.
      \EndIf
    \EndFor
  \end{algorithmic}
  \caption{DVFS algorithm}
  \label{dvfs}
\end{algorithm}

\section{Experimental results}
\label{sec.expe}

The experiments of this work are executed on the simulator SimGrid/SMPI
v3.10~\cite{casanova+giersch+legrand+al.2014.versatile}. We are configure the
simulator to use a heterogeneous cluster with one core per node. The proposed
heterogeneous cluster has four different types of nodes. Each node in the cluster
has different characteristics such as the maximum frequency speed, the number of
available frequencies and dynamic and static powers values, see table
(\ref{table:platform}). These different types of processing nodes are simulate some
real Intel processors. The maximum number of nodes that supported by the cluster
is 144 nodes according to characteristics of some MPI programs of the NAS
benchmarks v3.3 \cite{44} that used. We are use the same number from each type of nodes when we
run the iterative MPI programs, for example if  we are execute the program on 8 node, there
are 2 nodes from each type participating in the computation. The dynamic and
static power values is different from one type to other. Each node has a dynamic
and static power values proportionally increased to their computing power (FLOPS), for more
details see the Intel data sheets in \cite{47}.  Each node has a percentage of
80\% for dynamic power and 20\% for static power of the total power
consumption of a CPU, the same assumption is made in \cite{45,3}. These nodes are
connected via an ethernet network with 1 Gbit/s bandwidth. The proposed scaling algorithm has a small
execution time: for a heterogeneous cluster composed of four different types of
nodes having the characteristics presented in table~(\ref{table:platform}), it  
takes \np[ms]{0.04} on average for 4 nodes and \np[ms]{0.15} on average for 144
nodes.  The algorithm complexity is $O(F\cdot (N \cdot4) )$, where $F$ is the
number of iterations and $N$ is the number of computing nodes. The algorithm
needs on average from 12 to 20 iterations to selects the best vector of frequency scaling factors that give the results of the next section.
\begin{table}[htb]
  \caption{Heterogeneous nodes characteristics}
  % title of Table
  \centering
  \begin{tabular}{|*{7}{l|}}
    \hline
    Node     & Similar     & Max        & Min          & Diff.          & Dynamic      & Static \\
    type     & to          & Freq. GHz  & Freq. GHz    & Freq. GHz       & power        & power \\
    \hline
    1       & core-i3       & 2.5         & 1.2          & 0.1           & 20~w         &4~w    \\
            &  2100T        &             &              &               &              &  \\
    \hline
    2       & Xeon          & 2.66        & 1.6          & 0.133         & 25~w         &5~w    \\
            & 7542          &             &              &               &              &  \\
    \hline
    3       & core-i5       & 2.9         & 1.2          & 0.1           & 30~w         &6~w    \\
            & 3470s         &             &              &               &              &  \\
    \hline
    4       & core-i7       & 3.4         & 1.6          & 0.133         & 35~w         &7~w    \\
            & 2600s         &             &              &               &              &  \\
    \hline
  \end{tabular}
  \label{table:platform}
\end{table}

 
%\subsection{Performance prediction verification}


\subsection{The experimental results of the scaling algorithm}
\label{sec.res}

The proposed algorithm was applied to seven MPI programs of the NAS benchmarks (EP, CG, MG, FT, BT, LU and SP) NPB v3.3,  which were run with three classes (A, B and C).
In this experiments we are interested to run the class C, the biggest class compared to A and B, on different number of 
nodes, from 4 to 144 nodes according to the type of the iterative MPI program.  Depending on the proposed energy consumption model EQ(\ref{eq:energy}),
 we are measure the energy consumption for all the NAS MPI programs. The dynamic and static power values are used under the same assumption used by \cite{45,3}, we are used a percentage of 80\% for dynamic power and 20\% for static of the total power consumption of a CPU. The heterogeneous nodes in table (\ref{table:platform}) have different  simulated computing power (FLOPS), ranked from the node of type 1 with smaller computing power (FLOPS) to the highest computing power (FLOPS) for node of type 4. Therefore, the power values are used proportionally increased from nodes of type 1 to nodes of type 4 that with highest computing power. Then, we are used an assumption that the power consumption is increased linearly when the computing power (FLOPS) of the processor is increased, see \cite{48}.   
 
\begin{table}[htb]
  \caption{Running NAS benchmarks on 4 nodes }
  % title of Table
  \centering
  \begin{tabular}{|*{7}{l|}}
    \hline
    Method     & Execution     & Energy         & Energy      & Performance        & Distance      \\
    name       & time/s        & consumption/J  & saving\%    & degradation\%      &               \\
    \hline
    CG         &  64.64        & 3560.39        &34.16        &6.72               &27.44       \\
    \hline 
    MG         & 18.89         & 1074.87	    &35.37	      &4.34	              &31.03       \\
   \hline
    EP         &79.73	       &5521.04	        &26.83   	  &3.04               &23.79      \\
   \hline
    LU         &308.65	       &21126.00	   &34.00	      &6.16	              &27.84      \\
    \hline
    BT         &360.12         &21505.55	   &35.36         &8.49               &26.87     \\
   \hline
    SP         &234.24	       &13572.16	   &35.22         &5.70	              &29.52    \\
   \hline
    FT         &81.58          &4151.48        &35.58         &0.99        	      &34.59    \\
\hline 
  \end{tabular}
  \label{table:res_4n}
\end{table}

\begin{table}[htb]
  \caption{Running NAS benchmarks on 8 and 9 nodes }
  % title of Table
  \centering
  \begin{tabular}{|*{7}{l|}}
    \hline
    Method     & Execution     & Energy         & Energy      & Performance        & Distance      \\
    name       & time/s        & consumption/J  & saving\%    & degradation\%      &               \\
    \hline
    CG         &36.11    	   &3263.49	        &31.25	      &7.12	               &24.13     \\
    \hline 
    MG         &8.99 	       &953.39	        &33.78	      &6.41	               &27.37     \\
   \hline
    EP         &40.39	       &5652.81	        &27.04	      &0.49	               &26.55     \\
   \hline
    LU         &218.79  	   &36149.77	    &28.23        &0.01   	           &28.22      \\
    \hline
    BT         &166.89 	       &23207.42	    &32.32	      &7.89	               &24.43      \\
   \hline
    SP         &104.73	       &18414.62	    &24.73	      &2.78	               &21.95      \\
   \hline
    FT         &51.10	       &4913.26	        &31.02	      &2.54	               &28.48      \\
\hline 
  \end{tabular}
  \label{table:res_8n}
\end{table}

\begin{table}[htb]
  \caption{Running NAS benchmarks on 16 nodes }
  % title of Table
  \centering
  \begin{tabular}{|*{7}{l|}}
    \hline
    Method     & Execution     & Energy         & Energy      & Performance        & Distance      \\
    name       & time/s        & consumption/J  & saving\%    & degradation\%      &               \\
    \hline
    CG         &31.74	       &4373.90	        &26.29	      &9.57	               &16.72          \\
    \hline 
    MG         &5.71	       &1076.19         &32.49	      &6.05	               &26.44         \\
   \hline
    EP         &20.11	       &5638.49	        &26.85	      &0.56	               &26.29         \\
   \hline
    LU         &144.13	       &42529.06	    &28.80	      &6.56	               &22.24         \\
    \hline
    BT         &97.29	       &22813.86	    &34.95   	  &5.80	               &29.15         \\
   \hline
    SP         &66.49	       &20821.67 	    &22.49	      &3.82	               &18.67         \\
   \hline
    FT     	   &37.01          &5505.60	        &31.59	      &6.48	               &25.11         \\
\hline 
  \end{tabular}
  \label{table:res_16n}
\end{table}

\begin{table}[htb]
  \caption{Running NAS benchmarks on 32 and 36 nodes }
  % title of Table
  \centering
  \begin{tabular}{|*{7}{l|}}
    \hline
    Method     & Execution     & Energy         & Energy      & Performance        & Distance      \\
    name       & time/s        & consumption/J  & saving\%    & degradation\%      &               \\
    \hline
    CG         &32.35	       &6704.21	        &16.15	      &5.30	               &10.85           \\
    \hline 
    MG         &4.30	       &1355.58	        &28.93	      &8.85	               &20.08          \\
   \hline
    EP         &9.96           &5519.68	        &26.98	      &0.02	               &26.96          \\
   \hline
    LU         &99.93	       &67463.43	    &23.60	      &2.45	               &21.15          \\
    \hline
    BT         &48.61	       &23796.97	    &34.62	      &5.83	               &28.79          \\
   \hline
    SP         &46.01	       &27007.43	    &22.72	      &3.45	               &19.27           \\
   \hline
    FT     	   &28.06     	   &7142.69	        &23.09	      &2.90	               &20.19           \\
\hline 
  \end{tabular}
  \label{table:res_32n}
\end{table}

\begin{table}[htb]
  \caption{Running NAS benchmarks on 64 nodes }
  % title of Table
  \centering
  \begin{tabular}{|*{7}{l|}}
    \hline
    Method     & Execution     & Energy         & Energy      & Performance        & Distance      \\
    name       & time/s        & consumption/J  & saving\%    & degradation\%      &               \\
    \hline
    CG         &46.65	       &17521.83	    &8.13	      &1.68	               &6.45           \\
    \hline 
    MG         &3.27	       &1534.70	        &29.27	      &14.35	           &14.92          \\
   \hline
    EP         &5.05           &5471.1084	    &27.12	      &3.11    	           &24.01         \\
   \hline
    LU         &73.92	       &101339.16	    &21.96	      &3.67	               &18.29         \\
    \hline
    BT         &39.99 	       &27166.71	    &32.02	      &12.28	           &19.74         \\
   \hline
    SP         &52.00	       &49099.28	    &24.84	      &0.03	               &24.81         \\
   \hline
    FT         &25.97	       &10416.82        &20.15	      &4.87	               &15.28         \\
\hline 
  \end{tabular}
  \label{table:res_64n}
\end{table}


\begin{table}[htb]
  \caption{Running NAS benchmarks on 128 and 144 nodes }
  % title of Table
  \centering
  \begin{tabular}{|*{7}{l|}}
    \hline
    Method     & Execution     & Energy         & Energy      & Performance        & Distance     \\
    name       & time/s        & consumption/J  & saving\%    & degradation\%      &              \\
    \hline
    CG         &56.92	       &41163.36        &4.00	      &1.10	               &2.90          \\
    \hline 
    MG         &3.55           &2843.33         &18.77	      &10.38	           &8.39          \\
   \hline
    EP         &2.67           &5669.66	        &27.09	      &0.03	               &27.06         \\
   \hline
    LU         &51.23	       &144471.90   	&16.67	      &2.36	               &14.31         \\
    \hline
    BT         &37.96          &44243.82	    &23.18	      &1.28	               &21.90         \\
   \hline
    SP         &64.53	       &115409.71 	    &26.72	      &0.05	               &26.67         \\
   \hline
    FT         &25.51	       &18808.72	    &12.85	      &2.84	               &10.01         \\
\hline 
  \end{tabular}
  \label{table:res_128n}
\end{table}

The results of applying the proposed scaling algorithm to the NAS benchmarks is demonstrated in tables (\ref{table:res_4n}, \ref{table:res_8n}, \ref{table:res_16n}, \ref{table:res_32n}, \ref{table:res_64n} and \ref{table:res_128n}). These tables are show the experimental results for running the NAS benchmarks on different number of nodes. In general the energy saving percent is decreased  when the number of the computing nodes is increased. Also the distance is decreased by the same direction of the energy saving. This because when we are run the iterative MPI programs on a big number of nodes the communications times is increased, so the static energy is increased linearly to these times. The tables also show that the performance degradation percent still approximately the same ratio or decreased in a very small present when the number of computing nodes is increased. This is gives a good prove that the proposed algorithm keeping the performance degradation as mush as possible is the same. 

\begin{figure}
  \centering
  \subfloat[CG, MG, LU and FT benchmarks]{%
    \includegraphics[width=.23185\textwidth]{fig/avg_eq}\label{fig:avg_eq}}%
  \quad%
  \subfloat[BT and SP benchmarks]{%
    \includegraphics[width=.23185\textwidth]{fig/avg_neq}\label{fig:avg_neq}}
  \label{fig:avg}
  \caption{The average of energy and performance for all NAS benchmarks running with difference number of nodes}
\end{figure}

In the NAS benchmarks there are some programs executed on different number of
nodes. The benchmarks CG, MG, LU and FT executed on 2 to a power of (1, 2, 4, 8,
\dots{}) of nodes. The other benchmarks such as BT and SP executed on 2 to a
power of (1, 2, 4, 9, \dots{}) of nodes. We are take the average of energy
saving, performance degradation and distances for all results of NAS
benchmarks. The average of values of these three objectives are plotted to the number of
nodes as in plots (\ref{fig:avg_eq} and \ref{fig:avg_neq}).  In CG, MG, LU, and
FT benchmarks the average of energy saving is decreased when the number of nodes
is increased because the communication times is increased as mentioned
before. Thus, the average of distances (our objective function) is decreased
linearly with energy saving while keeping the average of performance degradation approximately is 
the same. In BT and SP benchmarks, the average of the  energy saving is not decreased
significantly compare to other benchmarks when the number of nodes is
increased. Nevertheless, the average of performance degradation approximately
still the same ratio. This difference is depends on the characteristics of the
benchmark such as the computations to communications ratio that has.

\subsection{The results for different power consumption scenarios}

The results of the previous section are obtained using a percentage of 80\% for
dynamic power and 20\% for static power of the total power consumption of a CPU. In this
section we are change these ratio by using two others power scenarios. Because is
interested to measure the ability of the proposed algorithm when these power ratios are changed. 
In fact, we are used two different scenarios for dynamic and static power ratios in addition to the previous
scenario in section (\ref{sec.res}). Therefore, we have three different
scenarios for three different dynamic and static power ratios refer to these as: 
70\%-20\%, 80\%-20\% and 90\%-10\% scenario respectively. The results of these scenarios
running the NAS benchmarks class C on 8 or 9 nodes are place in the tables
(\ref{table:res_s1} and \ref{table:res_s2}).

 \begin{table}[htb]
  \caption{The results of 70\%-30\% powers scenario}
  % title of Table
  \centering
  \begin{tabular}{|*{6}{l|}}
    \hline
    Method     & Energy          & Energy      & Performance        & Distance     \\
    name       & consumption/J   & saving\%    & degradation\%      &              \\
    \hline
    CG         &4144.21          &22.42        &7.72                &14.70         \\
    \hline 
    MG         &1133.23          &24.50        &5.34                &19.16          \\
   \hline
    EP         &6170.30	        &16.19	       &0.02	            &16.17          \\
   \hline
    LU         &39477.28        &20.43	       &0.07	            &20.36          \\
    \hline
    BT         &26169.55	    &25.34	       &6.62	            &18.71          \\
   \hline
    SP         &19620.09	    &19.32	       &3.66	            &15.66          \\
   \hline
    FT         &6094.07	        &23.17	       &0.36	            &22.81          \\
\hline 
  \end{tabular}
  \label{table:res_s1}
\end{table}



\begin{table}[htb]
  \caption{The results of 90\%-10\% powers scenario}
  % title of Table
  \centering
  \begin{tabular}{|*{6}{l|}}
    \hline
    Method     & Energy          & Energy      & Performance        & Distance     \\
    name       & consumption/J   & saving\%    & degradation\%      &              \\
    \hline
    CG         &2812.38	         &36.36	       &6.80                &29.56         \\
    \hline 
    MG         &825.427	         &38.35	       &6.41	            &31.94         \\
   \hline
    EP         &5281.62	         &35.02	       &2.68	            &32.34         \\
   \hline
    LU         &31611.28	     &39.15        &3.51	            &35.64        \\
    \hline
    BT         &21296.46	     &36.70	       &6.60	            &30.10       \\
   \hline
    SP         &15183.42	     &35.19	       &11.76	            &23.43        \\
   \hline
    FT         &3856.54	         &40.80	       &5.67	            &35.13        \\
\hline 
  \end{tabular}
  \label{table:res_s2}
\end{table}


\begin{figure}
  \centering
  \subfloat[Comparison the average of the results on 8 nodes]{%
    \includegraphics[width=.22\textwidth]{fig/sen_comp}\label{fig:sen_comp}}%
  \quad%
  \subfloat[Comparison the selected frequency scaling factors for 8 nodes]{%
    \includegraphics[width=.24\textwidth]{fig/three_scenarios}\label{fig:scales_comp}}
  \label{fig:comp}
  \caption{The comparison of the three power scenarios}
\end{figure}  

To compare the results of these three powers scenarios, we are take the average of the performance degradation, the energy saving and the distances for all NAS benchmarks running on 8 or 9 nodes of class C, as in figure (\ref{fig:sen_comp}). Thus, according to the average of these results, the energy saving ratio is increased when using a higher percentage for dynamic power (e.g. 90\%-10\% scenario), due to increase in dynamic energy. While the average of energy saving is decreased in 70\%-30\% scenario. Because the static energy consumption is increase. Moreover, the average of distances is more related to energy saving changes. The average of the performance degradation is decreased when using a higher ratio for static power (e.g. 70\%-30\% scenario and 80\%-20\% scenario). The raison behind these relations, that the proposed algorithm optimize both energy consumption and performance in the same time. Therefore, when using a higher ratio for dynamic power the algorithm selecting bigger frequency scaling factors values, more energy saving versus more performance degradation, for example see the figure (\ref{fig:scales_comp}). The inverse happen when using a higher ratio for  static  power, the algorithm proportionally  selects a smaller scaling values, less energy saving versus less performance degradation. This is because the  
algorithm is optimizes the  static energy consumption that is always related to the execution time. 

\subsection{The verifications of the proposed method}
\label{sec.verif}
The precision of the proposed algorithm mainly depends on the execution time prediction model EQ(\ref{eq:perf}) and the energy model EQ(\ref{eq:energy}). The energy model is significantly depends on the execution time model, that the static energy is related linearly. So, our work is depends mainly on execution time model. To verifying this model, we are compared the predicted execution time with the real execution time (Simgrid time) values that gathered  offline from the NAS benchmarks class B executed on 8 or 9 nodes. The execution time model can predicts the real execution time by maximum normalized error equal to 0.03 for all the NAS benchmarks. The second verification that we are made is for the proposed scaling algorithm to prove its ability to selects the best vector of the frequency scaling factors. Therefore, we are expand the algorithm to test at each iteration the frequency scaling factor of the slowest node with the all available scaling factors of the other nodes, all possible solutions. This version of the algorithm is applied to different NAS benchmarks classes with different number of nodes. The results from the expanded algorithms and the proposed algorithm are identical. While the proposed algorithm is runs  by 10 times faster on average compare to the expanded algorithm.

\section{Conclusion}
\label{sec.concl}


\section*{Acknowledgment}


% trigger a \newpage just before the given reference
% number - used to balance the columns on the last page
% adjust value as needed - may need to be readjusted if
% the document is modified later
%\IEEEtriggeratref{15}

\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,my_reference}
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% fill-column: 80
%%% ispell-local-dictionary: "american"
%%% End:

% LocalWords:  Fanfakh Charr FIXME Tianhe DVFS HPC NAS NPB SMPI Rauber's Rauber
% LocalWords:  CMOS EQ EPSA Franche Comté Tflop Rünger IUT Maréchal Juin cedex
% LocalWords:  de badri muslim MPI TcpOld TcmOld dNew dOld cp Sopt Tcp Tcm Ps
% LocalWords:  Scp Fmax Fdiff SimGrid GFlops Xeon EP BT
