From 04237b062ba76603c6be49d9ba84121691aa4009 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Miqu=C3=A9e?= Date: Tue, 25 Jan 2011 11:44:54 +0100 Subject: [PATCH] Adding new functionalities. 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 | 18 ++---------- src/and/Mapping/DefaultMapping.java | 6 ++++ src/and/Mapping/FT_AIAC_QM.java | 6 ++++ src/and/Mapping/FT_FEC.java | 6 ++++ src/and/Mapping/GNode.java | 9 +++--- src/and/Mapping/Graph.java | 23 ++++++++++++++- src/and/Mapping/Grid.java | 45 ++++++++++++++++++++++++----- src/and/Mapping/Maheve.java | 39 +++++++++++++++++++++++-- src/and/Mapping/Simple.java | 6 ++++ src/and/Mapping/Utils.java | 2 +- 10 files changed, 128 insertions(+), 32 deletions(-) diff --git a/src/and/Mapping/Algo.java b/src/and/Mapping/Algo.java index ab4a895..f1974a0 100644 --- a/src/and/Mapping/Algo.java +++ b/src/and/Mapping/Algo.java @@ -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. diff --git a/src/and/Mapping/DefaultMapping.java b/src/and/Mapping/DefaultMapping.java index 3de90b1..f322659 100644 --- a/src/and/Mapping/DefaultMapping.java +++ b/src/and/Mapping/DefaultMapping.java @@ -110,6 +110,12 @@ public class DefaultMapping extends Algo return null ; } + + + @Override + public boolean setParams(Object[] _params) { + return true ; + } } diff --git a/src/and/Mapping/FT_AIAC_QM.java b/src/and/Mapping/FT_AIAC_QM.java index a7e87c6..d0a2861 100644 --- a/src/and/Mapping/FT_AIAC_QM.java +++ b/src/and/Mapping/FT_AIAC_QM.java @@ -612,6 +612,12 @@ public class FT_AIAC_QM extends Algo return ret ; } + + + @Override + public boolean setParams(Object[] _params) { + return true ; + } } diff --git a/src/and/Mapping/FT_FEC.java b/src/and/Mapping/FT_FEC.java index 28f78f8..b9e216a 100644 --- a/src/and/Mapping/FT_FEC.java +++ b/src/and/Mapping/FT_FEC.java @@ -515,6 +515,12 @@ public class FT_FEC extends Algo return ret ; } + + + @Override + public boolean setParams(Object[] _params) { + return true ; + } } diff --git a/src/and/Mapping/GNode.java b/src/and/Mapping/GNode.java index e7d5f94..3e79f03 100644 --- a/src/and/Mapping/GNode.java +++ b/src/and/Mapping/GNode.java @@ -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 ) ; } } diff --git a/src/and/Mapping/Graph.java b/src/and/Mapping/Graph.java index 8f255cd..e9ac2a2 100644 --- a/src/and/Mapping/Graph.java +++ b/src/and/Mapping/Graph.java @@ -18,6 +18,7 @@ public class Graph implements Serializable private ArrayList graph ; private int nb_dep_total ; + private int maxDep ; /** @@ -27,6 +28,7 @@ public class Graph implements Serializable { graph = new ArrayList() ; 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 ; + } /** diff --git a/src/and/Mapping/Grid.java b/src/and/Mapping/Grid.java index 57345cd..2451b95 100644 --- a/src/and/Mapping/Grid.java +++ b/src/and/Mapping/Grid.java @@ -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 diff --git a/src/and/Mapping/Maheve.java b/src/and/Mapping/Maheve.java index c22bfc9..f38b9fc 100644 --- a/src/and/Mapping/Maheve.java +++ b/src/and/Mapping/Maheve.java @@ -374,7 +374,12 @@ public class Maheve extends Algo ArrayList calcMark = new ArrayList() ; - 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 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 _ag ) { @@ -506,6 +533,12 @@ public class Maheve extends Algo return ret ; } + + + @Override + public boolean setParams(Object[] _params) { + return true ; + } } diff --git a/src/and/Mapping/Simple.java b/src/and/Mapping/Simple.java index 403b008..b6c19a9 100644 --- a/src/and/Mapping/Simple.java +++ b/src/and/Mapping/Simple.java @@ -163,6 +163,12 @@ public class Simple extends Algo return null ; } + + + @Override + public boolean setParams(Object[] _params) { + return true ; + } } diff --git a/src/and/Mapping/Utils.java b/src/and/Mapping/Utils.java index 068789d..bef5dd4 100644 --- a/src/and/Mapping/Utils.java +++ b/src/and/Mapping/Utils.java @@ -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 ; } -- 2.20.1