COSTA: COSt and Termination Analyzer for Java Bytecode
    
    package x10;


public class Gaussian {

    static int A[][];

    public static void gaussian_elimination(int n) {
	for (int k=0; k<n; k++) {
	    
	    Conc.finish_begin();
	    m_loop1(n,k);
	    Conc.finish_end();

	    Conc.finish_begin();
	    m_loop2(n,k);
	    Conc.finish_end();
	    
	}
    }

    // the content of the first finish call
    public static void m_loop1(int n, int k) {
	for (int j=k+1; j<n; j++) {
	    Conc.async_begin();
	    m_1(k,j);
	    Conc.async_end();
	}
    }

    // the body of the first inner loop
    public static void m_1(int k, int j) {
	A[k][j] = A[k][j]/A[k][k];
    }


    // the content of the second finish call
    public static void m_loop2(int n, int k) {
	for (int i=k+1; i<n; i++) {
	    Conc.async_begin();
	    m_2(i,k,n);
	    Conc.async_end();
	}
    }

    // the body of the second inner loop
    public static void m_2(int i, int k, int n) {
	for (int j=k+1; j<n; j++) {
	    A[i][j] = A[i][j] - A[i][k]*A[k][j];
	}
    }


    public static void main(String args[]) {
	gaussian_elimination(args.length);
    }

}