Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid default-init overhead for lookup map in assemble_pre #122

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/ssids/cpu/kernels/assemble.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ void assemble_pre(
typename FADoubleTraits::allocator_type factor_alloc_double(factor_alloc);
typedef typename std::allocator_traits<FactorAlloc>::template rebind_traits<int> FAIntTraits;
typename FAIntTraits::allocator_type factor_alloc_int(factor_alloc);
typedef typename std::allocator_traits<PoolAlloc>::template rebind_alloc<int> PoolAllocInt;
typedef typename std::allocator_traits<PoolAlloc>::template rebind_traits<int> PAIntTraits;
typename PAIntTraits::allocator_type pool_alloc_int(pool_alloc);

/* Count incoming delays and determine size of node */
node.ndelay_in = 0;
Expand Down Expand Up @@ -228,7 +229,11 @@ void assemble_pre(
/* Build lookup vector, allowing for insertion of delayed vars */
/* Note that while rlist[] is 1-indexed this is fine so long as lookup
* is also 1-indexed (which it is as it is another node's rlist[] */
std::vector<int, PoolAllocInt> map(n+1, PoolAllocInt(pool_alloc));
const auto map_deleter = [&pool_alloc_int, n](int* p) {
PAIntTraits::deallocate(pool_alloc_int, p, n+1);
};
auto map = std::unique_ptr<int[], decltype(map_deleter)>(
PAIntTraits::allocate(pool_alloc_int, n+1), map_deleter);
for(int i=0; i<snode.ncol; i++)
map[ snode.rlist[i] ] = i;
for(int i=snode.ncol; i<snode.nrow; i++)
Expand Down
Loading