Skip to content

Commit

Permalink
Different syntactically equivalent idioms for row/column add/swap of …
Browse files Browse the repository at this point in the history
…matrices for distributed and shared memory execution of homology computation.
  • Loading branch information
jesunsahariar committed Oct 5, 2020
1 parent 0be9d39 commit a11f7de
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions example/homology_experimental/betti_number_calculator_parallel_bool.chpl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,15 @@ forall (_kCellsArray, kCellKey) in zip(kCellsArrayMap, kCellKeys) {
sort(_kCellsArray.A, comparator=absComparator);
}


config param useLocalArray = (CHPL_COMM == "none");
/*Start of the construction of boundary matrices.*/
class Matrix {
var N : int;
var M : int;
var D = {1..N, 1..M} dmapped Block(boundingBox = {1..N, 1..M});
const D = if useLocalArray then {1..N, 1..M}
else {1..N, 1..M} dmapped Block(boundingBox = {1..N, 1..M});
// var D = {1..N, 1..M} dmapped Block(boundingBox = {1..N, 1..M});
var matrix : [D] bool;
proc init(_N: int, _M:int) {
N = _N;
Expand Down Expand Up @@ -489,27 +493,41 @@ proc _get_next_pivot(M, s1, in s2 : int = -1) {

proc swap_rows(i, j, M) {
var N = M;
N[i, ..] <=> N[j, ..];
// N[i, ..] <=> N[j, ..];
N[i..i, ..] <=> N[j..j, ..];
/* forall k in N.domain.dim(2) do */
/* N[i, k] <=> N[j, k]; */
return N;
}

proc swap_columns(i, j, M) {
var N = M;
N[.., i] <=> N[.., j];
// N[.., i] <=> N[.., j];
N[.., i..i] <=> N[.., j..j];
/* forall k in N.domain.dim(1) do */
/* N[k, i] <=> N[k, j]; */
return N;
}

// Replaces row i (of M) with sum ri multiple of ith row and rj multiple of jth row
proc add_to_row(M, i, j, mod = 2) {
var N = M;
N[i, ..] = (N[i, ..] ^ N[j, ..]);
// N[i, ..] = (N[i, ..] ^ N[j, ..]);
// N[i, ..] ^= N[j, ..];
/* forall k in N.domain.dim(2) do */
/* N[i, k] ^= N[j, k]; */
N[i..i, ..] ^= N[j..j, ..];
return N;
}


proc add_to_column(M, i, j, mod = 2) {
var N = M;
N[.., i] = (N[.., i] ^ N[..,j]);
// N[.., i] = (N[.., i] ^ N[..,j]);
// N[.., i] ^= N[..,j];
/* forall k in N.domain.dim(1) do */
/* N[k, i] ^= N[k, j]; */
N[.., i..i] ^= N[..,j..j];
return N;
}

Expand Down

0 comments on commit a11f7de

Please sign in to comment.