Skip to content

Commit

Permalink
adding amd and symrcm to the mix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahdhn committed Sep 16, 2024
1 parent 3a64de4 commit 6b7b075
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 19 deletions.
14 changes: 7 additions & 7 deletions apps/MCF/benchmark.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ set input_dir4=C:\Github\RXMesh\input\SI


rem Flag to indicate whether to start processing files
set start_processing=1
set start_processing=0

rem Define the file name to start processing from
rem set start_file=C:\Github\RXMesh\input\SI\usnm_1149322-20m.obj
set start_file=C:\Github\RXMesh\input\SI\bell_x1-complete_with_vane-smooth.obj

rem Loop over each directory
for %%d in (%input_dir4%) do (
for %%d in (%input_dir4% %input_dir1% %input_dir2% %input_dir3%) do (
for %%f in (%%d\*.obj) do (
echo %%f
if not "!start_processing!"=="1" (
rem if "%%f"=="%start_file%" (
rem set start_processing=1
rem echo !start_processing!
rem )
if "%%f"=="%start_file%" (
set start_processing=1
echo !start_processing!
)
) else (
if exist "%%f" (
echo %exe% -input "%%f" -device_id %device_id% -perm_method symamd
Expand Down
74 changes: 62 additions & 12 deletions apps/NDReorder/test_all_permutations.cu
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void no_permute(rxmesh::RXMeshStatic& rx, const EigeMatT& eigen_mat)

fill_with_sequential_numbers(h_permute.data(), h_permute.size());

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

int nnz = count_nnz_fillin(eigen_mat, h_permute, "natural");

Expand Down Expand Up @@ -130,15 +130,15 @@ void with_metis(rxmesh::RXMeshStatic& rx,
EXPECT_TRUE(
rxmesh::is_unique_permutation(h_permute.size(), h_permute.data()));

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

int nnz = count_nnz_fillin(eigen_mat, h_iperm, "metis");

RXMESH_INFO(" With METIS Nested Dissection NNZ = {}", nnz);
}

template <typename EigeMatT>
void with_mgnd(rxmesh::RXMeshStatic& rx, const EigeMatT& eigen_mat)
void with_gpumgnd(rxmesh::RXMeshStatic& rx, const EigeMatT& eigen_mat)
{
std::vector<int> h_permute(eigen_mat.rows());

Expand All @@ -147,15 +147,15 @@ void with_mgnd(rxmesh::RXMeshStatic& rx, const EigeMatT& eigen_mat)
EXPECT_TRUE(
rxmesh::is_unique_permutation(h_permute.size(), h_permute.data()));

//render_permutation(rx, h_permute, "MGND");
// render_permutation(rx, h_permute, "GPUMGND");

int nnz = count_nnz_fillin(eigen_mat, h_permute, "mgnd");
int nnz = count_nnz_fillin(eigen_mat, h_permute, "gpumgnd");

RXMESH_INFO(" With MGND NNZ = {}", nnz);
RXMESH_INFO(" With GPUMGND NNZ = {}", nnz);
}

template <typename EigeMatT>
void with_cuda_nd(rxmesh::RXMeshStatic& rx, const EigeMatT& eigen_mat)
void with_gpu_nd(rxmesh::RXMeshStatic& rx, const EigeMatT& eigen_mat)
{
std::vector<int> h_permute(eigen_mat.rows());

Expand All @@ -164,11 +164,57 @@ void with_cuda_nd(rxmesh::RXMeshStatic& rx, const EigeMatT& eigen_mat)
EXPECT_TRUE(
rxmesh::is_unique_permutation(h_permute.size(), h_permute.data()));

//render_permutation(rx, h_permute, "CUDA_ND");
// render_permutation(rx, h_permute, "GPUND");

int nnz = count_nnz_fillin(eigen_mat, h_permute, "cuda_nd");
int nnz = count_nnz_fillin(eigen_mat, h_permute, "gpund");

RXMESH_INFO(" With CUDA ND NNZ = {}", nnz);
RXMESH_INFO(" With GPUND NNZ = {}", nnz);
}

template <typename T, typename EigeMatT>
void with_amd(rxmesh::RXMeshStatic& rx,
rxmesh::SparseMatrix<T>& rx_mat,
const EigeMatT& eigen_mat)
{
std::vector<int> h_permute(eigen_mat.rows());

rx_mat.permute_alloc(rxmesh::PermuteMethod::SYMAMD);
rx_mat.permute(rx, rxmesh::PermuteMethod::SYMAMD);

const int* h_perm = rx_mat.get_h_permute();

std::memcpy(h_permute.data(),
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");

RXMESH_INFO(" With AMD NNZ = {}", nnz);
}

template <typename T, typename EigeMatT>
void with_symrcm(rxmesh::RXMeshStatic& rx,
rxmesh::SparseMatrix<T>& rx_mat,
const EigeMatT& eigen_mat)
{
std::vector<int> h_permute(eigen_mat.rows());

rx_mat.permute_alloc(rxmesh::PermuteMethod::SYMRCM);
rx_mat.permute(rx, rxmesh::PermuteMethod::SYMRCM);

const int* h_perm = rx_mat.get_h_permute();

std::memcpy(h_permute.data(),
rx_mat.get_h_permute(),
h_permute.size() * sizeof(int));

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

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

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

TEST(Apps, NDReorder)
Expand Down Expand Up @@ -207,11 +253,15 @@ TEST(Apps, NDReorder)

no_permute(rx, eigen_mat);

with_amd(rx, rx_mat, eigen_mat);

with_symrcm(rx, rx_mat, eigen_mat);

with_metis(rx, rx_mat, eigen_mat);

with_mgnd(rx, eigen_mat);
with_gpumgnd(rx, eigen_mat);

with_cuda_nd(rx, eigen_mat);
with_gpu_nd(rx, eigen_mat);

// polyscope::show();
}
Expand Down
8 changes: 8 additions & 0 deletions include/rxmesh/matrix/sparse_matrix.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,14 @@ struct SparseMatrix

/* --- LOW LEVEL API --- */

/**
* @brief return a pointer to the host memory that holds the permutation
*/
__host__ IndexT* get_h_permute()
{
return m_h_permute;
}

/**
* @brief allocate all temp buffers needed for the solver low-level API
*/
Expand Down

0 comments on commit 6b7b075

Please sign in to comment.