Skip to content

Commit

Permalink
Current design causes II violation in banding kernel under 250MHz. Lo…
Browse files Browse the repository at this point in the history
…sen it to 200MHz resolve the issue.
  • Loading branch information
ioeddk committed May 21, 2024
1 parent 1dd2dc5 commit 6259c85
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 36 deletions.
14 changes: 7 additions & 7 deletions kernels/banding_global_linear/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
#include <ap_fixed.h>
#include <hls_vector.h>

#define MAX_QUERY_LENGTH 16
#define MAX_REFERENCE_LENGTH 16
#define MAX_QUERY_LENGTH 256
#define MAX_REFERENCE_LENGTH 256

#define INPUT_QUERY_LENGTH 14
#define INPUT_REFERENCE_LENGTH 15
#define INPUT_QUERY_LENGTH 256
#define INPUT_REFERENCE_LENGTH 256

#define ALIGN_TYPE BandingGlobalLinear
#define N_BLOCKS 1
#define N_LAYERS 1
const int PE_NUM = 4;
const int PE_NUM = 5;
#define LAYER_MAXIMIUM 0 // We need to indicate from which layer (main matrix) is the maximum score stored.

#define BANDING FIXED
#define BANDWIDTH 3
#define BANDWIDTH 64

// Primitive Types
typedef ap_uint<2> char_t; // Sequence Alphabet
Expand All @@ -39,7 +39,7 @@ typedef ap_uint<2> tbp_t; // Traceback Pointer Type
#define TB_UP (tbp_t) 0b11

// Legacy Debugger Configuration
#define DEBUG_OUTPUT_FILE "/home/centos/workspace/banding/DP-HLS/banding_global_linear_out.txt"
#define DEBUG_OUTPUT_FILE "/home/centos/workspace/DP-HLS/banding_global_linear_out.txt"

struct Penalties {
type_t mismatch;
Expand Down
54 changes: 27 additions & 27 deletions src/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,15 +541,15 @@ void Align::Fixed::AlignStatic(

#ifdef CMAKEDEBUG
// print l_lims and u_lims
std::cout << "Lower limits: ";
for (int j = 0; j < MAX_QUERY_LENGTH; j++) {
std::cout << l_lims[j] << " ";
}
std::cout << endl << "Upper limits: ";
for (int j = 0; j < MAX_QUERY_LENGTH; j++) {
std::cout << u_lims[j] << " ";
}
std::cout << endl;
// std::cout << "Lower limits: ";
// for (int j = 0; j < MAX_QUERY_LENGTH; j++) {
// std::cout << l_lims[j] << " ";
// }
// std::cout << endl << "Upper limits: ";
// for (int j = 0; j < MAX_QUERY_LENGTH; j++) {
// std::cout << u_lims[j] << " ";
// }
// std::cout << endl;
#endif

// Declare and initialize maximum scores.
Expand Down Expand Up @@ -656,17 +656,17 @@ void Align::Fixed::ChunkCompute(
){

#ifdef CMAKEDEBUG
std::cout << "Started Chunk: " << ck_idx << std::endl;
// print local l lim and local u lim
std::cout << "Local Lower limits: ";
for (int j = 0; j < PE_NUM; j++) {
std::cout << local_l_lim[j] << " ";
}
std::cout << endl << "Local Upper limits: ";
for (int j = 0; j < PE_NUM; j++) {
std::cout << local_u_lim[j] << " ";
}
std::cout << endl;
// std::cout << "Started Chunk: " << ck_idx << std::endl;
// // print local l lim and local u lim
// std::cout << "Local Lower limits: ";
// for (int j = 0; j < PE_NUM; j++) {
// std::cout << local_l_lim[j] << " ";
// }
// std::cout << endl << "Local Upper limits: ";
// for (int j = 0; j < PE_NUM; j++) {
// std::cout << local_u_lim[j] << " ";
// }
// std::cout << endl;
#endif

bool predicate[PE_NUM];
Expand All @@ -688,7 +688,7 @@ void Align::Fixed::ChunkCompute(
const idx_t chunk_end_col = local_u_lim[PE_NUM - 1];

// Set the upper left corner cell of the chunk, depending whether it's the first chunk.
dp_mem[0][0] = local_l_lim[0] > 0 ? init_row_scr[local_l_lim[0]-1] : init_col_scr[0];
dp_mem[0][0] = local_l_lim[0] > 0 ? init_row_scr[chunk_start_col-1] : init_col_scr[0];

Iterating_Wavefronts:
for (int i = chunk_start_col; i < chunk_end_col + PE_NUM; i++)
Expand All @@ -709,12 +709,12 @@ void Align::Fixed::ChunkCompute(
Align::Fixed::MapPredicate(local_l_lim, local_u_lim, i, col_pred, predicate);
#ifdef CMAKEDEBUG
// print predicate
std::cout << "Predicate: ";
for (int j = 0; j < PE_NUM; j++)
{
std::cout << predicate[j];
}
std::cout << endl;
// std::cout << "Predicate: ";
// for (int j = 0; j < PE_NUM; j++)
// {
// std::cout << predicate[j];
// }
// std::cout << endl;
#endif

// Align::ShiftReference(local_reference, reference, i, chunk_end_col);
Expand Down
3 changes: 2 additions & 1 deletion src/pe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void PE::PEUnrollFixedSep(
for (int i = 0; i < PE_NUM; i++)
{
#pragma HLS unroll
// FIXME: I can probably fuse the predicate and feeding NINF logic here.
ALIGN_TYPE::PE::Compute(
qry[i],
ref[i],
Expand All @@ -108,6 +109,6 @@ void PE::PEUnrollFixedSep(
#endif
}
#ifdef CMAKEDEBUG
printf("\n");
// printf("\n");
#endif
}
6 changes: 5 additions & 1 deletion testbench/test_csim_banding_global_linear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "solutions.h"
#include "debug.h"

#define INPUT_QUERY_LENGTH 256
#define INPUT_REFERENCE_LENGTH 256

using namespace std;

char tbp_to_char(tbp_t tbp){
Expand Down Expand Up @@ -201,10 +204,11 @@ int main(){

// print out the scores
// print_matrix<float, MAX_QUERY_LENGTH, MAX_REFERENCE_LENGTH>(scores_sol[k], "Solution Score Matrix, Layer: " + std::to_string(k));
#ifdef CMAKEDEBUG
fprint_matrix<float, MAX_QUERY_LENGTH, MAX_REFERENCE_LENGTH>(debug_file, sol_score_mat[0], query_string, reference_string, "Solution Score Matrix, Layer: " + std::to_string(0));
fprint_matrix<float, MAX_QUERY_LENGTH, MAX_REFERENCE_LENGTH>(debug_file, debuggers->scores_cpp[0], query_string, reference_string, "Kernel Score Matrix, Layer: " + std::to_string(0));
// print traceback pointer matrices
fprint_matrix<char, MAX_QUERY_LENGTH, MAX_REFERENCE_LENGTH>(debug_file, sol_tb_mat, "Solution Traceback Matrix, Layer: " + std::to_string(0));
#endif
return 0;
}

0 comments on commit 6259c85

Please sign in to comment.