\documentclass[conference]{IEEEtran}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{algpseudocode}
\usepackage{graphicx,graphics}
\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}

\begin{document}

\title{Dynamic Frequency Scaling for Energy Consumption
  Reduction in Synchronous Distributed Applications}

\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}
  Dynamic Voltage Frequency Scaling (DVFS) can be applied to modern CPUs.  This
  technique is usually used to reduce the energy consumed by a CPU while
  computing.  Thus, decreasing the frequency
  reduces the power consumed by the CPU.  However, it can also significantly
  affect the performance of the executed program if it is compute bound and if a
  low CPU frequency is selected.  Therefore, the chosen scaling factor must
  give the best possible trade-off between energy reduction and performance.

  In this paper we present an algorithm that predicts the energy consumed with
  each frequency gear and selects the one that gives the best ratio between
  energy consumption reduction and performance.  This algorithm works online
  without training or profiling and has a very small overhead.  It also takes
  into account synchronous communications between the nodes that are executing
  the distributed algorithm.  The algorithm has been evaluated over the SimGrid
  simulator while being applied to the NAS parallel benchmark programs.  The
  results of the experiments show that it outperforms other existing scaling
  factor selection algorithms.
\end{abstract}

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

The need and demand for more computing power have been increasing since the
birth of the first computing unit and it is not expected to slow down in the
coming years.  To satisfy this demand, researchers and supercomputers
constructors have been regularly increasing the number of computing cores and
processors in supercomputers (for example in November 2013, according to the
TOP500 list~\cite{43}, the Tianhe-2 was the fastest supercomputer.  It has more
than 3 million of cores and delivers more than \np[Tflop/s]{33} while consuming
\np[kW]{17808}).  This large increase in number of computing cores has led to
large energy consumption by these architectures.  Moreover, the price of energy
is expected to continue its ascent according to the demand.  For all these
reasons energy reduction has become an important topic in the high performance
computing field.  To tackle this problem, many researchers use DVFS (Dynamic
Voltage Frequency Scaling) operations which reduce dynamically the frequency and
voltage of cores and thus their energy consumption.  Indeed, modern CPUs offer a
set of acceptable frequencies which are usually called gears, and the user or
the operating system can modify the frequency of the processor according to its
needs.  However, DVFS also degrades the performance of computation.  Therefore
researchers try to reduce the frequency to the minimum when processors are idle
(waiting for data from other processors or communicating with other processors).
Moreover, depending on their objectives, they use heuristics to find the best
scaling factor during the computation.  If they aim for performance they choose
the best scaling factor that reduces the consumed energy while affecting as
little as possible the performance.  On the other hand, if they aim for energy
reduction, the chosen scaling factor must produce the most energy efficient
execution without considering the degradation of the performance.  It is
important to notice that lowering the frequency to the minimum value does not always
give the most energy efficient execution due to energy leakage.  The best
scaling factor might be chosen during execution (online) or during a
pre-execution phase.  In this paper, we present an algorithm that selects a
frequency scaling factor that simultaneously takes into consideration the energy
consumption by the CPU and the performance of the application.  The main
objective of HPC systems is to execute as fast as possible the application.
Therefore, our algorithm selects the scaling factor online with very small
overhead.  The proposed algorithm takes into account the communication times of
the MPI program to choose the scaling factor.  This algorithm has the ability to
predict both energy consumption and execution time over all available scaling
factors.  The prediction achieved depends on some computing time information,
gathered at the beginning of the runtime.  We apply this algorithm to the NAS parallel benchmarks (NPB v3.3)~\cite{44}.  Our experiments are executed using the simulator
SimGrid/SMPI v3.10~\cite{Casanova:2008:SGF:1397760.1398183} over an homogeneous
distributed memory architecture.  Furthermore, we compare the proposed algorithm
with Rauber and Rünger methods~\cite{3}.  The comparison's results show that our
algorithm gives better energy-time trade-off.

