org/objectweb/proactive/ext/scilab/test/SciTestParMult.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.ext.scilab.test;
00032 
00033 import java.io.BufferedReader;
00034 import java.io.BufferedWriter;
00035 import java.io.FileReader;
00036 import java.io.FileWriter;
00037 import java.io.PrintWriter;
00038 
00039 import org.objectweb.proactive.ext.scilab.monitor.ScilabService;
00040 import org.objectweb.proactive.ext.scilab.util.FutureDoubleMatrix;
00041 import org.objectweb.proactive.ext.scilab.util.GridMatrix;
00042 
00043 
00044 public class SciTestParMult {
00045     public SciTestParMult() {
00046     }
00047 
00048     public static void main(String[] args) throws Exception {
00049         ScilabService service = new ScilabService();
00050 
00051         if (args.length != 5) {
00052             System.out.println("Invalid number of parameter : " + args.length);
00053             return;
00054         }
00055 
00056         int nbEngine = Integer.parseInt(args[2]);
00057         service.deployEngine(args[0], args[1], nbEngine);
00058         BufferedReader reader = new BufferedReader(new FileReader(args[3]));
00059         PrintWriter writer = new PrintWriter(new BufferedWriter(
00060                     new FileWriter(args[4])));
00061 
00062         int nbRow;
00063         int nbCol;
00064 
00065         double[] m1;
00066         double[] m2;
00067         double[] m3;
00068         FutureDoubleMatrix result;
00069 
00070         double startTime;
00071         double endTime;
00072         String line;
00073 
00074         for (int i = 0; (line = reader.readLine()) != null; i++) {
00075             if (line.trim().startsWith("#")) {
00076                 continue;
00077             }
00078 
00079             if (line.trim().equals("")) {
00080                 break;
00081             }
00082 
00083             nbRow = Integer.parseInt(line);
00084             nbCol = Integer.parseInt(line);
00085             System.out.println(nbEngine + "  size=" + nbRow );
00086             m1 = new double[nbRow * nbCol];
00087             m2 = new double[nbRow * nbCol];
00088             for (int k = 0; k < (nbRow * nbCol); k++) {
00089                 m1[k] = Math.random() * 10.0; 
00090                 m2[k] = Math.random() * 10.0;
00091             }
00092 
00093             startTime = System.currentTimeMillis();
00094             result = GridMatrix.mult(service, "mult" + i, m1, nbRow, nbCol, m2, nbRow, nbCol);
00095             m3 = result.get();
00096 
00097             endTime = System.currentTimeMillis();
00098             System.out.println(endTime - startTime);
00099 
00100            /* System.out.println(" ");
00101             for (int k = 0; k < nbRow; k++) {
00102                 for (int j = 0; j < nbCol; j++) {
00103                     System.out.print(m3[(k * nbCol) + j] + " ");
00104                 }
00105                 System.out.println(" ");
00106             }*/
00107             
00108             writer.println(nbEngine + " " + nbRow + (endTime - startTime));
00109         }
00110         
00111         reader.close();
00112                 writer.close();
00113         service.exit();
00114         System.exit(0);
00115     }
00116 }

Generated on Mon Jan 22 15:16:10 2007 for ProActive by  doxygen 1.5.1