1 29 package org.objectweb.proactive.examples.matrix; 30 31 import org.apache.log4j.Logger; 32 import org.objectweb.proactive.core.node.Node; 33 import org.objectweb.proactive.core.node.NodeException; 34 import org.objectweb.proactive.core.node.NodeFactory; 35 36 37 public class Launcher implements java.io.Serializable { 38 39 static Logger logger = Logger.getLogger(Launcher.class.getName()); 40 41 Node[] nodesList; 42 43 public Launcher () {} 44 45 public Launcher (String [] nodesNameList) throws NodeException { 46 nodesList = new Node[nodesNameList.length]; 47 for (int i=0; i<nodesNameList.length; i++) { 48 nodesList[i] = NodeFactory.getNode(nodesNameList[i]); 49 } 50 } 51 52 53 public void start(Matrix m1, Matrix m2, int i) { 55 57 int matrixSize=m1.getWidth(); 58 59 60 long startTime; 61 long endTime; 62 63 startTime = System.currentTimeMillis(); 64 65 Matrix groupResult =multiply(m1,m2); 67 68 71 72 74 try { 76 Matrix result = reconstruction(groupResult,matrixSize); } 77 catch (Exception e) {} 78 79 80 endTime = System.currentTimeMillis() - startTime; 81 logger.info("\n Result (" +i+ ") : Total time spent = " + endTime + " millisecondes"); 82 83 } 85 86 87 public Matrix createMatrix(int size) { 88 Matrix m = new Matrix(size,size); 89 m.initializeWithRandomValues(); 90 return m; 91 } 92 93 94 public Matrix distribute (Matrix m) { 95 Matrix verticalSubMatrixGroup = null; 96 verticalSubMatrixGroup = m.transformIntoActiveVerticalSubMatrixGroup(nodesList); 97 98 return verticalSubMatrixGroup; 99 } 100 101 102 public Matrix multiply (Matrix m, Matrix group) { 103 Matrix ma = group.localMultiplyForGroup(m); 104 return ma; 105 } 106 107 108 public Matrix reconstruction (Matrix group, int size) { 109 Matrix result = null; 110 111 result = new Matrix(group,size); 112 113 return result; 114 } 115 116 117 public String getString(Matrix m) { 118 return m.toString(); 119 } 120 121 } 122 | Popular Tags |