XT-neighbor
Functions | Variables
xtn_inner.cu File Reference

The core algorithm on the high-level abstraction concerning data manupulation operations in all 4 stream. More...

#include "generate_combination.cu"
#include "cub.cu"
#include "kernel.cu"
#include "codec.cu"
#include "stream.cu"
#include <limits.h>

Functions

int NUM_BLOCK (int len)
 private function. More...
 
int cal_offsets (Int3 *inputKeys, int *&inputOffsets, int *&outputLengths, int n, int *buffer)
 private function. More...
 
int cal_offsets_lowerbound (Int3 *inputKeys, int *inputValues, int *&inputOffsets, int *&outputLengths, int lowerbound, int n, int *buffer)
 private function. More...
 
int gen_pairs (int *input, int *inputOffsets, int *outputLengths, Int2 *&output, int *&lesserIndex, int lowerbound, int carry, int n, int seqLen)
 private function. More...
 
int gen_smaller_index (int *input, int *inputOffsets, int *outputLengths, int *&output, int carry, int n)
 private function. More...
 
int deduplicate (Int2 *input, Int2 *output, int n, int *buffer)
 private function. More...
 
int postprocessing (char *allStr, unsigned int *allStrOffsets, Int2 *uniquePairs, int distance, char measure, Int2 *&pairOutput, char *&distanceOutput, int uniqueLen, int *buffer, int seqLen)
 private function. More...
 
void make_output (Int2 *pairOut, char *distanceOut, int len, XTNOutput &output)
 private function. More...
 
void gen_next_chunk (Chunk< Int3 > &keyInOut, Chunk< int > &valueInOut, int *valueOffsets, int offsetLen, int lowerbound, int *buffer)
 private function. More...
 
int solve_next_bin (int *chunksizes, int start, int maxSize, int n)
 solve bin packing on spot when precalculation is impossible. More...
 
int solve_bin_packing_lowerbounds (int *histograms, int *&lowerboundsOutput, int n, int seqLen, int *buffer, MemoryContext ctx)
 solve bin packing for lower bound calculation. More...
 
int solve_bin_packing_offsets (int *histograms, int **&offsetOutput, int n, int *buffer, MemoryContext ctx)
 solve bin packing for 2 dimensional buffer. More...
 
void stream_handler1 (Chunk< Int3 > input, Int3 *&deletionsOutput, int *&indexOutput, std::vector< int *> &histogramOutput, int &outputLen, int distance, int &carry, MemoryContext ctx)
 handle all GPU operations in stream 1. More...
 
void stream_handler2 (Chunk< Int3 > &keyInOut, Chunk< int > &valueInOut, std::vector< int *> &histogramOutput, size_t &throughput2B, int distance, int seqLen, int *buffer, MemoryContext ctx)
 handle all GPU operations in stream 2. More...
 
void stream_handler3 (Chunk< Int3 > &keyInOut, Chunk< int > &valueInOut, void callback(Int2 *, int), std::vector< int *> &histogramOutput, int lowerbound, int seqLen, int *buffer, MemoryContext ctx)
 handle all GPU operations in stream 3. More...
 
void stream_handler4_nn (Chunk< Int2 > pairInput, XTNOutput &output, char *allStr, unsigned int *allStrOffsets, int seqLen, int distance, char measure, int *buffer)
 handle all GPU operations in stream 4 nn mode. More...
 
void convertString (char *allStr, unsigned int *allStrOffsets, Int3 *output, int seqLen)
 convert all sequences to int3 form More...
 

Variables

const int NUM_THREADS = 256
 
const unsigned int UINT_MIN = 0
 

Detailed Description

The core algorithm on the high-level abstraction concerning data manupulation operations in all 4 stream.

Function Documentation

◆ cal_offsets()

int cal_offsets ( Int3 inputKeys,
int *&  inputOffsets,
int *&  outputLengths,
int  n,
int *  buffer 
)

private function.

◆ cal_offsets_lowerbound()

int cal_offsets_lowerbound ( Int3 inputKeys,
int *  inputValues,
int *&  inputOffsets,
int *&  outputLengths,
int  lowerbound,
int  n,
int *  buffer 
)

private function.

◆ convertString()

void convertString ( char *  allStr,
unsigned int *  allStrOffsets,
Int3 output,
int  seqLen 
)

convert all sequences to int3 form

Parameters
allStrall CDR3 sequences
allStrOffsetsoffset of CDR3 sequences
outputsequence outputs
seqLennumber of input CDR3 sequences

◆ deduplicate()

int deduplicate ( Int2 input,
Int2 output,
int  n,
int *  buffer 
)

private function.

◆ gen_next_chunk()

void gen_next_chunk ( Chunk< Int3 > &  keyInOut,
Chunk< int > &  valueInOut,
int *  valueOffsets,
int  offsetLen,
int  lowerbound,
int *  buffer 
)

private function.

◆ gen_pairs()

