-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
#include "cusolverSp.h" | ||
#include "cusparse.h" | ||
|
||
#include "rxmesh/context.h" | ||
#include "rxmesh/query.cuh" | ||
|
||
namespace rxmesh { | ||
|
||
namespace detail { | ||
|
||
// this is the function for the CSR calculation | ||
template <uint32_t blockThreads, typename IndexT = int> | ||
__global__ static void sparse_mat_prescan(const rxmesh::Context context, | ||
IndexT* row_ptr) | ||
{ | ||
using namespace rxmesh; | ||
|
||
auto init_lambda = [&](VertexHandle& v_id, const VertexIterator& iter) { | ||
auto ids = v_id.unpack(); | ||
uint32_t patch_id = ids.first; | ||
uint16_t local_id = ids.second; | ||
row_ptr[context.vertex_prefix()[patch_id] + local_id] = iter.size() + 1; | ||
}; | ||
|
||
auto block = cooperative_groups::this_thread_block(); | ||
Query<blockThreads> query(context); | ||
ShmemAllocator shrd_alloc; | ||
query.dispatch<Op::VV>(block, shrd_alloc, init_lambda); | ||
} | ||
|
||
template <uint32_t blockThreads, typename IndexT = int> | ||
__global__ static void sparse_mat_col_fill(const rxmesh::Context context, | ||
IndexT* row_ptr, | ||
IndexT* col_idx) | ||
{ | ||
using namespace rxmesh; | ||
|
||
auto col_fillin = [&](VertexHandle& v_id, const VertexIterator& iter) { | ||
auto ids = v_id.unpack(); | ||
uint32_t patch_id = ids.first; | ||
uint16_t local_id = ids.second; | ||
col_idx[row_ptr[context.vertex_prefix()[patch_id] + local_id]] = | ||
context.vertex_prefix()[patch_id] + local_id; | ||
for (uint32_t v = 0; v < iter.size(); ++v) { | ||
auto s_ids = iter[v].unpack(); | ||
uint32_t s_patch_id = s_ids.first; | ||
uint16_t s_local_id = s_ids.second; | ||
col_idx[row_ptr[context.vertex_prefix()[patch_id] + local_id] + v + | ||
1] = context.vertex_prefix()[s_patch_id] + s_local_id; | ||
} | ||
}; | ||
|
||
auto block = cooperative_groups::this_thread_block(); | ||
Query<blockThreads> query(context); | ||
ShmemAllocator shrd_alloc; | ||
query.dispatch<Op::VV>(block, shrd_alloc, col_fillin); | ||
} | ||
|
||
} // namespace detail | ||
|
||
} // namespace rxmesh |