Skip to content

Commit

Permalink
replace loop with memset
Browse files Browse the repository at this point in the history
  • Loading branch information
jperez999 committed Feb 26, 2025
1 parent 950e564 commit 4cec160
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions cpp/include/raft/sparse/matrix/preprocessing.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,10 @@ class SparseEncoder {
template <typename ValueType, typename IndexType>
SparseEncoder<ValueType, IndexType>::SparseEncoder(int feats) : numFeats(feats)
{
cudaMallocManaged(&featIdCount, feats * sizeof(int));
cudaMallocManaged(&featIdCount, feats * sizeof(IndexType));
cudaMemset(featIdCount, 0, numFeats * sizeof(IndexType));
fullIdLen = 0;
numRows = 0;
for (int i = 0; i < numFeats; i++) {
featIdCount[i] = 0;
}
}
/**
* This constructor creates the `SparseEncoder` class with a numFeats equal to the
Expand Down Expand Up @@ -172,9 +170,9 @@ SparseEncoder<ValueType, IndexType>::SparseEncoder(
: numFeats(num_feats), numRows(num_rows), fullIdLen(full_id_len)
{
cudaStream_t stream = raft::resource::get_cuda_stream(handle);
cudaMallocManaged(&featIdCount, numFeats * sizeof(int));
cudaMallocManaged(&featIdCount, numFeats * sizeof(IndexType));

cudaMemset(featIdCount, 0, numFeats * sizeof(int));
cudaMemset(featIdCount, 0, numFeats * sizeof(IndexType));
for (int i = 0; i < numFeats; i++) {
featIdCount[i] = featIdValues[i];
}
Expand Down

0 comments on commit 4cec160

Please sign in to comment.