16 #include <hls_vector.h>
17 #include <hls_stream.h>
45 char_t (&query)[MAX_QUERY_LENGTH],
46 char_t (&local_query)[PE_NUM],
51 stream_of_blocks<dp_mem_block_t> &dp_mem_out);
72 template <
int PE_NUM_T>
74 const char_t (&query)[MAX_QUERY_LENGTH],
75 char_t (&local_query)[PE_NUM_T],
78 bool (&col_pred)[PE_NUM],
const idx_t local_query_len,
81 init_col_scr_local[0] = init_col_scr_local[PE_NUM_T];
82 for (
int i = 0; i < PE_NUM_T; i++)
84 init_col_scr_local[i + 1] = init_col_scr[idx + i];
85 local_query[i] = query[idx + i];
86 col_pred[i] = i < local_query_len;
100 void InitializeChunkCoordinates(idx_t chunk_row_offset, idx_t chunk_col_offset, hls::vector<idx_t, PE_NUM> &ic, hls::vector<idx_t, PE_NUM> &jc);
112 const idx_t &p_col_offset,
113 const bool (&predicate)[PE_NUM],
114 tbp_t (&chunk_tbp_out)[PE_NUM][TBMEM_SIZE]);
123 void ShiftPredicate(
bool (&predicate)[PE_NUM],
int idx,
int query_len,
int reference_len);
133 char_t (&local_reference)[PE_NUM],
const char_t (&reference)[MAX_REFERENCE_LENGTH],
134 int idx,
int ref_len);
144 score_vec_t (&preserved_row_scr)[MAX_REFERENCE_LENGTH],
146 const bool predicate_pe_last,
182 namespace Rectangular
194 const char_t (&querys)[MAX_QUERY_LENGTH],
195 const char_t (&references)[MAX_REFERENCE_LENGTH],
196 const idx_t query_length,
197 const idx_t reference_length,
198 const Penalties &penalties,
199 #ifdef LOCAL_TRANSITION_MATRIX
200 const type_t (&transitions)[TRANSITION_MATRIX_SIZE][TRANSITION_MATRIX_SIZE],
202 idx_t &tb_i, idx_t &tb_j
204 ,
tbr_t (&tb_out)[MAX_REFERENCE_LENGTH + MAX_QUERY_LENGTH]
225 idx_t chunk_row_offset,
227 const char_t (&reference)[MAX_REFERENCE_LENGTH],
230 idx_t &p_col_offset, idx_t ck_idx,
231 idx_t global_query_length, idx_t query_length, idx_t reference_length,
232 const bool (&col_pred)[PE_NUM],
233 const Penalties &penalties,
234 #ifdef LOCAL_TRANSITION_MATRIX
235 const type_t (&transitions)[PE_NUM][TRANSITION_MATRIX_SIZE][TRANSITION_MATRIX_SIZE],
239 , tbp_t (&chunk_tbp_out)[PE_NUM][TBMEM_SIZE]
256 const idx_t wavefront,
257 const idx_t ref_len,
const idx_t qry_len,
258 bool (&row_pred)[PE_NUM],
259 const bool (&col_pred)[PE_NUM],
260 bool (&pred)[PE_NUM]);
279 const char_t (&querys)[MAX_QUERY_LENGTH],
280 const char_t (&references)[MAX_REFERENCE_LENGTH],
281 const idx_t query_length,
282 const idx_t reference_length,
283 const Penalties &penalties,
284 #ifdef LOCAL_TRANSITION_MATRIX
285 const type_t (&transitions)[TRANSITION_MATRIX_SIZE][TRANSITION_MATRIX_SIZE],
287 idx_t &tb_i, idx_t &tb_j
289 ,
tbr_t (&tb_out)[MAX_REFERENCE_LENGTH + MAX_QUERY_LENGTH]
310 const idx_t chunk_row_offset,
312 const char_t (&reference)[MAX_REFERENCE_LENGTH],
315 idx_t p_cols,
const idx_t ck_idx,
316 idx_t &l_lim_reg, idx_t &u_lim_reg,
317 const bool (&col_pred)[PE_NUM],
318 const idx_t global_query_length,
const idx_t local_query_length,
const idx_t reference_length,
319 const Penalties &penalties,
320 #ifdef LOCAL_TRANSITION_MATRIX
321 const type_t (&transitions)[PE_NUM][TRANSITION_MATRIX_SIZE][TRANSITION_MATRIX_SIZE],
325 , tbp_t (&chunk_tbp_out)[PE_NUM][TBMEM_SIZE]
343 const idx_t (&local_l_lim)[PE_NUM],
const idx_t (&local_u_lim)[PE_NUM],
344 const idx_t (&virtual_cols)[PE_NUM],
const bool (&col_pred)[PE_NUM],
345 bool (&predicate)[PE_NUM]);
347 template <
int PE_NUM_,
int MAX_QUERY_LENGTH_>
349 const char_t (&query)[MAX_QUERY_LENGTH_],
350 const score_vec_t (&init_col_scr)[MAX_QUERY_LENGTH_],
351 char_t (&local_query)[PE_NUM_],
353 bool (&col_pred)[PE_NUM_],
const idx_t local_query_len,
356 FixedBandingPrepareChunkLocals:
357 init_col_scr_local[0] = init_col_scr_local[PE_NUM_];
358 for (
int i = 0; i < PE_NUM_; i++)
360 init_col_scr_local[i + 1] = init_col_scr[idx + i];
361 local_query[i] = query[idx + i];
362 col_pred[i] = i < local_query_len;
377 const Penalties &penalties);
381 void UpdatePEOffset(idx_t (&pe_offset)[PE_NUM],
bool (&predicate)[PE_NUM]);
393 const score_vec_t (&init_row_scr)[MAX_REFERENCE_LENGTH]);
396 #endif // !SEQ_ALIGN_H
void ArrangeTBP(const tbp_vec_t &tbp_in, const idx_t &p_col_offset, const bool(&predicate)[PE_NUM], tbp_t(&chunk_tbp_out)[PE_NUM][TBMEM_SIZE])
hls::vector< type_t, N_LAYERS > score_vec_t
Vector of scores, used to store the scores of each layer in the same coordiante in the DP matrix...
Definition: dp_hls_common.h:31
A structure to hold score and index information.
Definition: dp_hls_common.h:46
Declaration of types used by DP-HLS internally, referred from the user defined params.h file.
score_vec_t chunk_col_scores_inf_t[PE_NUM+1]
Definition: dp_hls_common.h:88
void ShiftPredicate(bool(&predicate)[PE_NUM], int idx, int query_len, int reference_len)
Determine the predicate values by constantantly shifting the predicate array with truth values...
score_vec_t wavefront_scores_t[PE_NUM]
Definition: dp_hls_common.h:85
void UpdatePEOffset(idx_t(&pe_offset)[PE_NUM], bool(&predicate)[PE_NUM])
void AlignStatic(const char_t(&querys)[MAX_QUERY_LENGTH], const char_t(&references)[MAX_REFERENCE_LENGTH], const idx_t query_length, const idx_t reference_length, const Penalties &penalties, idx_t &tb_i, idx_t &tb_j, tbr_t(&tb_out)[MAX_REFERENCE_LENGTH+MAX_QUERY_LENGTH])
Perform Pairwise alignment for two sequences in rectangular grid, with virtual coordinates.
void PrepareScoreBuffer(score_vec_t(&score_buff)[PE_NUM+1], const idx_t i, const chunk_col_scores_inf_t(&init_col_scr), const score_vec_t(&init_row_scr)[MAX_REFERENCE_LENGTH])
void ReductionMaxScores(ScorePack(&max)[PE_NUM], ScorePack &chunk_max, idx_t &max_pe)
Compare the local maximum of each PE after the score computation and keep the global maximum score...
void PrepareLocalQuery(char_t(&query)[MAX_QUERY_LENGTH], char_t(&local_query)[PE_NUM], const idx_t offset)
At beginning of the computation of each strip, it copy a PE_NUM number of the global query characters...
char_t input_char_block_t[PE_NUM]
Definition: dp_hls_common.h:91
void CopyColScore(chunk_col_scores_inf_t &init_col_scr_local, score_vec_t(&init_col_scr)[MAX_QUERY_LENGTH], idx_t i)
void ShiftReference(char_t(&local_reference)[PE_NUM], const char_t(&reference)[MAX_REFERENCE_LENGTH], int idx, int ref_len)
Shift into the local reference buffer a new reference element, given current wavefront index and refe...
void InitializeScores(score_vec_t(&init_col_scr)[MAX_QUERY_LENGTH], score_vec_t(&init_row_scr)[MAX_REFERENCE_LENGTH], const Penalties &penalties)
Initialize initial scores for the first column and row on the device.
void UpdateDPMemShift(dp_mem_block_t &dp_mem)
void MapPredicate(const idx_t wavefront, const idx_t ref_len, const idx_t qry_len, bool(&row_pred)[PE_NUM], const bool(&col_pred)[PE_NUM], bool(&pred)[PE_NUM])
Logics to map the global coordinates of a wavefront of PE to their prediate values. MapPredicateSquare is a function F: (pe_row: int, pe_col: int) -> (predicate_balue: boolean) It's unrolled for PE_NUM applying to each PE.
score_vec_t dp_mem_block_t[PE_NUM+1][2]
Definition: dp_hls_common.h:87
void UpdateDPMemSep(score_vec_t(&dp_mem)[PE_NUM+1][2], score_vec_t(&score_in)[PE_NUM+1])
void InitializeChunkCoordinates(idx_t chunk_row_offset, idx_t chunk_col_offset, hls::vector< idx_t, PE_NUM > &ic, hls::vector< idx_t, PE_NUM > &jc)
Initialize two lists of coordinates, x coordinate and y coordinate, for each chunk. Theis function is called within the chunk compute function. This is especially useful if the chunk doesn't start at the beginning, i.e. after chunk column offset is developed.
void PrepareLocals(const char_t(&query)[MAX_QUERY_LENGTH], char_t(&local_query)[PE_NUM_T], score_vec_t(&init_col_scr)[MAX_QUERY_LENGTH], chunk_col_scores_inf_t &init_col_scr_local, bool(&col_pred)[PE_NUM], const idx_t local_query_len, const idx_t idx)
This function merge PrepareLocalQuery function and CopyColScore function into one, where CopyColScore is a function to copy a column of initial scores from the global buffer to each PE's local buffer before the computation of each chunk.
Definition: align.h:73
void PreserveRowScore(score_vec_t(&preserved_row_scr)[MAX_REFERENCE_LENGTH], const score_vec_t score_vec, const bool predicate_pe_last, const idx_t idx)
Write the last PE's output score to the preserved_row_score buffer to be used in the next chunk...
void PrepareScoresArr(dp_mem_block_t &dp_mem_in, score_vec_t(&init_col_scr)[PE_NUM], int id, score_vec_t(&last_chunk_scr)[2], wavefront_scores_t &up_out, wavefront_scores_t &diag_out, wavefront_scores_t &left_out)
void UpdateDPMem(dp_mem_block_t &dp_mem, idx_t i, chunk_col_scores_inf_t &init_col_scr, score_vec_t(&init_row_scr)[MAX_REFERENCE_LENGTH])
Updated the content of the DP Memory with the new scores. It saparates the step of shifting and setti...
void ChunkMax(ScorePack &max, ScorePack new_scr)
void ChunkCompute(idx_t chunk_row_offset, input_char_block_t &query, const char_t(&reference)[MAX_REFERENCE_LENGTH], chunk_col_scores_inf_t &init_col_scr, score_vec_t(&init_row_scr)[MAX_REFERENCE_LENGTH], idx_t &p_col_offset, idx_t ck_idx, idx_t global_query_length, idx_t query_length, idx_t reference_length, const bool(&col_pred)[PE_NUM], const Penalties &penalties, ScorePack(&max)[PE_NUM], tbp_t(&chunk_tbp_out)[PE_NUM][TBMEM_SIZE])
Compute the traceback pointers for a chunk of the size PE_NUM * REFERENCE_LENGTH, with rectangular gr...
tbp_t tbp_vec_t[PE_NUM]
Definition: dp_hls_common.h:90
void InitializeChunkColScore(score_vec_t(&init_col_scr)[PE_NUM], stream_of_blocks< dp_mem_block_t > &dp_mem_out)
ap_uint< 3 > tbr_t
Definition: dp_hls_common.h:94
void UpdateDPMemSet(dp_mem_block_t &dp_mem, idx_t i, chunk_col_scores_inf_t &init_col_scr, score_vec_t(&init_row_scr)[MAX_REFERENCE_LENGTH])