This paper is organized as follows: Section~\ref{sec.relwork} presents some
related works from other authors.  Section~\ref{sec.exe}  presents an energy
model for homogeneous platforms.  Section~\ref{sec.mpip} describes how the
performance of MPI programs can be predicted.  Section~\ref{sec.compet} presents
the energy-performance objective function that maximizes the reduction of energy
consumption while minimizing the degradation of the program's performance.
Section~\ref{sec.optim} details the proposed energy-performance algorithm.
Section~\ref{sec.expe} verifies the accuracy of the performance prediction model
and presents the results of the proposed algorithm.  It also shows the
comparison results between our method and other existing methods.  Finally, we
conclude in Section~\ref{sec.concl} with a summary and some future works.

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


In this section, some heuristics to compute the scaling factor are presented and
classified into two categories: offline and online methods.

\subsection{Offline scaling factor selection methods}

The offline scaling factor selection methods are executed before the runtime of
the program.  They return static scaling factor values to the processors
participating in the execution of the parallel program.  On the one hand, the
scaling factor values could be computed based on information retrieved by
analyzing the code of the program and the computing system that will execute it.
In~\cite{40}, Azevedo et al. detect during compilation the dependency points
between tasks in a multi-task program.  This information is then used to lower
the frequency of some processors in order to eliminate slack times.  A slack
time is the period of time during which a processor that has already finished
its computation, has to wait for a set of processors to finish their
computations and send their results to the waiting processor in order to
continue its task that is dependent on the results of computations being
executed on other processors.  Freeh et al. showed in~\cite{17} that the
communication times of MPI programs do not change when the frequency is scaled
down.  On the other hand, some offline scaling factor selection methods use the
information gathered from previous full or partial executions of the program. The whole program or, a 
part of it,  is usually executed over all the available frequency
gears and the execution time and the energy consumed with each frequency
gear are measured.  Then a heuristic or an exact method uses the retrieved
information to compute the values of the scaling factor for the processors.
In~\cite{8} , Rountree et al. use a linear programming algorithm, while in~\cite{34}, Cochran et
al. use a multi-logistic regression algorithm for the same goal.  The main
drawback of these methods is that they all require executing the
whole program or, a part of it, on all frequency gears for each new instance of the same program.

\subsection{Online scaling factor selection methods}

The online scaling factor selection methods are executed during the runtime of
the program.  They are usually integrated into iterative programs where the same
block of instructions is executed many times.  During the first few iterations,
a lot of information is measured such as the execution time, the energy consumed
using a multimeter, the slack times, \dots{} Then a method will exploit these
measurements to compute the scaling factor values for each processor.  This
operation, measurements and computing new scaling factor, can be repeated as
much as needed if the iterations are not regular. Peraza, Yu-Liang et
al.~\cite{2,31} used varied heuristics to select the appropriate scaling
factor values to eliminate the slack times during runtime.  However, as seen
in~\cite{19}, machine learning method takes a lot of time to converge
when the number of available gears is big.  To reduce the impact of slack times,
in~\cite{1}, Lim et al. developed an algorithm that detects the communication
sections and changes the frequency during these sections only.  This approach
might change the frequency of each processor many times per iteration if an
iteration contains more than one communication section.  In~\cite{3}, Rauber and
Rünger used an analytical model that can predict the consumed energy for every frequency gear after measuring the consumed energy. They
maintain the performance as mush as possible by setting the highest frequency gear to the slowest task. 

The primary contribution of 
our paper is to present a new online scaling factor selection method which has the
 following characteristics:\\
1) It is based on Rauber and Rünger analytical model to predict the energy
  consumption of the application with different frequency gears. 
2) It selects the frequency scaling factor for simultaneously optimizing
  energy reduction and maintaining performance. 
3) It is well adapted to distributed architectures because it takes into
  account the communication time. 
4) It is well adapted to distributed applications with imbalanced tasks.
5) It has a very small overhead when compared to other methods
  (e.g.,~\cite{19}) and does not require profiling or training as
  in~\cite{34}.


% \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}