int gen_pairs ( int *  input,
int *  inputOffsets,
int *  outputLengths,
Int2 *&  output,
int *&  lesserIndex,
int  lowerbound,
int  carry,
int  n,
int  seqLen 
)

private function.

◆ gen_smaller_index()

int gen_smaller_index ( int *  input,
int *  inputOffsets,
int *  outputLengths,
int *&  output,
int  carry,
int  n 
)

private function.

◆ make_output()

void make_output ( Int2 pairOut,
char *  distanceOut,
int  len,
XTNOutput output 
)

private function.

◆ NUM_BLOCK()

int NUM_BLOCK ( int  len)

private function.

◆ postprocessing()

int postprocessing ( char *  allStr,
unsigned int *  allStrOffsets,
Int2 uniquePairs,
int  distance,
char  measure,
Int2 *&  pairOutput,
char *&  distanceOutput,
int  uniqueLen,
int *  buffer,
int  seqLen 
)

private function.

◆ solve_bin_packing_lowerbounds()

int solve_bin_packing_lowerbounds ( int *  histograms,
int *&  lowerboundsOutput,
int  n,
int  seqLen,
int *  buffer,
MemoryContext  ctx 
)

solve bin packing for lower bound calculation.

Parameters
histogramsflatten histogram matrix
lowerboundsOutputoutput assignment
nrow count of histograms
seqLenarray length of sequences
bufferreusable 4-byte buffer
ctxmemory constraints and info
Returns
the length of lowerboundsOutput array

◆ solve_bin_packing_offsets()

int solve_bin_packing_offsets ( int *  histograms,
int **&  offsetOutput,
int  n,
int *  buffer,
MemoryContext  ctx 
)

solve bin packing for 2 dimensional buffer.

Parameters
histogramsflatten histogram matrix
offsetOutputoutput assignment
nrow count of histograms
bufferreusable 4-byte buffer
ctxmemory constraints and info
Returns
the second dimension of offsetOutput matrix

◆ solve_next_bin()

int solve_next_bin ( int *  chunksizes,
int  start,
int  maxSize,
int  n 
)

solve bin packing on spot when precalculation is impossible.

Parameters
chunksizesarray of chunk sizes
startoffset of the latest processed chunk
maxSizebin size
narray length of chunkSizes
Returns
the number of chunks to process

◆ stream_handler1()

void stream_handler1 ( Chunk< Int3 input,
Int3 *&  deletionsOutput,
int *&  indexOutput,
std::vector< int *> &  histogramOutput,
int &  outputLen,
int  distance,
int &  carry,
MemoryContext  ctx 
)

handle all GPU operations in stream 1.

Parameters
inputinput CDR3 sequences
deletionsOutputgenerated deletion forms of CDR3 sequence
indexOutputoriginal index of each deletion forms
histogramOutputhistogram of deletion forms
outputLennumber of output deletion forms
distancedistance threshold
carryindex offset of the chunk
ctxmemory context

◆ stream_handler2()

void stream_handler2 ( Chunk< Int3 > &  keyInOut,
Chunk< int > &  valueInOut,
std::vector< int *> &  histogramOutput,
size_t &  throughput2B,
int  distance,
int  seqLen,
int *  buffer,
MemoryContext  ctx 
)

handle all GPU operations in stream 2.

Parameters
keyInOutdeletion forms of CDR3 sequence
valueInOutindex of each deletion forms
histogramOutputhistogram of indexes
throughput2Bthroughput counting variable
distancedistance threshold
seqLennumber of input CDR3 sequences
bufferinteger buffer
ctxmemory context

◆ stream_handler3()

void stream_handler3 ( Chunk< Int3 > &  keyInOut,
Chunk< int > &  valueInOut,
void   callbackInt2 *, int,
std::vector< int *> &  histogramOutput,
int  lowerbound,
int  seqLen,
int *  buffer,
MemoryContext  ctx 
)

handle all GPU operations in stream 3.

Parameters
keyInOutdeletion forms of CDR3 sequence
valueInOutindex of each deletion forms
callbackpair outputs
histogramOutputhistogram of generating pairs
lowerboundbound of generating pairs
seqLennumber of input CDR3 sequences
bufferinteger buffer
ctxmemory context

◆ stream_handler4_nn()

void stream_handler4_nn ( Chunk< Int2 pairInput,
XTNOutput output,
char *  allStr,
unsigned int *  allStrOffsets,
int  seqLen,
int  distance,
char  measure,
int *  buffer 
)

handle all GPU operations in stream 4 nn mode.

Parameters
pairInputnearest neighbor pairs
outputreturning output
allStrall CDR3 sequences
allStrOffsetsoffset of CDR3 sequences
seqLennumber of input CDR3 sequences
distancedistance threshold
measuretype of measurement (levenshtein/hamming)
bufferinteger buffer

Variable Documentation

◆ NUM_THREADS

const int NUM_THREADS = 256

◆ UINT_MIN

const unsigned int UINT_MIN = 0