Skip to content

Commit

Permalink
fix amd and symrcm
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahdhn committed Sep 16, 2024
1 parent 6b7b075 commit 41cee4d
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions apps/NDReorder/test_all_permutations.cu
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ void no_permute(rxmesh::RXMeshStatic& rx, const EigeMatT& eigen_mat)
RXMESH_INFO(" No-permutation NNZ = {}", nnz);
}

template <typename T>
std::vector<T> inverse_permutation(const std::vector<T>& perm)
{
std::vector<int> perm_inv(perm.size());

for (int i = 0; i < perm_inv.size(); ++i) {
perm_inv[perm[i]] = i;
}

return perm_inv;
}


template <typename T, typename EigeMatT>
void with_metis(rxmesh::RXMeshStatic& rx,
const rxmesh::SparseMatrix<T>& rx_mat,
Expand Down Expand Up @@ -187,9 +200,16 @@ void with_amd(rxmesh::RXMeshStatic& rx,
rx_mat.get_h_permute(),
h_permute.size() * sizeof(int));

// render_permutation(rx, h_permute, "AMD");

int nnz = count_nnz_fillin(eigen_mat, h_permute, "amd");
std::vector<int> h_permute_inv = inverse_permutation(h_permute);


EXPECT_TRUE(rxmesh::is_unique_permutation(h_permute_inv.size(),
h_permute_inv.data()));

// render_permutation(rx, h_permute_inv, "AMD");

int nnz = count_nnz_fillin(eigen_mat, h_permute_inv, "amd");

RXMESH_INFO(" With AMD NNZ = {}", nnz);
}
Expand All @@ -210,9 +230,14 @@ void with_symrcm(rxmesh::RXMeshStatic& rx,
rx_mat.get_h_permute(),
h_permute.size() * sizeof(int));

// render_permutation(rx, h_permute, "symrcm");
EXPECT_TRUE(
rxmesh::is_unique_permutation(h_permute.size(), h_permute.data()));

std::vector<int> h_permute_inv = inverse_permutation(h_permute);

// render_permutation(rx, h_permute_inv, "symrcm");

int nnz = count_nnz_fillin(eigen_mat, h_permute, "symrcm");
int nnz = count_nnz_fillin(eigen_mat, h_permute_inv, "symrcm");

RXMESH_INFO(" With SYMRCM NNZ = {}", nnz);
}
Expand Down

0 comments on commit 41cee4d

Please sign in to comment.