\section{Energy model for homogeneous platform}
\label{sec.exe}
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 on, the latter is only consumed during
computation times.  The dynamic power $P_{dyn}$ is related to the switching
activity $\alpha$, load capacitance $C_L$, the supply voltage $V$ and
operational frequency $f$, as shown in EQ~\eqref{eq:pd}.
\begin{equation}
  \label{eq:pd}
  P_\textit{dyn} = \alpha \cdot C_L \cdot V^2 \cdot f
\end{equation}
The static power $P_{static}$ captures the leakage power as follows:
\begin{equation}
  \label{eq:ps}
   P_\textit{static}  = 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{dyn} \cdot T_{Comp} + P_\textit{static} \cdot T
\end{equation}
where $T$ is the execution time of the program, $T_{Comp}$ is the computation
time and $T_{Comp} \leq T$.  $T_{Comp}$ may be equal to $T$ if there is no
communication, no slack time and no synchronization.

DVFS is a process that is allowed in modern processors to reduce the dynamic
power by scaling down the voltage and frequency.  Its main objective 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~\eqref{eq:s}.
\begin{equation}
  \label{eq:s}
 S = \frac{F_\textit{max}}{F_\textit{new}}
\end{equation}
The value of the scaling factor $S$ is greater than 1 when changing the
frequency of the CPU to any new frequency value~(\emph{P-state}) in the
governor. This factor reduces quadratically
the dynamic power which may cause degradation in performance and thus, the
increase of the static energy because the execution time is increased~\cite{36}.
If the tasks are sorted according to their execution times before scaling in a
descending order, the total energy consumption model for a parallel homogeneous
platform, as presented by Rauber and Rünger~\cite{3}, can be written as a
function of the scaling factor $S$, as in EQ~\eqref{eq:energy}.

\begin{equation}
  \label{eq:energy}
  E = P_\textit{dyn} \cdot S_1^{-2} \cdot
    \left( T_1 + \sum_{i=2}^{N} \frac{T_i^3}{T_1^2} \right) +
    P_\textit{static} \cdot T_1 \cdot S_1 \cdot N
 \hfill
\end{equation}
where $N$ is the number of parallel nodes, $T_i$ for $i=1,\dots,N$ are
the execution times and scaling factors of the sorted tasks.  Therefore, $T1$ is
the time of the slowest task, and $S_1$ its scaling factor which should be the
highest because they are proportional to the time values $T_i$.  The scaling
factors are computed as in EQ~\eqref{eq:si}.
\begin{equation}
  \label{eq:si}
  S_i = S \cdot \frac{T_1}{T_i}
      = \frac{F_\textit{max}}{F_\textit{new}} \cdot \frac{T_1}{T_i}
\end{equation}
In this paper we use Rauber and Rünger's energy model, EQ~\eqref{eq:energy}, because it can be applied to homogeneous clusters if the communication time is taken in consideration. Moreover, we compare our algorithm with Rauber and Rünger's scaling factor selection
method which uses the same energy model.  In their method, the optimal scaling factor is
computed by minimizing the derivation of EQ~\eqref{eq:energy} which produces
EQ~\eqref{eq:sopt}.

\begin{equation}
  \label{eq:sopt}
  S_\textit{opt} = \sqrt[3]{\frac{2}{N} \cdot \frac{P_\textit{dyn}}{P_\textit{static}} \cdot
    \left( 1 + \sum_{i=2}^{N} \frac{T_i^3}{T_1^3} \right) }
\end{equation}


\section{Performance evaluation of MPI programs}
\label{sec.mpip}

The performance (execution time) of parallel synchronous MPI applications depends
on the time of the slowest task.  If there is no
communication and the application is not data bounded, the execution time of a
parallel program is linearly proportional to the operational frequency and any
DVFS operation for energy reduction increases the execution time of the parallel
program.  Therefore, the scaling factor $S$ is linearly proportional to the
execution time.  However, in most MPI applications the processes exchange
data.  During these communications the processors involved remain idle until the
communications are finished.  For that reason, any change in the frequency has no
impact on the time of communication~\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.  To
be able to predict the execution time of MPI program, the communication time and
the computation time for the slowest task must be measured before scaling.  These
times are used to predict the execution time for any MPI program as a function
of the new scaling factor as in EQ~\eqref{eq:tnew}.
\begin{equation}
  \label{eq:tnew}
 \textit  T_\textit{new} = T_\textit{Max Comp Old} \cdot S + T_{\textit{Max Comm Old}}
