115 int* spectraValues,
int* spectraIdx,
116 int csrRowoffsetsLength,
int csrNNZ,
117 int sVLength,
int sILength,
118 int n,
float tolerance,
119 bool normalize,
bool gaussianTol,
122 if (n >= csrRowoffsetsLength) {
123 throw std::invalid_argument(
"Cannot return more hits than number of candidates!");
129 int* result =
new int[sILength * n];
130 float* csrValues =
new float[csrNNZ];
131 float* MVresult =
new float[csrRowoffsetsLength - 1] {0.0};
134 for (
int i = 0; i < csrRowoffsetsLength - 1; ++i) {
135 int startIter = csrRowoffsets[i];
136 int endIter = csrRowoffsets[i + 1];
137 int nrNonZero = endIter - startIter;
138 float val = normalize ? 1.0 / (float) nrNonZero : 1.0;
139 for (
int j = startIter; j < endIter; ++j) {
149 int* dM_csrRowoffsets;
155 CHECK_CUDA(cudaMalloc((
void**) &dM_csrRowoffsets, csrRowoffsetsLength *
sizeof(
int)));
156 CHECK_CUDA(cudaMalloc((
void**) &dM_csrColIdx, csrNNZ *
sizeof(
int)));
157 CHECK_CUDA(cudaMalloc((
void**) &dM_csrValues, csrNNZ *
sizeof(
float)));
159 CHECK_CUDA(cudaMalloc((
void**) &dMVresult, (csrRowoffsetsLength - 1) *
sizeof(
float)));
162 CHECK_CUDA(cudaMemcpy(dM_csrRowoffsets, csrRowoffsets, csrRowoffsetsLength *
sizeof(
int), cudaMemcpyHostToDevice));
163 CHECK_CUDA(cudaMemcpy(dM_csrColIdx, csrColIdx, csrNNZ *
sizeof(
int), cudaMemcpyHostToDevice));
164 CHECK_CUDA(cudaMemcpy(dM_csrValues, csrValues, csrNNZ *
sizeof(
float), cudaMemcpyHostToDevice));
165 CHECK_CUDA(cudaMemcpy(dMVresult, MVresult, (csrRowoffsetsLength - 1) *
sizeof(
float), cudaMemcpyHostToDevice));
168 cusparseHandle_t handle = NULL;
169 cusparseSpMatDescr_t mat;
170 cusparseDnVecDescr_t vec;
171 cusparseDnVecDescr_t res;
172 void* dBuffer = NULL;
173 size_t bufferSize = 0;
177 dM_csrRowoffsets, dM_csrColIdx, dM_csrValues,
178 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
179 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F));
180 CHECK_CUSPARSE(cusparseCreateDnVec(&res, csrRowoffsetsLength - 1, dMVresult, CUDA_R_32F));
183 for (
int i = 0; i < sILength; ++i) {
188 int startIter = spectraIdx[i];
189 int endIter = i + 1 == sILength ? sVLength : spectraIdx[i + 1];
190 for (
int j = startIter; j < endIter; ++j) {
191 auto currentPeak = spectraValues[j];
192 auto minPeak = currentPeak - t > 0 ? currentPeak - t : 0;
195 for (
int k = minPeak; k <= maxPeak; ++k) {
196 float currentVal = V[k];
197 float newVal = gaussianTol ?
normpdf((
float) k, (
float) currentPeak, (
float) (t / 3.0)) : 1.0;
198 V[k] = max(currentVal, newVal);
206 CUSPARSE_OPERATION_NON_TRANSPOSE,
207 &alpha, mat, vec, &beta, res,
208 CUDA_R_32F, CUSPARSE_SPMV_ALG_DEFAULT, &bufferSize));
211 CUSPARSE_OPERATION_NON_TRANSPOSE,
212 &alpha, mat, vec, &beta, res,
213 CUDA_R_32F, CUSPARSE_SPMV_ALG_DEFAULT, dBuffer));
215 CHECK_CUDA(cudaMemcpy(MVresult, dMVresult, (csrRowoffsetsLength - 1) *
sizeof(
float), cudaMemcpyDeviceToHost));
220 auto* idx =
new int[csrRowoffsetsLength - 1];
221 std::iota(idx, idx + csrRowoffsetsLength - 1, 0);
222 std::sort(idx, idx + csrRowoffsetsLength - 1, [&](
int i,
int j) {
return MVresult[i] > MVresult[j];});
224 for (
int j = 0; j < n; ++j) {
225 result[i * n + j] = idx[j];
230 if (verbose != 0 && (i + 1) % verbose == 0) {
231 std::cout <<
"Searched " << i + 1 <<
" spectra in total..." << std::endl;
273 int* spectraValues,
int* spectraIdx,
274 int csrRowoffsetsLength,
int csrNNZ,
275 int sVLength,
int sILength,
276 int n,
float tolerance,
277 bool normalize,
bool gaussianTol,
280 if (n >= csrRowoffsetsLength) {
281 throw std::invalid_argument(
"Cannot return more hits than number of candidates!");
284 if (tolerance < 0.01f) {
285 throw std::invalid_argument(
"Tolerance must not be smaller than 0.01 for i8 operations!");
291 int* result =
new int[sILength * n];
292 int8_t* csrValues =
new int8_t[csrNNZ];
293 int* MVresult =
new int[csrRowoffsetsLength - 1] {0};
296 for (
int i = 0; i < csrRowoffsetsLength - 1; ++i) {
297 int startIter = csrRowoffsets[i];
298 int endIter = csrRowoffsets[i + 1];
299 int nrNonZero = endIter - startIter;
300 int8_t val = normalize ? (int8_t) round(INT8_MAX / (
float) nrNonZero) : 1i8;
301 for (
int j = startIter; j < endIter; ++j) {
311 int* dM_csrRowoffsets;
313 int8_t* dM_csrValues;
317 CHECK_CUDA(cudaMalloc((
void**) &dM_csrRowoffsets, csrRowoffsetsLength *
sizeof(
int)));
318 CHECK_CUDA(cudaMalloc((
void**) &dM_csrColIdx, csrNNZ *
sizeof(
int)));
319 CHECK_CUDA(cudaMalloc((
void**) &dM_csrValues, csrNNZ *
sizeof(int8_t)));
321 CHECK_CUDA(cudaMalloc((
void**) &dMVresult, (csrRowoffsetsLength - 1) *
sizeof(
int)));
324 CHECK_CUDA(cudaMemcpy(dM_csrRowoffsets, csrRowoffsets, csrRowoffsetsLength *
sizeof(
int), cudaMemcpyHostToDevice));
325 CHECK_CUDA(cudaMemcpy(dM_csrColIdx, csrColIdx, csrNNZ *
sizeof(
int), cudaMemcpyHostToDevice));
326 CHECK_CUDA(cudaMemcpy(dM_csrValues, csrValues, csrNNZ *
sizeof(int8_t), cudaMemcpyHostToDevice));
327 CHECK_CUDA(cudaMemcpy(dMVresult, MVresult, (csrRowoffsetsLength - 1) *
sizeof(
int), cudaMemcpyHostToDevice));
330 cusparseHandle_t handle = NULL;
331 cusparseSpMatDescr_t mat;
332 cusparseDnVecDescr_t vec;
333 cusparseDnVecDescr_t res;
334 void* dBuffer = NULL;
335 size_t bufferSize = 0;
339 dM_csrRowoffsets, dM_csrColIdx, dM_csrValues,
340 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
341 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_8I));
342 CHECK_CUSPARSE(cusparseCreateDnVec(&res, csrRowoffsetsLength - 1, dMVresult, CUDA_R_32I));
345 for (
int i = 0; i < sILength; ++i) {
350 int startIter = spectraIdx[i];
351 int endIter = i + 1 == sILength ? sVLength : spectraIdx[i + 1];
352 for (
int j = startIter; j < endIter; ++j) {
353 auto currentPeak = spectraValues[j];
354 auto minPeak = currentPeak - t > 0 ? currentPeak - t : 0;
357 for (
int k = minPeak; k <= maxPeak; ++k) {
358 int8_t currentVal = V[k];
359 int8_t newVal = gaussianTol ? (int8_t) round(
normpdf((
float) k, (
float) currentPeak, (
float) (t / 3.0)) *
ROUNDING_ACCURACY) : 1i8;
360 V[k] = max(currentVal, newVal);
368 CUSPARSE_OPERATION_NON_TRANSPOSE,
369 &alpha, mat, vec, &beta, res,
370 CUDA_R_32I, CUSPARSE_SPMV_CSR_ALG2, &bufferSize));
373 CUSPARSE_OPERATION_NON_TRANSPOSE,
374 &alpha, mat, vec, &beta, res,
375 CUDA_R_32I, CUSPARSE_SPMV_CSR_ALG2, dBuffer));
377 CHECK_CUDA(cudaMemcpy(MVresult, dMVresult, (csrRowoffsetsLength - 1) *
sizeof(
int), cudaMemcpyDeviceToHost));
382 auto* idx =
new int[csrRowoffsetsLength - 1];
383 std::iota(idx, idx + csrRowoffsetsLength - 1, 0);
384 std::sort(idx, idx + csrRowoffsetsLength - 1, [&](
int i,
int j) {
return MVresult[i] > MVresult[j];});
386 for (
int j = 0; j < n; ++j) {
387 result[i * n + j] = idx[j];
392 if (verbose != 0 && (i + 1) % verbose == 0) {
393 std::cout <<
"Searched " << i + 1 <<
" spectra in total..." << std::endl;
436 int* spectraValues,
int* spectraIdx,
437 int csrRowoffsetsLength,
int csrNNZ,
438 int sVLength,
int sILength,
439 int n,
float tolerance,
440 bool normalize,
bool gaussianTol,
444 if (n >= csrRowoffsetsLength) {
445 throw std::invalid_argument(
"Cannot return more hits than number of candidates!");
451 int* result =
new int[sILength * n];
452 float* csrValues =
new float[csrNNZ];
455 for (
int i = 0; i < csrRowoffsetsLength - 1; ++i) {
456 int startIter = csrRowoffsets[i];
457 int endIter = csrRowoffsets[i + 1];
458 int nrNonZero = endIter - startIter;
459 float val = normalize ? 1.0 / (float) nrNonZero : 1.0;
460 for (
int j = startIter; j < endIter; ++j) {
470 int* dm_csrRowoffsets;
473 int* dM_csrRowoffsets;
476 int* dspgemM_csrRowoffsets;
477 int* dspgemM_csrColIdx;
478 float* dspgemM_csrValues;
481 void* dBuffer1 = NULL;
482 void* dBuffer2 = NULL;
483 size_t bufferSize1 = 0;
484 size_t bufferSize2 = 0;
487 CHECK_CUDA(cudaMalloc((
void**) &dm_csrRowoffsets, csrRowoffsetsLength *
sizeof(
int)));
488 CHECK_CUDA(cudaMalloc((
void**) &dm_csrColIdx, csrNNZ *
sizeof(
int)));
489 CHECK_CUDA(cudaMalloc((
void**) &dm_csrValues, csrNNZ *
sizeof(
float)));
492 CHECK_CUDA(cudaMemcpy(dm_csrRowoffsets, csrRowoffsets, csrRowoffsetsLength *
sizeof(
int), cudaMemcpyHostToDevice));
493 CHECK_CUDA(cudaMemcpy(dm_csrColIdx, csrColIdx, csrNNZ *
sizeof(
int), cudaMemcpyHostToDevice));
494 CHECK_CUDA(cudaMemcpy(dm_csrValues, csrValues, csrNNZ *
sizeof(
float), cudaMemcpyHostToDevice));
497 cusparseHandle_t handle = NULL;
498 cusparseSpMatDescr_t mat;
502 dm_csrRowoffsets, dm_csrColIdx, dm_csrValues,
503 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
504 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F));
507 CHECK_CUDA(cudaMalloc((
void**) &dspgemM_csrRowoffsets, csrRowoffsetsLength *
sizeof(
int)));
509 for (
int i = 0; i < sILength; i += batchSize) {
512 std::vector<std::vector<float>> vectorStorage;
513 std::vector<int> M_csrRowoffsets;
514 std::vector<int> M_csrColIdx;
515 std::vector<float> M_csrValues;
517 M_csrRowoffsets.push_back(0);
519 for (
int s = 0; s < batchSize; ++s) {
523 if (i + s < sILength) {
525 int startIter = spectraIdx[i + s];
526 int endIter = i + s + 1 == sILength ? sVLength : spectraIdx[i + s + 1];
528 for (
int j = startIter; j < endIter; ++j) {
529 auto currentPeak = spectraValues[j];
530 auto minPeak = currentPeak - t > 0 ? currentPeak - t : 0;
533 for (
int k = minPeak; k <= maxPeak; ++k) {
534 float currentVal = v[k];
535 float newVal = gaussianTol ?
normpdf((
float) k, (
float) currentPeak, (
float) (t / 3.0)) : 1.0;
536 v[k] = max(currentVal, newVal);
541 vectorStorage.push_back(v);
546 for (
int s = 0; s < batchSize; ++s) {
547 if (vectorStorage[s][j] != 0.0) {
548 M_csrColIdx.push_back(s);
549 M_csrValues.push_back(vectorStorage[s][j]);
553 M_csrRowoffsets.push_back(M_csrNNZ);
556 vectorStorage.clear();
560 CHECK_CUDA(cudaMalloc((
void**) &dM_csrColIdx, M_csrNNZ *
sizeof(
int)));
561 CHECK_CUDA(cudaMalloc((
void**) &dM_csrValues, M_csrNNZ *
sizeof(
float)));
564 CHECK_CUDA(cudaMemcpy(dM_csrRowoffsets, M_csrRowoffsets.data(), (
ENCODING_SIZE + 1) *
sizeof(
int), cudaMemcpyHostToDevice));
565 CHECK_CUDA(cudaMemcpy(dM_csrColIdx, M_csrColIdx.data(), M_csrNNZ *
sizeof(
int), cudaMemcpyHostToDevice));
566 CHECK_CUDA(cudaMemcpy(dM_csrValues, M_csrValues.data(), M_csrNNZ *
sizeof(
float), cudaMemcpyHostToDevice));
569 cusparseSpMatDescr_t Mat;
572 dM_csrRowoffsets, dM_csrColIdx, dM_csrValues,
573 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
574 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F));
577 cusparseSpMatDescr_t spgemM;
579 CHECK_CUSPARSE(cusparseCreateCsr(&spgemM, csrRowoffsetsLength - 1, batchSize, 0,
581 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
582 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F));
585 cusparseSpGEMMDescr_t spgemmDesc;
587 CHECK_CUSPARSE(cusparseSpGEMM_workEstimation(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, CUSPARSE_OPERATION_NON_TRANSPOSE,
588 &alpha, mat, Mat, &beta, spgemM,
589 CUDA_R_32F, CUSPARSE_SPGEMM_ALG1,
590 spgemmDesc, &bufferSize1, NULL));
591 CHECK_CUDA(cudaMalloc((
void**) &dBuffer1, bufferSize1));
592 CHECK_CUSPARSE(cusparseSpGEMM_workEstimation(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, CUSPARSE_OPERATION_NON_TRANSPOSE,
593 &alpha, mat, Mat, &beta, spgemM,
594 CUDA_R_32F, CUSPARSE_SPGEMM_ALG1,
595 spgemmDesc, &bufferSize1, dBuffer1));
596 CHECK_CUSPARSE(cusparseSpGEMM_compute(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, CUSPARSE_OPERATION_NON_TRANSPOSE,
597 &alpha, mat, Mat, &beta, spgemM,
598 CUDA_R_32F, CUSPARSE_SPGEMM_ALG1,
599 spgemmDesc, &bufferSize2, NULL));
600 CHECK_CUDA(cudaMalloc((
void**) &dBuffer2, bufferSize2));
601 CHECK_CUSPARSE(cusparseSpGEMM_compute(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, CUSPARSE_OPERATION_NON_TRANSPOSE,
602 &alpha, mat, Mat, &beta, spgemM,
603 CUDA_R_32F, CUSPARSE_SPGEMM_ALG1,
604 spgemmDesc, &bufferSize2, dBuffer2));
607 int64_t spgemM_rows, spgemM_cols, spgemM_nnz;
608 CHECK_CUSPARSE(cusparseSpMatGetSize(spgemM, &spgemM_rows, &spgemM_cols, &spgemM_nnz));
609 CHECK_CUDA(cudaMalloc((
void**) &dspgemM_csrColIdx, spgemM_nnz *
sizeof(
int)));
610 CHECK_CUDA(cudaMalloc((
void**) &dspgemM_csrValues, spgemM_nnz *
sizeof(
float)));
611 CHECK_CUSPARSE(cusparseCsrSetPointers(spgemM, dspgemM_csrRowoffsets, dspgemM_csrColIdx, dspgemM_csrValues));
612 CHECK_CUSPARSE(cusparseSpGEMM_copy(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, CUSPARSE_OPERATION_NON_TRANSPOSE,
613 &alpha, mat, Mat, &beta, spgemM,
614 CUDA_R_32F, CUSPARSE_SPGEMM_ALG1, spgemmDesc));
617 int* spgemM_csrRowoffsets =
new int[csrRowoffsetsLength];
618 int* spgemM_csrColIdx =
new int[spgemM_nnz];
619 float* spgemM_csrValues =
new float[spgemM_nnz];
620 CHECK_CUDA(cudaMemcpy(spgemM_csrRowoffsets, dspgemM_csrRowoffsets, csrRowoffsetsLength *
sizeof(
int), cudaMemcpyDeviceToHost));
621 CHECK_CUDA(cudaMemcpy(spgemM_csrColIdx, dspgemM_csrColIdx, spgemM_nnz *
sizeof(
int), cudaMemcpyDeviceToHost));
622 CHECK_CUDA(cudaMemcpy(spgemM_csrValues, dspgemM_csrValues, spgemM_nnz *
sizeof(
float), cudaMemcpyDeviceToHost));
625 for (
int s = 0; s < batchSize; ++s) {
627 if (i + s >= sILength) {
631 std::vector<int> rowIdx;
632 std::vector<float> rowValues;
633 for (
int j = 0; j < spgemM_nnz; ++j) {
634 if (spgemM_csrColIdx[j] == s) {
635 rowIdx.push_back(
getRowIdx(spgemM_csrRowoffsets, csrRowoffsetsLength, j));
636 rowValues.push_back(spgemM_csrValues[j]);
642 std::vector<int> idx(rowIdx.size());
643 std::iota(idx.begin(), idx.end(), 0);
644 std::sort(idx.begin(), idx.end(), [&](
int i,
int j) {return rowValues[i] > rowValues[j];});
646 if (rowIdx.size() >= n) {
647 for (
int j = 0; j < n; ++j) {
648 result[(i + s) * n + j] = rowIdx[idx[j]];
654 delete[] spgemM_csrRowoffsets;
655 delete[] spgemM_csrColIdx;
656 delete[] spgemM_csrValues;
669 if (verbose != 0 && (i + batchSize) % verbose == 0) {
670 std::cout <<
"Searched " << i + batchSize <<
" spectra in total..." << std::endl;
711 int* spectraValues,
int* spectraIdx,
712 int csrRowoffsetsLength,
int csrNNZ,
713 int sVLength,
int sILength,
714 int n,
float tolerance,
715 bool normalize,
bool gaussianTol,
719 if (n >= csrRowoffsetsLength) {
720 throw std::invalid_argument(
"Cannot return more hits than number of candidates!");
726 int* result =
new int[sILength * n];
727 float* csrValues =
new float[csrNNZ];
730 for (
int i = 0; i < csrRowoffsetsLength - 1; ++i) {
731 int startIter = csrRowoffsets[i];
732 int endIter = csrRowoffsets[i + 1];
733 int nrNonZero = endIter - startIter;
734 float val = normalize ? 1.0 / (float) nrNonZero : 1.0;
735 for (
int j = startIter; j < endIter; ++j) {
745 int* dm_csrRowoffsets;
749 float* dspmM_dnValues;
752 void* dBuffer = NULL;
753 size_t bufferSize = 0;
756 CHECK_CUDA(cudaMalloc((
void**) &dm_csrRowoffsets, csrRowoffsetsLength *
sizeof(
int)));
757 CHECK_CUDA(cudaMalloc((
void**) &dm_csrColIdx, csrNNZ *
sizeof(
int)));
758 CHECK_CUDA(cudaMalloc((
void**) &dm_csrValues, csrNNZ *
sizeof(
float)));
761 CHECK_CUDA(cudaMemcpy(dm_csrRowoffsets, csrRowoffsets, csrRowoffsetsLength *
sizeof(
int), cudaMemcpyHostToDevice));
762 CHECK_CUDA(cudaMemcpy(dm_csrColIdx, csrColIdx, csrNNZ *
sizeof(
int), cudaMemcpyHostToDevice));
763 CHECK_CUDA(cudaMemcpy(dm_csrValues, csrValues, csrNNZ *
sizeof(
float), cudaMemcpyHostToDevice));
769 CHECK_CUDA(cudaMalloc((
void**) &dspmM_dnValues, (csrRowoffsetsLength - 1) * batchSize *
sizeof(
float)));
772 cusparseHandle_t handle = NULL;
773 cusparseSpMatDescr_t mat;
777 dm_csrRowoffsets, dm_csrColIdx, dm_csrValues,
778 CUSPARSE_INDEX_32I, CUSPARSE_INDEX_32I,
779 CUSPARSE_INDEX_BASE_ZERO, CUDA_R_32F));
781 for (
int i = 0; i < sILength; i += batchSize) {
786 for (
int s = 0; s < batchSize; ++s) {
788 if (i + s < sILength) {
790 int startIter = spectraIdx[i + s];
791 int endIter = i + s + 1 == sILength ? sVLength : spectraIdx[i + s + 1];
793 for (
int j = startIter; j < endIter; ++j) {
794 auto currentPeak = spectraValues[j];
795 auto minPeak = currentPeak - t > 0 ? currentPeak - t : 0;
798 for (
int k = minPeak; k <= maxPeak; ++k) {
800 float newVal = gaussianTol ?
normpdf((
float) k, (
float) currentPeak, (
float) (t / 3.0)) : 1.0;
808 cusparseDnMatDescr_t Mat;
812 CUDA_R_32F, CUSPARSE_ORDER_COL));
815 float* spmm =
new float[(csrRowoffsetsLength - 1) * batchSize] {0.0};
818 cusparseDnMatDescr_t spmM;
820 CHECK_CUDA(cudaMemcpy(dspmM_dnValues, spmm, (csrRowoffsetsLength - 1) * batchSize *
sizeof(
float), cudaMemcpyHostToDevice));
821 CHECK_CUSPARSE(cusparseCreateDnMat(&spmM, csrRowoffsetsLength - 1, batchSize, csrRowoffsetsLength - 1, dspmM_dnValues,
822 CUDA_R_32F, CUSPARSE_ORDER_COL));
825 CHECK_CUSPARSE(cusparseSpMM_bufferSize(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, CUSPARSE_OPERATION_NON_TRANSPOSE,
826 &alpha, mat, Mat, &beta, spmM, CUDA_R_32F,
827 CUSPARSE_SPMM_CSR_ALG1, &bufferSize));
831 CHECK_CUSPARSE(cusparseSpMM(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, CUSPARSE_OPERATION_NON_TRANSPOSE,
832 &alpha, mat, Mat, &beta, spmM, CUDA_R_32F,
833 CUSPARSE_SPMM_CSR_ALG1, dBuffer));
836 CHECK_CUDA(cudaMemcpy(spmm, dspmM_dnValues, (csrRowoffsetsLength - 1) * batchSize *
sizeof(
float), cudaMemcpyDeviceToHost));
839 for (
int s = 0; s < batchSize; ++s) {
841 if (i + s >= sILength) {
845 int currentCol = s * (csrRowoffsetsLength - 1);
846 std::vector<float> values(csrRowoffsetsLength - 1, 0.0);
847 for (
int j = 0; j < csrRowoffsetsLength - 1; ++j) {
848 values[j] = spmm[currentCol + j];
851 std::vector<int> idx(csrRowoffsetsLength - 1);
852 std::iota(idx.begin(), idx.end(), 0);
853 std::sort(idx.begin(), idx.end(), [&](
int i,
int j) {return values[i] > values[j];});
855 if (idx.size() >= n) {
856 for (
int j = 0; j < n; ++j) {
857 result[(i + s) * n + j] = idx[j];
870 if (verbose != 0 && (i + batchSize) % verbose == 0) {
871 std::cout <<
"Searched " << i + batchSize <<
" spectra in total..." << std::endl;