= 1) { + for (k = 0; k < nm1; k++) { + l = ipvt[k]; + t = b[l]; + if (l != k){ + b[l] = b[k]; + b[k] = t; + } + kp1 = k + 1; + daxpy(n-(kp1),t,a[k],kp1,1,b,kp1,1); + } + } + + // now solve u*x = y + + for (kb = 0; kb < n; kb++) { + k = n - (kb + 1); + b[k] /= a[k][k]; + t = -b[k]; + daxpy(k,t,a[k],0,1,b,0,1); + } + } + else { + + // job = nonzero, solve trans(a) * x = b. first solve trans(u)*y = b + + for (k = 0; k < n; k++) { + t = ddot(k,a[k],0,1,b,0,1); + b[k] = (b[k] - t)/a[k][k]; + } + + // now solve trans(l)*x = y + + if (nm1 >= 1) { + for (kb = 1; kb < nm1; kb++) { + k = n - (kb+1); + kp1 = k + 1; + b[k] += ddot(n-(kp1),a[k],kp1,1,b,kp1,1); + l = ipvt[k]; + if (l != k) { + t = b[l]; + b[l] = b[k]; + b[k] = t; + } + } + } + } + } + + + + /* + constant times a vector plus a vector. + jack dongarra, linpack, 3/11/78. + */ + final void daxpy( int n, double da, double dx[], int dx_off, int incx, + double dy[], int dy_off, int incy) + { + int i,ix,iy; + + if ((n > 0) && (da != 0)) { + if (incx != 1 || incy != 1) { + + // code for unequal increments or equal increments not equal to 1 + + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dy[iy +dy_off] += da*dx[ix +dx_off]; + ix += incx; + iy += incy; + } + return; + } else { + + // code for both increments equal to 1 + + for (i=0; i < n; i++) + dy[i +dy_off] += da*dx[i +dx_off]; + } + } + } + + + + /* + forms the dot product of two vectors. + jack dongarra, linpack, 3/11/78. + */ + final double ddot( int n, double dx[], int dx_off, int incx, double dy[], + int dy_off, int incy) + { + double dtemp; + int i,ix,iy; + + dtemp = 0; + + if (n > 0) { + + if (incx != 1 || incy != 1) { + + // code for unequal increments or equal increments not equal to 1 + + ix = 0; + iy = 0; + if (incx < 0) ix = (-n+1)*incx; + if (incy < 0) iy = (-n+1)*incy; + for (i = 0;i < n; i++) { + dtemp += dx[ix +dx_off]*dy[iy +dy_off]; + ix += incx; + iy += incy; + } + } else { + + // code for both increments equal to 1 + + for (i=0;i < n; i++) + dtemp += dx[i +dx_off]*dy[i +dy_off]; + } + } + return(dtemp); + } + + + + /* + scales a vector by a constant. + jack dongarra, linpack, 3/11/78. + */ + final void dscal( int n, double da, double dx[], int dx_off, int incx) + { + int i,nincx; + + if (n > 0) { + if (incx != 1) { + + // code for increment not equal to 1 + + nincx = n*incx; + for (i = 0; i < nincx; i += incx) + dx[i +dx_off] *= da; + } else { + + // code for increment equal to 1 + + for (i = 0; i < n; i++) + dx[i +dx_off] *= da; + } + } + } + + + + /* + finds the index of element having max. absolute value. + jack dongarra, linpack, 3/11/78. + */ + final int idamax( int n, double dx[], int dx_off, int incx) + { + double dmax, dtemp; + int i, ix, itemp=0; + + if (n < 1) { + itemp = -1; + } else if (n ==1) { + itemp = 0; + } else if (incx != 1) { + + // code for increment not equal to 1 + + dmax = abs(dx[0 +dx_off]); + ix = 1 + incx; + for (i = 1; i < n; i++) { + dtemp = abs(dx[ix + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + ix += incx; + } + } else { + + // code for increment equal to 1 + + itemp = 0; + dmax = abs(dx[0 +dx_off]); + for (i = 1; i < n; i++) { + dtemp = abs(dx[i + dx_off]); + if (dtemp > dmax) { + itemp = i; + dmax = dtemp; + } + } + } + return (itemp); + } + + + + /* + estimate unit roundoff in quantities of size x. + + this program should function properly on all systems + satisfying the following two assumptions, + 1. the base used in representing dfloating point + numbers is not a power of three. + 2. the quantity a in statement 10 is represented to + the accuracy used in dfloating point variables + that are stored in memory. + the statement number 10 and the go to 10 are intended to + force optimizing compilers to generate code satisfying + assumption 2. + under these assumptions, it should be true that, + a is not exactly equal to four-thirds, + b has a zero for its last bit or digit, + c is not exactly equal to one, + eps measures the separation of 1.0 from + the next larger dfloating point number. + the developers of eispack would appreciate being informed + about any systems where these assumptions do not hold. + + ***************************************************************** + this routine is one of the auxiliary routines used by eispack iii + to avoid machine dependencies. + ***************************************************************** + + this version dated 4/6/83. + */ + final double epslon (double x) + { + double a,b,c,eps; + + a = 4.0e0/3.0e0; + eps = 0; + while (eps == 0) { + b = a - 1.0; + c = b + b + b; + eps = abs(c-1.0); + } + return(eps*abs(x)); + } + + + + /* + purpose: + multiply matrix m times vector x and add the result to vector y. + + parameters: + + n1 integer, number of elements in vector y, and number of rows in + matrix m + + y double [n1], vector of length n1 to which is added + the product m*x + + n2 integer, number of elements in vector x, and number of columns + in matrix m + + ldm integer, leading dimension of array m + + x double [n2], vector of length n2 + + m double [ldm][n2], matrix of n1 rows and n2 columns + */ + final void dmxpy ( int n1, double y[], int n2, int ldm, double x[], double m[][]) + { + int j,i; + + // cleanup odd vector + for (j = 0; j < n2; j++) { + for (i = 0; i < n1; i++) { + y[i] += x[j]*m[j][i]; + } + } + } + +} diff --git a/src/and/Mapping/Utils.java b/src/and/Mapping/Utils.java index 2127186..57a87e2 100644 --- a/src/and/Mapping/Utils.java +++ b/src/and/Mapping/Utils.java @@ -1,6 +1,5 @@ package and.Mapping ; - import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -9,11 +8,6 @@ import java.io.PrintWriter; import java.net.InetAddress; import java.util.ArrayList; -import org.hyperic.sigar.CpuInfo; -import org.hyperic.sigar.Mem; -import org.hyperic.sigar.Sigar; -import org.hyperic.sigar.SigarException; - import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; @@ -25,12 +19,6 @@ import com.thoughtworks.xstream.io.xml.DomDriver; */ public class Utils { -// public static String getOS() -// { -// return System.getProperty( "os.name" ) ; -// } - - /** * Creation of the representation of the node in the Mapping point of view. It needs * some information about the computing node, which will be exploited by mapping @@ -39,126 +27,37 @@ public class Utils */ public static GNode createGNode() { + /** Using the Linpack class **/ + Linpack linpack = new Linpack() ; + + /** **/ GNode n = new GNode() ; int nbCore = 0 ; int frequency = 0 ; + int mflops = 0 ; int memory = 0 ; String name = "" ; -// InputStream ips ; -// InputStreamReader ipsr ; -// BufferedReader br ; -// String ligne ; -// -// -// String fichier_cpu = "" ; -// String fichier_mem = "" ; -// -// -// if( getOS().equals( "Linux" ) ) -// { -// fichier_cpu = "/proc/cpuinfo" ; -// fichier_mem = "/proc/meminfo" ; -// -// /* Lecture des informations processeur */ -// try{ -// ips = new FileInputStream( fichier_cpu ) ; -// ipsr = new InputStreamReader( ips ) ; -// br = new BufferedReader( ipsr ) ; -// -// -// while( ( ligne = br.readLine() ) != null ) -// { -// if( ligne.contains( "processor" ) ) -// { -// nb_coeurs ++ ; -// } -// -// if( ligne.contains("cpu MHz") ) -// { -// String tab[] = new String[2] ; -// -// tab = ligne.split( ":" ) ; -// -// frequence = ( int ) Double.parseDouble( tab[1] ) ; -// } -// -// } -// -// br.close() ; -// ipsr.close() ; -// ips.close() ; -// -// } catch( Exception e ) { -// System.out.println( e.toString() ) ; -// } -// -// -// /* Lecture des informations mÃ©moire */ -// try { -// ips = new FileInputStream( fichier_mem ) ; -// ipsr = new InputStreamReader( ips ) ; -// br = new BufferedReader( ipsr ) ; -// -// while( ( ligne = br.readLine() ) != null ) -// { -// if( ligne.contains("MemTotal") ) -// { -// String tab[] = new String[2] ; -// -// tab = ligne.split( ":" ) ; -// ligne = tab[1].trim() ; -// tab = ligne.split( " " ) ; -// memoire = ( int ) Double.parseDouble( tab[0] ) ; -// } -// -// } -// -// br.close() ; -// ipsr.close() ; -// ips.close() ; -// -// } catch( Exception e ) { -// System.out.println( e.toString() ) ; -// } -// -// } - /* Creating the hardware information retriever */ - Sigar sigar = new Sigar() ; + /** CPU information **/ - /* CPU information */ - CpuInfo cpuinfo[] = null ; - try { - cpuinfo = sigar.getCpuInfoList(); - } catch (SigarException e) { - System.err.println( "Unable to retrieve CPU information !" ) ; - e.printStackTrace(); - System.exit( 1 ) ; - } + /* Amount of available computing cores */ + nbCore = Runtime.getRuntime().availableProcessors() ; + + /* Average MegaFlops of each core */ + double tmp_mflops = 0 ; + int loop = 10 ; - int tmp = 0 ; - for( int i = 0 ; i < cpuinfo.length ; i++ ) + for( int i = 0 ; i < loop ; i++ ) { - nbCore++ ; - tmp+= cpuinfo[i].getMhz() ; + tmp_mflops += linpack.getMFlops() ; + System.gc() ; } + mflops = (int) tmp_mflops / loop ; - /* The frequency is the average of cores frequencies */ - frequency = tmp / nbCore ; - - - /* Memory information */ - Mem mem = null ; - try { - mem = sigar.getMem() ; - } catch (SigarException e) { - System.err.println( "Unable to retrieve memory information !" ) ; - e.printStackTrace(); - System.exit( 1 ) ; - } - memory = (int)mem.getFree()/1000 ; + /** Memory information **/ + memory = (int) Runtime.getRuntime().maxMemory() / 1024 / 1024 ; /* Host name */ @@ -174,6 +73,7 @@ public class Utils /* Updating node information */ n.setFrequency( frequency ) ; + n.setMFlops( mflops ) ; n.setMemory( memory ) ; n.setNb_cores( nbCore ) ; n.setName( name ) ;