\end{equation}
In this paper, this prediction method is used to select the best scaling factor
for each processor as presented in the next section.

\section{Performance and energy reduction trade-off}
\label{sec.compet}

This section presents our approach for choosing the optimal scaling factor.
This factor gives maximum energy reduction while taking into account the execution
times for both computation and communication.  The relation between the performance
and the energy is nonlinear and complex. Thus, unlike the relation between the performance and  the scaling factor,  the relation of energy with the scaling factor 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 energy by calculating the ratio between
the consumed energy with scaled frequency and the consumed energy without scaled
frequency:
\begin{multline}
  \label{eq:enorm}
  E_\textit{Norm} = \frac{ E_\textit{Reduced}}{E_\textit{Original}} \\
        {} = \frac{P_\textit{dyn} \cdot S_1^{-2} \cdot
               \left( T_1 + \sum_{i=2}^{N}\frac{T_i^3}{T_1^2}\right) +
               P_\textit{static} \cdot T_1 \cdot S_1 \cdot N  }{
              P_\textit{dyn} \cdot \left(T_1+\sum_{i=2}^{N}\frac{T_i^3}{T_1^2}\right) +
              P_\textit{static} \cdot T_1 \cdot N }
\end{multline}
In the same way we can normalize the performance as follows:
\begin{equation}
  \label{eq:pnorm}
  P_\textit{Norm} = \frac{T_\textit{New}}{T_\textit{Old}}
          = \frac{T_\textit{Max Comp Old} \cdot S +
           T_\textit{Max Comm Old}}{T_\textit{Max Comp Old} +
           T_\textit{Max Comm Old}}
\end{equation}
The second problem is that the optimization operation for both energy and
performance is not in the same direction.  In other words, the normalized energy
and the performance curves are not at the same direction see
Figure~\ref{fig:rel}\subref{fig:r2}.  While the main goal is to optimize the
energy and performance in the same time.  According to the
equations~\eqref{eq:enorm} and~\eqref{eq:pnorm}, the scaling factor $S$ reduce
both the energy and the performance simultaneously.  But the main objective is
to produce maximum energy reduction with minimum performance reduction.  Many
researchers used different strategies to solve this nonlinear problem for
example see~\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 scaling factor $S$ to optimize both energy and performance
simultaneously without adding a big overhead.  Our solution for this problem is
to make the optimization process for energy and performance follow the same
direction.  Therefore, we inverse the equation of the normalized performance as
follows:
\begin{equation}
  \label{eq:pnorm_en}
  P^{-1}_\textit{Norm} = \frac{ T_\textit{Old}}{ T_\textit{New}}
               = \frac{T_\textit{Max Comp Old} +
                 T_\textit{Max Comm Old}}{T_\textit{Max Comp Old} \cdot S +
                 T_\textit{Max Comm Old}}
\end{equation}
\begin{figure}
  \centering
  \subfloat[Real relation.]{%
    \includegraphics[width=.5\linewidth]{fig/file3}\label{fig:r2}}%
  \subfloat[Converted relation.]{%
    \includegraphics[width=.5\linewidth]{fig/file}\label{fig:r1}}
  \caption{The energy and performance relation}
  \label{fig:rel}
\end{figure}
Then, we can model our objective function as finding the maximum distance
between the energy curve EQ~\eqref{eq:enorm} and the inverse of performance
curve EQ~\eqref{eq:pnorm_en} over all available scaling factors.  This
represents the minimum energy consumption with minimum execution time (better
performance) at the same time, see Figure~\ref{fig:rel}\subref{fig:r1}.  Then
our objective function has the following form:
\begin{equation}
  \label{eq:max}
  \textit{Max Dist} = \max_{j=1,2,\dots,F}
      (\overbrace{P^{-1}_\textit{Norm}(S_j)}^{\text{Maximize}} -
       \overbrace{E_\textit{Norm}(S_j)}^{\text{Minimize}} )
