Adding new functionalities to improve the Maheve algorithm.
Correction of some functions in order to take into consideration
multiples executions (Utils, Grid).
/**
* Set the algorithms parameters when this one is instanciated
* by a class load mechanism.
- * @param _params
- * @return
+ * @param _params The parameter(s)
+ * @return The state of setting parameter(s)
*/
- public boolean setParams( Object[] _params )
- {
- if( _params.length >= 2 )
- {
- gr = (Graph) _params[0] ;
- gl = (Grid) _params[1];
- } else {
- System.err.println( "Not enough parameters!" ) ;
- return false ;
- }
-
- return true ;
- }
+ public abstract boolean setParams( Object[] _params ) ;
/**
* Return the string identifier of the algorithm.
return null ;
}
+
+
+ @Override
+ public boolean setParams(Object[] _params) {
+ return true ;
+ }
}
return ret ;
}
+
+
+ @Override
+ public boolean setParams(Object[] _params) {
+ return true ;
+ }
}
return ret ;
}
+
+
+ @Override
+ public boolean setParams(Object[] _params) {
+ return true ;
+ }
}
/**
* Return the computational power of the computing node. It includes
- * the multiplication of cores by frequency plus a coefficient for the
- * memory.
+ * the multiplication of cores by frequency.
* @return The computational power of the computing node
*/
public int getPower()
{
- if( frequency != 0 )
+ if( mflops != 0 )
{
- return ( nb_cores * frequency ) ;
- } else {
return ( nb_cores * mflops ) ;
+ } else {
+ return ( nb_cores * frequency ) ;
}
}
private ArrayList<GTask> graph ;
private int nb_dep_total ;
+ private int maxDep ;
/**
{
graph = new ArrayList<GTask>() ;
nb_dep_total = 0 ;
+ maxDep = 0 ;
}
{
graph.add( _t.getNum(), _t ) ;
nb_dep_total += _t.getNbDep() ;
-// nb_task ++ ;
+
+ if ( _t.getNbDep() > maxDep )
+ {
+ maxDep = _t.getNbDep() ;
+ }
}
}
{
graph.add( _lt.get( i ).getNum(), _lt.get( i ) ) ;
nb_dep_total += _lt.get( i ).getNbDep() ;
+
+ if ( _lt.get( i ).getNbDep() > maxDep )
+ {
+ maxDep = _lt.get( i ).getNbDep() ;
+ }
}
}
}
{
return nb_dep_total / graph.size() ;
}
+
+
+ /**
+ * Return the max amount of dependencies a task of the graphs can have.
+ * @return The maximum amount of dependencies
+ */
+ public int getMaxDep()
+ {
+ return maxDep ;
+ }
/**
if( cluster1.compareTo( cluster2 ) == 0 )
{
- d = 1 ;
+ d = 10 ;
} else {
if( site1.compareTo( site2 ) == 0 )
{
- d = 2 ;
+ d = 20 ;
} else {
- d = 3 ;
+ d = 30 ;
}
}
return ret ;
}
+
/**
* Compute the heterogeneity degree of the grid.
* This is based on the relative standard deviation.
double average = 0 ;
double std = 0 ;
double temp = 0 ;
+ long nb_freenodes = 0 ;
/** Computation of the average power of computing nodes **/
for( int i = 0 ; i < gnodesList.size() ; i++ )
{
- temp += gnodesList.get(i).getPower() ;
+ if( ! gnodesList.get(i).getMapped() )
+ {
+ temp += gnodesList.get(i).getPower() ;
+ nb_freenodes++ ;
+ }
}
- average = temp / gnodesList.size() ;
+ average = temp / nb_freenodes ; //gnodesList.size() ;
/** Computation of the variance **/
temp = 0 ;
for( int i = 0 ; i < gnodesList.size() ; i++ )
{
- temp += Math.pow( ( gnodesList.get(i).getPower() - average ), 2 ) ;
+ if( ! gnodesList.get(i).getMapped() )
+ {
+ temp += Math.pow( ( gnodesList.get(i).getPower() - average ), 2 ) ;
+ }
}
/** Computation of the standard deviation **/
- temp = temp / gnodesList.size() ;
+ temp = temp / nb_freenodes ; //gnodesList.size() ;
std = Math.sqrt( temp ) ;
/** Computation of the relative standard deviation **/
return hd ;
}
+
+ /**
+ * Return the amount of nodes available in the cluster containing the
+ * maximum of available nodes.
+ * @return The maximum available nodes of the architecture
+ */
+ public int getMaxClusterNode()
+ {
+ int max = 0 ;
+
+ for( int i = 0 ; i < clusters.size() ; i++ )
+ {
+ if( max < clusters.get( i ).getNbFreeNodes() )
+ {
+ max = clusters.get( i ).getNbFreeNodes() ;
+ }
+ }
+
+ return max ;
+ }
+
+
/**
* Initialization of computing nodes in the grid. Set all
* of these nodes to be not mapped on, and do the same thing in each
ArrayList<Double> calcMark = new ArrayList<Double>() ;
- hd = gl.getHeterogenityDegre() ;
+ double hd_g = gl.getHeterogenityDegre() ;
+
+ /* Correction of hd */
+ hd = calcNewHd( hd_g ) ;
+
+ System.out.println("Corrected hd value: " + hd + " (" + hd_g + ")" ) ;
/** Sorting clusters **/
ArrayList<Cluster> tmp = gl.getClusters() ;
normP = tmp.get( i ).getAvgAvailablePower() * 100 / Pm ;
/** The magic formula :P **/
- calcLoc = Math.sqrt( Math.pow( (normP * hd), 2) +
- Math.pow( (normN *(1 - hd)), 2 ) ) ;
+ calcLoc = Math.pow( (normP * hd), 2) +
+ Math.pow( (normN * (1 - hd)), 2 ) ;
ok = false ;
}
+ /**
+ * Compute the new value of hd, by taking care of the application
+ * and execution architecture characteristics.
+ * @param hd_g Original heterogeneity degree
+ * @return The new (corrected) heterogeneity degree
+ */
+ private double calcNewHd( double hd_g )
+ {
+ /* Variables */
+ double nhd = 0 ;
+
+ double nbTask = gr.getNbGTask() ;
+ double nbDep = gr.getMaxDep() ;
+ double maxNodes = gl.getMaxClusterNode() ;
+
+ /* Computation */
+ nhd = hd_g / ( 10 * ( (nbDep / nbTask) + (nbDep / maxNodes) ) ) ;
+
+ return nhd ;
+ }
+
+
@Override
public GNode replaceNode( GNode _dead, ArrayList<GNode> _ag )
{
return ret ;
}
+
+
+ @Override
+ public boolean setParams(Object[] _params) {
+ return true ;
+ }
}
return null ;
}
+
+
+ @Override
+ public boolean setParams(Object[] _params) {
+ return true ;
+ }
}
e.printStackTrace();
return null ;
} catch( ClassCastException e ) {
- System.err.println( "The file does not contain a valid Grid" ) ;
+ System.err.println( "The file does not contain a valid Mapping" ) ;
e.printStackTrace() ;
return null ;
}