Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding new functionalities.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Tue, 25 Jan 2011 10:44:54 +0000 (11:44 +0100)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Tue, 25 Jan 2011 10:44:54 +0000 (11:44 +0100)
Adding new functionalities to improve the Maheve algorithm.
Correction of some functions in order to take into consideration
multiples executions (Utils, Grid).

src/and/Mapping/Algo.java
src/and/Mapping/DefaultMapping.java
src/and/Mapping/FT_AIAC_QM.java
src/and/Mapping/FT_FEC.java
src/and/Mapping/GNode.java
src/and/Mapping/Graph.java
src/and/Mapping/Grid.java
src/and/Mapping/Maheve.java
src/and/Mapping/Simple.java
src/and/Mapping/Utils.java

index ab4a895..f1974a0 100644 (file)
@@ -121,22 +121,10 @@ public abstract class Algo implements Serializable
        /**
         * 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.
index 3de90b1..f322659 100644 (file)
@@ -110,6 +110,12 @@ public class DefaultMapping extends Algo
                
                return null ;
        }
+
+
+       @Override
+       public boolean setParams(Object[] _params) {
+               return true ;
+       }
 }
 
 
index a7e87c6..d0a2861 100644 (file)
@@ -612,6 +612,12 @@ public class FT_AIAC_QM extends Algo
                
                return ret ;
        }
+
+
+       @Override
+       public boolean setParams(Object[] _params) {
+               return true ;
+       }
 }
 
 
index 28f78f8..b9e216a 100644 (file)
@@ -515,6 +515,12 @@ public class FT_FEC extends Algo
                                
                return ret ;
        }
+
+
+       @Override
+       public boolean setParams(Object[] _params) {
+               return true ;
+       }
        
 }
 
index e7d5f94..3e79f03 100644 (file)
@@ -250,17 +250,16 @@ public class GNode implements Serializable
 
        /**
         * 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 ) ;
                }
        }
        
index 8f255cd..e9ac2a2 100644 (file)
@@ -18,6 +18,7 @@ public class Graph implements Serializable
        
        private ArrayList<GTask> graph ;
        private int nb_dep_total ;
+       private int maxDep ;
        
        
        /**
@@ -27,6 +28,7 @@ public class Graph implements Serializable
        {
                graph = new ArrayList<GTask>() ;
                nb_dep_total = 0 ;
+               maxDep = 0 ;
        }
        
        
@@ -50,7 +52,11 @@ public class Graph implements Serializable
                {
                        graph.add( _t.getNum(), _t ) ;
                        nb_dep_total += _t.getNbDep() ;
-//                     nb_task ++ ;
+                       
+                       if ( _t.getNbDep() > maxDep )
+                       {
+                               maxDep = _t.getNbDep() ;
+                       }
                }
        }
        
@@ -67,6 +73,11 @@ public class Graph implements Serializable
                        {
                                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() ;
+                               }
                        }
                }
        }
@@ -90,6 +101,16 @@ public class Graph implements Serializable
        {
                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 ;
+       }
 
 
        /**
index 57345cd..2451b95 100644 (file)
@@ -136,13 +136,13 @@ public class Grid implements Serializable
                
                if( cluster1.compareTo( cluster2 ) == 0 )
                {
-                       d = 1 ;
+                       d = 10 ;
                } else {
                        if( site1.compareTo( site2 ) == 0 )
                        {
-                               d = 2 ;
+                               d = 20 ;
                        } else {
-                               d = 3 ;
+                               d = 30 ;
                        }
                }
                
@@ -407,6 +407,7 @@ public class Grid implements Serializable
                return ret ;
        }
        
+       
        /**
         * Compute the heterogeneity degree of the grid.
         * This is based on the relative standard deviation.
@@ -426,24 +427,32 @@ public class Grid implements Serializable
                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 **/
@@ -459,6 +468,28 @@ public class Grid implements Serializable
                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
index c22bfc9..f38b9fc 100644 (file)
@@ -374,7 +374,12 @@ public class Maheve extends Algo
                        
                        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() ;
@@ -399,8 +404,8 @@ public class Maheve extends Algo
                                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 ;
                                
@@ -432,6 +437,28 @@ public class Maheve extends Algo
        }
 
 
+       /**
+        * 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 ) 
        {
@@ -506,6 +533,12 @@ public class Maheve extends Algo
                
                return ret ;
        }
+
+
+       @Override
+       public boolean setParams(Object[] _params) {
+               return true ;
+       }
        
 }
 
index 403b008..b6c19a9 100644 (file)
@@ -163,6 +163,12 @@ public class Simple extends Algo
                
                return null ;
        }
+
+
+       @Override
+       public boolean setParams(Object[] _params) {
+               return true ;
+       }
 }
 
 
index 068789d..bef5dd4 100644 (file)
@@ -480,7 +480,7 @@ public class Utils
                        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 ;
                }