\end{equation}
where $F$ is the number of available frequencies. Then we can select the optimal
scaling factor that satisfies EQ~\eqref{eq:max}.  Our objective function can
work with any energy model or static power values stored in a data file.
Moreover, this function works in optimal way when the energy curve has a convex
form over the available frequency scaling factors as shown in~\cite{15,3,19}.

\section{Optimal scaling factor for performance and energy}
\label{sec.optim}

Algorithm on Figure~\ref{EPSA} computes the optimal scaling factor according to
the objective function described above.
\begin{figure}[tp]
  \begin{algorithmic}[1]
    % \footnotesize
    \State  Initialize the variable $Dist=0$
    \State Set dynamic and static power values.
    \State Set $P_{states}$ to the number of available frequencies.
    \State Set the variable $F_{new}$ to max. frequency,  $F_{new} = F_{max} $
    \State Set the variable $F_{diff}$ to the difference between two successive
           frequencies.
    \For {$j:=1$   to   $P_{states} $}
      \State $F_{new}=F_{new} - F_{diff} $
      \State $S = \frac{F_\textit{max}}{F_\textit{new}}$
      \State $S_i = S \cdot \frac{T_1}{T_i}
                  = \frac{F_\textit{max}}{F_\textit{new}} \cdot \frac{T_1}{T_i}$
             for $i=1,\dots,N$
      \State $E_\textit{Norm} =
          \frac{P_\textit{dyn} \cdot S_1^{-2} \cdot
                  \left( T_1 + \sum_{i=2}^{N}\frac{T_i^3}{T_1^2}\right) +
                  P_\textit{static} \cdot T_1 \cdot S_1 \cdot N }{
                P_\textit{dyn} \cdot
                  \left(T_1+\sum_{i=2}^{N}\frac{T_i^3}{T_1^2}\right) +
                  P_\textit{static} \cdot T_1 \cdot N }$
      \State $P_{NormInv}=T_{old}/T_{new}$
      \If{$(P_{NormInv}-E_{Norm} > Dist)$}
        \State $S_{opt} = S$
        \State $Dist = P_{NormInv} - E_{Norm}$
      \EndIf
    \EndFor
    \State  Return $S_{opt}$
  \end{algorithmic}
  \caption{Scaling factor selection algorithm}
  \label{EPSA}
\end{figure}

The proposed algorithm works online during the execution time of the MPI
program.  It selects the optimal scaling factor after gathering the computation
and communication times from the program after one iteration.  Then the program
changes the new frequencies of the CPUs according to the computed scaling
factors. In our experiments over a homogeneous cluster described in
Section~\ref{sec.expe}, this algorithm has a small execution time. It takes
\np[$\mu$s]{1.52} on average for 4 nodes and \np[$\mu$s]{6.65} on average for 32
nodes.  The algorithm complexity is $O(F\cdot N)$, where $F$ is the number of
available frequencies and $N$ is the number of computing nodes.  The algorithm
is called just once during the execution of the program.  The DVFS algorithm on
Figure~\ref{dvfs} shows where and when the algorithm is called in the MPI
program.
%\begin{table}[htb]
%  \caption{Platform file parameters}
%  % title of Table
%  \centering
%  \begin{tabular}{|*{7}{l|}}
%    \hline
%    Max      & Min      & Backbone        & Backbone         & Link         & Link            & Sharing \\
%    Freq.    & Freq.    & Bandwidth       & Latency          & Bandwidth    & Latency         & Policy  \\
%    \hline
%    \np{2.5} & \np{800} & \np[GBps]{2.25} & \np[$\mu$s]{0.5} & \np[GBps]{1} & \np[$\mu$s]{50} & Full    \\
%    GHz      & MHz      &                 &                  &              &                 & Duplex  \\
%    \hline
%  \end{tabular}
%  \label{table:platform}
%\end{table}

