Skip to content

Instantly share code, notes, and snippets.

@ben-albrecht
Created May 23, 2018 18:04
Show Gist options
  • Save ben-albrecht/57dcee924fe469d1bf9ce6b3b842b858 to your computer and use it in GitHub Desktop.
Save ben-albrecht/57dcee924fe469d1bf9ce6b3b842b858 to your computer and use it in GitHub Desktop.
use Time;
use LinearAlgebra.Sparse;
use MatrixUtils;
var t: Timer;
//
t.start();
write('Reading and creating A: ');
stdout.flush();
var r = openreader('rep.txt');
var spsD = csrDomain(r);
r.close();
var A: [spsD] real = 1.0;
writeln(t.elapsed());
t.clear();
//
write('A.dot(A): ');
stdout.flush();
A.dot(A);
writeln(t.elapsed());
t.clear();
//
write('transpose(A): ');
stdout.flush();
var AT = transpose(A);
writeln(t.elapsed());
t.clear();
//
write('AT.dot(AT): ');
stdout.flush();
AT.dot(AT);
writeln(t.elapsed());
t.clear();
use IO;
use LayoutCS;
proc csrDomain(handle: channel) {
var rows: int, cols: int, nnz: int;
handle.read(rows);
handle.read(cols);
handle.read(nnz);
var indices: [1..nnz] (int, int);
for ind in indices {
handle.readf("%i,%i", ind[1], ind[2]);
}
var D = {1..rows, 1..cols};
var spsD: sparse subdomain(D) dmapped CS();
spsD.bulkAdd(indices);
return spsD;
}
2553515
2553515
3300832
i, j
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment