CandidateVectorSearch 1.7.2
Searching for peptide candidates using sparse matrix + matrix/vector multiplication.
|
#include "pch.h"
#include <cuda_runtime_api.h>
#include <cusparse.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
Go to the source code of this file.
Macros | |
#define | METHOD_EXPORTS |
#define | EXPORT __declspec(dllexport) |
#define | CHECK_CUDA(status) { checkCuda(status, __LINE__); } |
#define | CHECK_CUSPARSE(status) { checkCusparse(status, __LINE__); } |
Functions | |
EXPORT int * | findTopCandidatesCuda (int *csrRowoffsets, int *csrColIdx, int *spectraValues, int *spectraIdx, int csrRowoffsetsLength, int csrNNZ, int sVLength, int sILength, int n, float tolerance, bool normalize, bool gaussianTol, int verbose) |
A function that calculates the top n candidates for each spectrum (SpM*V) using f32 operations. | |
EXPORT int * | findTopCandidatesCudaInt (int *csrRowoffsets, int *csrColIdx, int *spectraValues, int *spectraIdx, int csrRowoffsetsLength, int csrNNZ, int sVLength, int sILength, int n, float tolerance, bool normalize, bool gaussianTol, int verbose) |
A function that calculates the top n candidates for each spectrum (SpM*V) using i8 and 32 operations. | |
EXPORT int * | findTopCandidatesCudaBatched (int *csrRowoffsets, int *csrColIdx, int *spectraValues, int *spectraIdx, int csrRowoffsetsLength, int csrNNZ, int sVLength, int sILength, int n, float tolerance, bool normalize, bool gaussianTol, int batchSize, int verbose) |
A function that calculates the top n candidates for each spectrum. Uses cusparseSpGEMM to calculate matrix product. | |
EXPORT int * | findTopCandidatesCudaBatched2 (int *csrRowoffsets, int *csrColIdx, int *spectraValues, int *spectraIdx, int csrRowoffsetsLength, int csrNNZ, int sVLength, int sILength, int n, float tolerance, bool normalize, bool gaussianTol, int batchSize, int verbose) |
A function that calculates the top n candidates for each spectrum. Uses cusparseSpMM to calculate matrix product. | |
EXPORT int | releaseMemoryCuda (int *result) |
Free memory after result has been marshalled. | |
float | squared (float x) |
Returns the square for a given value x. | |
float | normpdf (float x, float mu, float sigma) |
Returns the PDF for a given x for the normal distribution given by mu and sigma. | |
int | getRowIdx (int *csrRowoffsets, int csrRowoffsetsLength, int colIdxPos) |
Gets the row index of a specific position in the csr_column_indices array. | |
int | checkCuda (cudaError_t, int line) |
int | checkCusparse (cusparseStatus_t, int line) |
BOOL APIENTRY | DllMain (HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) |
Variables | |
const int | versionMajor = 1 |
const int | versionMinor = 5 |
const int | versionFix = 1 |
const int | MASS_RANGE = 5000 |
const int | MASS_MULTIPLIER = 100 |
const int | ENCODING_SIZE = MASS_RANGE * MASS_MULTIPLIER |
const float | ROUNDING_ACCURACY = (float) INT8_MAX / 7.0f |
const double | ONE_OVER_SQRT_PI = 0.39894228040143267793994605993438 |
#define CHECK_CUDA | ( | status | ) | { checkCuda(status, __LINE__); } |
Definition at line 23 of file findTopCandidatesCudaInt.cpp.
#define CHECK_CUSPARSE | ( | status | ) | { checkCusparse(status, __LINE__); } |
Definition at line 24 of file findTopCandidatesCudaInt.cpp.
#define EXPORT __declspec(dllexport) |
Definition at line 18 of file findTopCandidatesCudaInt.cpp.
#define METHOD_EXPORTS |
Definition at line 16 of file findTopCandidatesCudaInt.cpp.
int checkCuda | ( | cudaError_t | status, |
int | line | ||
) |
Definition at line 77 of file findTopCandidatesCudaInt.cpp.
int checkCusparse | ( | cusparseStatus_t | status, |
int | line | ||
) |
Definition at line 87 of file findTopCandidatesCudaInt.cpp.
BOOL APIENTRY DllMain | ( | HMODULE | hModule, |
DWORD | ul_reason_for_call, | ||
LPVOID | lpReserved | ||
) |
Definition at line 946 of file findTopCandidatesCudaInt.cpp.
int * findTopCandidatesCuda | ( | int * | csrRowoffsets, |
int * | csrColIdx, | ||
int * | spectraValues, | ||
int * | spectraIdx, | ||
int | csrRowoffsetsLength, | ||
int | csrNNZ, | ||
int | sVLength, | ||
int | sILength, | ||
int | n, | ||
float | tolerance, | ||
bool | normalize, | ||
bool | gaussianTol, | ||
int | verbose | ||
) |
A function that calculates the top n candidates for each spectrum (SpM*V) using f32 operations.
csrRowoffsets | Rowoffsets (int array) of the CSR sparse matrix (L: rows + 1). |
csrColIdx | Column indices (int array) of the CSR sparse matrix (L: NNZ). |
spectraValues | An integer array of peaks from experimental spectra flattened. |
spectraIdx | An integer array that contains indices of where each spectrum starts in spectraValues. |
csrRowoffsetsLength | Length (int) of csrRowoffsets (rows + 1). |
csrNNZ | Number of non-zero entries (int) in the CSR sparse matrix. |
sVLength | Length (int) of spectraValues. |
sILength | Length (int) of spectraIdx. |
n | How many of the best hits should be returned (int). |
tolerance | Tolerance for peak matching (float). |
normalize | If candidate vectors should be normalized to sum(elements) = 1 (bool). |
gaussianTol | If spectrum peaks should be modelled as normal distributions or not (bool). |
verbose | Print info every (int) processed spectra. |
csrRowoffsets | Rowoffsets (int array) of the CSR sparse matrix (L: rows + 1). |
csrColIdx | Column indices (int array) of the CSR sparse matrix (L: NNZ). |
spectraValues | An integer array of peaks from experimental spectra flattened. |
spectraIdx | An integer array that contains indices of where each spectrum starts in spectraValues. |
csrRowoffsetsLength | Length (int) of csrRowoffsets (rows + 1). |
csrNNZ | Number of non-zero entries (int) in the CSR sparse matrix. |
sVLength | Length (int) of spectraValues. |
sILength | Length (int) of spectraIdx. |
n | How many of the best hits should be returned (int). |
tolerance | Tolerance for peak matching (float). |
normalize | If candidate vectors should be normalized to sum(elements) = 1 (bool). |
gaussianTol | If spectrum peaks should be modelled as normal distributions or not (bool). |
verbose | Print info every (int) processed spectra. |
std::invalid_argument | Thrown if n is greater than cILength, cannot return more hits than number of candidates. |
Definition at line 114 of file findTopCandidatesCudaInt.cpp.
int * findTopCandidatesCudaBatched | ( | int * | csrRowoffsets, |
int * | csrColIdx, | ||
int * | spectraValues, | ||
int * | spectraIdx, | ||
int | csrRowoffsetsLength, | ||
int | csrNNZ, | ||
int | sVLength, | ||
int | sILength, | ||
int | n, | ||
float | tolerance, | ||
bool | normalize, | ||
bool | gaussianTol, | ||
int | batchSize, | ||
int | verbose | ||
) |
A function that calculates the top n candidates for each spectrum. Uses cusparseSpGEMM to calculate matrix product.
csrRowoffsets | Rowoffsets (int array) of the CSR sparse matrix (L: rows + 1). |
csrColIdx | Column indices (int array) of the CSR sparse matrix (L: NNZ). |
spectraValues | An integer array of peaks from experimental spectra flattened. |
spectraIdx | An integer array that contains indices of where each spectrum starts in spectraValues. |
csrRowoffsetsLength | Length (int) of csrRowoffsets (rows + 1). |
csrNNZ | Number of non-zero entries (int) in the CSR sparse matrix. |
sVLength | Length (int) of spectraValues. |
sILength | Length (int) of spectraIdx. |
n | How many of the best hits should be returned (int). |
tolerance | Tolerance for peak matching (float). |
normalize | If candidate vectors should be normalized to sum(elements) = 1 (bool). |
gaussianTol | If spectrum peaks should be modelled as normal distributions or not (bool). |
batchSize | How many spectra (int) should be searched at once. |
verbose | Print info every (int) processed spectra. |
csrRowoffsets | Rowoffsets (int array) of the CSR sparse matrix (L: rows + 1). |
csrColIdx | Column indices (int array) of the CSR sparse matrix (L: NNZ). |
spectraValues | An integer array of peaks from experimental spectra flattened. |
spectraIdx | An integer array that contains indices of where each spectrum starts in spectraValues. |
csrRowoffsetsLength | Length (int) of csrRowoffsets (rows + 1). |
csrNNZ | Number of non-zero entries (int) in the CSR sparse matrix. |
sVLength | Length (int) of spectraValues. |
sILength | Length (int) of spectraIdx. |
n | How many of the best hits should be returned (int). |
tolerance | Tolerance for peak matching (float). |
normalize | If candidate vectors should be normalized to sum(elements) = 1 (bool). |
gaussianTol | If spectrum peaks should be modelled as normal distributions or not (bool). |
batchSize | How many spectra (int) should be searched at once. |
verbose | Print info every (int) processed spectra. |
std::invalid_argument | Thrown if n is greater than cILength, cannot return more hits than number of candidates. |
Definition at line 435 of file findTopCandidatesCudaInt.cpp.
int * findTopCandidatesCudaBatched2 | ( | int * | csrRowoffsets, |
int * | csrColIdx, | ||
int * | spectraValues, | ||
int * | spectraIdx, | ||
int | csrRowoffsetsLength, | ||
int | csrNNZ, | ||
int | sVLength, | ||
int | sILength, | ||
int | n, | ||
float | tolerance, | ||
bool | normalize, | ||
bool | gaussianTol, | ||
int | batchSize, | ||
int | verbose | ||
) |
A function that calculates the top n candidates for each spectrum. Uses cusparseSpMM to calculate matrix product.
csrRowoffsets | Rowoffsets (int array) of the CSR sparse matrix (L: rows + 1). |
csrColIdx | Column indices (int array) of the CSR sparse matrix (L: NNZ). |
spectraValues | An integer array of peaks from experimental spectra flattened. |
spectraIdx | An integer array that contains indices of where each spectrum starts in spectraValues. |
csrRowoffsetsLength | Length (int) of csrRowoffsets (rows + 1). |
csrNNZ | Number of non-zero entries (int) in the CSR sparse matrix. |
sVLength | Length (int) of spectraValues. |
sILength | Length (int) of spectraIdx. |
n | How many of the best hits should be returned (int). |
tolerance | Tolerance for peak matching (float). |
normalize | If candidate vectors should be normalized to sum(elements) = 1 (bool). |
gaussianTol | If spectrum peaks should be modelled as normal distributions or not (bool). |
batchSize | How many spectra (int) should be searched at once. |
verbose | Print info every (int) processed spectra. |
csrRowoffsets | Rowoffsets (int array) of the CSR sparse matrix (L: rows + 1). |
csrColIdx | Column indices (int array) of the CSR sparse matrix (L: NNZ). |
spectraValues | An integer array of peaks from experimental spectra flattened. |
spectraIdx | An integer array that contains indices of where each spectrum starts in spectraValues. |
csrRowoffsetsLength | Length (int) of csrRowoffsets (rows + 1). |
csrNNZ | Number of non-zero entries (int) in the CSR sparse matrix. |
sVLength | Length (int) of spectraValues. |
sILength | Length (int) of spectraIdx. |
n | How many of the best hits should be returned (int). |
tolerance | Tolerance for peak matching (float). |
normalize | If candidate vectors should be normalized to sum(elements) = 1 (bool). |
gaussianTol | If spectrum peaks should be modelled as normal distributions or not (bool). |
batchSize | How many spectra (int) should be searched at once. |
verbose | Print info every (int) processed spectra. |
std::invalid_argument | Thrown if n is greater than cILength, cannot return more hits than number of candidates. |
Definition at line 710 of file findTopCandidatesCudaInt.cpp.
int * findTopCandidatesCudaInt | ( | int * | csrRowoffsets, |
int * | csrColIdx, | ||
int * | spectraValues, | ||
int * | spectraIdx, | ||
int | csrRowoffsetsLength, | ||
int | csrNNZ, | ||
int | sVLength, | ||
int | sILength, | ||
int | n, | ||
float | tolerance, | ||
bool | normalize, | ||
bool | gaussianTol, | ||
int | verbose | ||
) |
A function that calculates the top n candidates for each spectrum (SpM*V) using i8 and 32 operations.
csrRowoffsets | Rowoffsets (int array) of the CSR sparse matrix (L: rows + 1). |
csrColIdx | Column indices (int array) of the CSR sparse matrix (L: NNZ). |
spectraValues | An integer array of peaks from experimental spectra flattened. |
spectraIdx | An integer array that contains indices of where each spectrum starts in spectraValues. |
csrRowoffsetsLength | Length (int) of csrRowoffsets (rows + 1). |
csrNNZ | Number of non-zero entries (int) in the CSR sparse matrix. |
sVLength | Length (int) of spectraValues. |
sILength | Length (int) of spectraIdx. |
n | How many of the best hits should be returned (int). |
tolerance | Tolerance for peak matching (float). |
normalize | If candidate vectors should be normalized to sum(elements) = 1 (bool). |
gaussianTol | If spectrum peaks should be modelled as normal distributions or not (bool). |
verbose | Print info every (int) processed spectra. |
Definition at line 272 of file findTopCandidatesCudaInt.cpp.
int getRowIdx | ( | int * | csrRowoffsets, |
int | csrRowoffsetsLength, | ||
int | colIdxPos | ||
) |
Gets the row index of a specific position in the csr_column_indices array.
csrRowoffsets | The csr_row_offsets array. |
csrRowoffsetsLength | Length (int) of the csr_row_offsets array. |
colIdxPos | The position (int) of the element in question of the csr_column_indices array. |
csrRowoffsets | The csr_row_offsets array. |
csrRowoffsetsLength | Length (int) of the csr_row_offsets array. |
colIdxPos | The position (int) of the element in question of the csr_column_indices array. |
std::logic_error | Thrown if the row index could not be found. |
Definition at line 934 of file findTopCandidatesCudaInt.cpp.
float normpdf | ( | float | x, |
float | mu, | ||
float | sigma | ||
) |
Returns the PDF for a given x for the normal distribution given by mu and sigma.
x | The value for which the PDF should be calculated. |
mu | The mu of the normal distribution. |
sigma | The sigma of the normal distribution. |
Definition at line 920 of file findTopCandidatesCudaInt.cpp.
int releaseMemoryCuda | ( | int * | result | ) |
Free memory after result has been marshalled.
result | The result array. |
Definition at line 898 of file findTopCandidatesCudaInt.cpp.
float squared | ( | float | x | ) |
Returns the square for a given value x.
x | The value to be squared. |
Definition at line 909 of file findTopCandidatesCudaInt.cpp.
const int ENCODING_SIZE = MASS_RANGE * MASS_MULTIPLIER |
Definition at line 28 of file findTopCandidatesCudaInt.cpp.
const int MASS_MULTIPLIER = 100 |
Definition at line 27 of file findTopCandidatesCudaInt.cpp.
const int MASS_RANGE = 5000 |
Definition at line 26 of file findTopCandidatesCudaInt.cpp.
const double ONE_OVER_SQRT_PI = 0.39894228040143267793994605993438 |
Definition at line 30 of file findTopCandidatesCudaInt.cpp.
const float ROUNDING_ACCURACY = (float) INT8_MAX / 7.0f |
Definition at line 29 of file findTopCandidatesCudaInt.cpp.
const int versionFix = 1 |
Definition at line 14 of file findTopCandidatesCudaInt.cpp.
const int versionMajor = 1 |
Definition at line 12 of file findTopCandidatesCudaInt.cpp.
const int versionMinor = 5 |
Definition at line 13 of file findTopCandidatesCudaInt.cpp.