\begin{figure}[tp]
  \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{EPSA} with these times.
        \State Compute the new frequency from the\newline\hspace*{3em}%
              returned optimal scaling factor.
        \State Set the new frequency to the CPU.
      \EndIf
    \EndFor
  \end{algorithmic}
  \caption{DVFS algorithm}
  \label{dvfs}
\end{figure}
After obtaining the optimal scaling factor, the program calculates the new
frequency $F_i$ for each task proportionally to its time value $T_i$.  By
substitution of EQ~\eqref{eq:s} in EQ~\eqref{eq:si}, we can calculate the new
frequency $F_i$ as follows:
\begin{equation}
  \label{eq:fi}
  F_i = \frac{F_\textit{max} \cdot T_i}{S_\textit{optimal} \cdot T_\textit{max}}
\end{equation}
According to this equation all the nodes may have the same frequency value if
they have balanced workloads, otherwise, they take different frequencies when
having imbalanced workloads.  Thus, EQ~\eqref{eq:fi} adapts the frequency of the
CPU to the nodes' workloads to maintain the performance of the program.

\section{Experimental results}
\label{sec.expe}
Our experiments are executed on the simulator SimGrid/SMPI v3.10.  We configure
the simulator to use a homogeneous cluster with one core per node.  
%The detailed characteristics of our platform file are shown in Table~\ref{table:platform}.
Each node in the cluster has 18 frequency values
from \np[GHz]{2.5} to \np[MHz]{800} with \np[MHz]{100} difference between each
two successive frequencies. The nodes are connected via an ethernet network with 1Gbit/s  bandwidth. 

\subsection{Performance prediction verification}

In this section we evaluate the precision of our performance prediction method
based on EQ~\eqref{eq:tnew} by applying it to the NAS benchmarks.  The NAS programs
are executed with the class B option to compare the real execution time with
the predicted execution time.  Each program runs offline with all available
scaling factors on 8 or 9 nodes (depending on the benchmark) to produce real
execution time values.  These scaling factors are computed by dividing the
maximum frequency by the new one see EQ~\eqref{eq:s}.
\begin{figure}
  \centering
  \includegraphics[width=.5\linewidth]{fig/cg_per}\hfill%
 % \includegraphics[width=.5\linewidth]{fig/mg_pre}\hfill%
 % \includegraphics[width=.5\linewidth]{fig/bt_pre}\qquad%
   \includegraphics[width=.5\linewidth]{fig/lu_pre}\hfill%
  \caption{Comparing predicted to real execution times}
  \label{fig:pred}
\end{figure}
%see Figure~\ref{fig:pred}
In our cluster there are 18 available frequency states for each processor.  This
leads to 18 run states for each program.  We use seven MPI programs of the NAS
parallel benchmarks: CG, MG, EP, FT, BT, LU and SP.  Figure~\ref{fig:pred}
presents plots of the real execution times and the simulated ones. The maximum
normalized error between these two execution times varies between \np{0.0073} to
\np{0.031} dependent on the executed benchmark.  The smallest prediction error
was for CG and the worst one was for LU.

