41void parse_options(
int argc,
const char *argv[], po::options_description &desc,
42 po::variables_map &vm);
48 int verbosity, std::string xclbinFileName,
49 std::string kernelNameInXclbin);
51static inline std::int16_t random_int16_t(int32_t range = 0x10000) {
52 return (std::int16_t)rand() % range;
55static inline std::int32_t random_int32_t(int32_t range = 0x10000) {
56 return (std::int32_t)rand() % range;
59#if defined(__STDCPP_BFLOAT16_T__)
60static inline std::bfloat16_t random_bfloat16_t(std::bfloat16_t scale,
61 std::bfloat16_t bias) {
62 return std::bfloat16_t((scale * (
float)rand() / (
float)(RAND_MAX)) + bias);
66bool nearly_equal(
float a,
float b,
float epsilon = 128 * FLT_EPSILON,
67 float abs_th = FLT_MIN);
71 int n_printable_rows = 10,
int n_printable_cols = 10,
72 std::ostream &ostream = std::cout,
73 const char col_sep[] =
" ",
const char elide_sym[] =
" ... ",
75 assert(matrix.size() % n_cols == 0);
77 auto maxima = std::minmax_element(matrix.begin(), matrix.end());
78 T max_val = std::max(*maxima.first, std::abs(*maxima.second));
79 size_t n_digits = log10(max_val);
83 int n_rows = matrix.size() / n_cols;
85 n_printable_rows = std::min(n_rows, n_printable_rows);
86 n_printable_cols = std::min(n_cols, n_printable_cols);
88 const bool elide_rows = n_printable_rows < n_rows;
89 const bool elide_cols = n_printable_cols < n_cols;
91 if (elide_rows || elide_cols) {
92 w = std::max((
int)w, (
int)strlen(elide_sym));
96 ostream << std::fixed << std::setprecision(2);
98#define print_row(what) \
99 for (int col = 0; col < n_printable_cols / 2; col++) { \
100 ostream << std::right << std::setw(w) << (what); \
101 ostream << std::setw(0) << col_sep; \
104 ostream << std::setw(0) << elide_sym; \
106 for (int col = n_printable_cols / 2 + 1; col < n_printable_cols; col++) { \
107 ostream << std::right << std::setw(w) << (what); \
108 ostream << std::setw(0) << col_sep; \
111 for (
int row = 0; row < n_printable_rows / 2; row++) {
113 ostream << std::endl;
117 ostream << std::endl;
119 for (
int row = n_printable_rows / 2 + 1; row < n_printable_rows; row++) {
121 ostream << std::endl;
127void write_out_trace(
char *traceOutPtr,
size_t trace_size, std::string path);
void print_matrix(const std::vector< T > matrix, int n_cols, int n_printable_rows=10, int n_printable_cols=10, std::ostream &ostream=std::cout, const char col_sep[]=" ", const char elide_sym[]=" ... ", int w=-1)