From 4cec1600de7ad1599ce741e1000268a5fccbaea5 Mon Sep 17 00:00:00 2001 From: Julio Perez Date: Tue, 25 Feb 2025 19:59:38 -0500 Subject: [PATCH] replace loop with memset --- cpp/include/raft/sparse/matrix/preprocessing.cuh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cpp/include/raft/sparse/matrix/preprocessing.cuh b/cpp/include/raft/sparse/matrix/preprocessing.cuh index 1a6d69da95..b475b5f678 100644 --- a/cpp/include/raft/sparse/matrix/preprocessing.cuh +++ b/cpp/include/raft/sparse/matrix/preprocessing.cuh @@ -138,12 +138,10 @@ class SparseEncoder { template SparseEncoder::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 @@ -172,9 +170,9 @@ SparseEncoder::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]; }