\subsection{The experimental results for the scaling algorithm }
The proposed algorithm was applied to seven MPI programs of the NAS benchmarks
(EP, CG, MG, FT, BT, LU and SP) which were run with three classes (A, B and C).
For each instance the benchmarks were executed on a number of processors
proportional to the size of the class.  Each class represents the problem size
ascending from class A to C.  Additionally, depending on some speed up points
for each class we run the classes A, B and C on 4, 8 or 9 and 16 nodes
respectively.  Depending on EQ~\eqref{eq:energy}, we measure the energy
consumption for all the NAS MPI programs while assuming that the dynamic power
with the highest frequency is equal to \np[W]{20} and the power static is equal
to \np[W]{4} for all experiments.  These power values were also used by Rauber
and Rünger in~\cite{3}.  The results showed that the algorithm selected
different scaling factors for each program depending on the communication
features of the program as in the plots from Figure~\ref{fig:nas}.  These plots
illustrate that there are different distances between the normalized energy and
the normalized inverted performance curves, because there are different
communication features for each benchmark.  When there are little or no
communications, the inverted performance curve is very close to the energy
curve.  Then the distance between the two curves is very small.  This leads to
small energy savings.  The opposite happens when there are a lot of
communication, the distance between the two curves is big.  This leads to more
energy savings (e.g. CG and FT), see Table~\ref{table:compareC}.  All discovered
frequency scaling factors optimize both the energy and the performance
simultaneously for all NAS benchmarks.  In Table~\ref{table:compareC}, we record
all optimal scaling factors results for each benchmark running class C.  These
scaling factors give the maximum energy saving percentage and the minimum
performance degradation percentage at the same time from all available scaling
factors.
\begin{figure*}[t]
  \centering
  \includegraphics[width=.33\linewidth]{fig/ep}\hfill%
  \includegraphics[width=.33\linewidth]{fig/cg}\hfill%
 % \includegraphics[width=.328\linewidth]{fig/sp}
 %  \includegraphics[width=.328\linewidth]{fig/lu}\hfill%
  \includegraphics[width=.33\linewidth]{fig/bt}
 % \includegraphics[width=.328\linewidth]{fig/ft}
  \caption{Optimal scaling factors for the predicted energy and performance of NAS benchmarks}
  \label{fig:nas}
\end{figure*}

As shown in Table~\ref{table:compareC}, when the optimal scaling factor has a
big value we can gain more energy savings as in CG and FT benchmarks.  The
opposite happens when the optimal scaling factor has a small value as in BT and
EP benchmarks.  Our algorithm selects a big scaling factor value when the
communication and the other slacks times are big and smaller ones in opposite
cases.  In EP there are no communication inside the iterations.  This leads our
algorithm to select smaller scaling factor values (inducing smaller energy
savings).

\subsection{Results comparison}

In this section, we compare our scaling factor selection method with Rauber and
Rünger methods~\cite{3}.  They had two scenarios, the first is to reduce energy
to the optimal level without considering the performance as in
EQ~\eqref{eq:sopt}.  We refer to this scenario as $R_{E}$.  The second scenario
is similar to the first except setting the slower task to the maximum frequency
(when the scale $S=1$) to keep the performance from degradation as mush as
possible.  We refer to this scenario as $R_{E-P}$.  While we refer to our
algorithm as EPSA (Energy to Performance Scaling Algorithm).  The comparison is
made in Table~\ref{table:compareC}.  This table shows the results of our method and
Rauber and Rünger scenarios for all the NAS benchmarks programs for class C.

\begin{table}
  \caption{Comparing results for the NAS class C}
  % title of Table
  \centering
  \begin{tabular}{|l|l|*{4}{r|}}
    \hline
    Method    & Program & Factor & Energy    & Performance    & Energy-Perf. \\
    Name      & Name    & Value  & Saving \% & Degradation  \% & Distance     \\
    \hline
    % \rowcolor[gray]{0.85}
    $EPSA$    & CG      & 1.56   & 39.23     & 14.88          &  24.35 \\ \hline
    $R_{E-P}$ & CG      & 2.15   & 45.36     & 25.89          &  19.47 \\ \hline
    $R_{E}$   & CG      & 2.15   & 45.36     & 26.70          &  18.66 \\ \hline

    $EPSA$    & MG      & 1.47   & 34.97     & 21.69          &  13.27 \\ \hline
    $R_{E-P}$ & MG      & 2.15   & 43.65     & 40.45          &   3.20 \\ \hline
    $R_{E}$   & MG      & 2.15   & 43.64     & 41.38          &   2.26 \\ \hline

    $EPSA$    & EP      & 1.04   & 22.14     & 20.73          &   1.41 \\ \hline
    $R_{E-P}$ & EP      & 1.92   & 39.40     & 56.33          & -16.93 \\ \hline
    $R_{E}$   & EP      & 1.92   & 38.10     & 56.35          & -18.25 \\ \hline

    $EPSA$    & LU      & 1.38   & 35.83     & 22.49          &  13.34 \\ \hline
    $R_{E-P}$ & LU      & 2.15   & 44.97     & 41.00          &   3.97 \\ \hline
    $R_{E}$   & LU      & 2.15   & 44.97     & 41.80          &   3.17 \\ \hline

    $EPSA$    & BT      & 1.31   & 29.60     & 21.28          &   8.32 \\ \hline
    $R_{E-P}$ & BT      & 2.13   & 45.60     & 49.84          &  -4.24 \\ \hline
    $R_{E}$   & BT      & 2.13   & 44.90     & 55.16          & -10.26 \\ \hline

    $EPSA$    & SP      & 1.38   & 33.48     & 21.35          &  12.12 \\ \hline
    $R_{E-P}$ & SP      & 2.10   & 45.69     & 43.60          &   2.09 \\ \hline
    $R_{E}$   & SP      & 2.10   & 45.75     & 44.10          &   1.65 \\ \hline

    $EPSA$    & FT      & 1.47   & 34.72     & 19.00          &  15.72 \\ \hline
    $R_{E-P}$ & FT      & 2.04   & 39.40     & 37.10          &   2.30 \\ \hline
    $R_{E}$   & FT      & 2.04   & 39.35     & 37.70          &   1.65 \\ \hline
  \end{tabular}
  \label{table:compareC}
  % is used to refer this table in the text
\end{table}
As shown in Table~\ref{table:compareC}, the ($R_{E-P}$) method outperforms the ($R_{E}$)
method in terms of performance and energy reduction.  The ($R_{E-P}$) method
also gives better energy savings than our method.  However, although our scaling
factor is not optimal for energy reduction, the results in this table prove
that our algorithm returns the best scaling factor that satisfy our objective
method: the largest distance between energy reduction and performance
degradation. Figure~\ref{fig:compare}  illustrates even better the distance between 
the energy reduction and performance degradation. The negative values mean that one of
the two objectives (energy or performance) have been degraded more than the
other.  The positive trade-offs with the highest values lead to maximum energy
savings while keeping the performance degradation as low as possible.  Our
algorithm always gives the highest positive energy to performance trade-offs
while Rauber and Rünger's method, ($R_{E-P}$), gives sometimes negative
trade-offs such as in BT and EP.
\begin{figure}[t]
  \centering
%  \includegraphics[width=.328\linewidth]{fig/compare_class_A}
%  \includegraphics[width=.328\linewidth]{fig/compare_class_B}
  \includegraphics[width=\linewidth]{fig/compare_class_C}
  \caption{Comparing our method to Rauber and Rünger's methods}
  \label{fig:compare}
\end{figure}

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

In this paper, we have presented a new online scaling factor selection method
that optimizes simultaneously the energy and performance of a distributed
application running on an homogeneous cluster.  It uses the computation and
communication times measured at the first iteration to predict energy
consumption and the performance of the parallel application at every available
frequency.  Then, it selects the scaling factor that gives the best trade-off
between energy reduction and performance which is the maximum distance between
the energy and the inverted performance curves.  To evaluate this method, we
have applied it to the NAS benchmarks and it was compared to Rauber and Rünger
methods while being executed on the simulator SimGrid.  The results showed that
our method, outperforms Rauber and Rünger's methods in terms of energy-performance
ratio. 

In the near future, we would like to adapt this scaling factor selection method
to heterogeneous platforms where each node has different characteristics.  In
particular, each CPU has different available frequencies, energy consumption and
performance.  It would be also interesting to develop a new energy model for
asynchronous parallel iterative methods where the number of iterations is not
known in advance and depends on the global convergence of the iterative system.

\section*{Acknowledgment}

This work has been partially supported by the Labex ACTION project (contract
``ANR-11-LABX-01-01'').  Computations have been performed on the supercomputer
facilities of the Mésocentre de calcul de Franche-Comté.  As a PhD student,
Mr. Ahmed Fanfakh, would like to thank the University of Babylon (Iraq) for
supporting his work.

% 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
