Skip to content

Commit

Permalink
format files
Browse files Browse the repository at this point in the history
  • Loading branch information
lisal2023 committed Jan 8, 2020
1 parent bf1c08d commit 888dd95
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 34 deletions.
38 changes: 15 additions & 23 deletions L1/include/hw/xf_blas/helpers/utils/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,46 +382,38 @@ inline double BitConv<double>::toType(BitConv<double>::BitsType p_Val) {
return (u.f);
}

template <
unsigned int t_Bits,
unsigned int t_Width,
typename t_DataType>
ap_uint<t_Bits> convWideVal2Bits (
WideType<t_DataType, t_Width> p_val){
template <unsigned int t_Bits, unsigned int t_Width, typename t_DataType>
ap_uint<t_Bits> convWideVal2Bits(WideType<t_DataType, t_Width> p_val) {
#pragma HLS inline
#ifndef __SYNTHESIS__
assert ((t_Bits>t_Width) && (t_Bits%t_Width == 0));
#endif
const unsigned int t_DataBits = sizeof(t_DataType)*8;
#ifndef __SYNTHESIS__
assert((t_Bits > t_Width) && (t_Bits % t_Width == 0));
#endif
const unsigned int t_DataBits = sizeof(t_DataType) * 8;
const unsigned int t_ResEntryBits = t_Bits / t_Width;
ap_uint<t_Bits> l_res;
for (unsigned int i=0; i<t_Width; ++i) {
for (unsigned int i = 0; i < t_Width; ++i) {
#pragma HLS UNROLL
BitConv<t_DataType> l_bitConv;
ap_uint<t_DataBits> l_datBits = l_bitConv.toBits(p_val[i]);
ap_uint<t_ResEntryBits> l_resEntry = l_datBits;
l_res.range((i+1)*t_ResEntryBits-1, i*t_ResEntryBits) = l_resEntry;
l_res.range((i + 1) * t_ResEntryBits - 1, i * t_ResEntryBits) = l_resEntry;
}
return l_res;
}

template <
unsigned int t_Bits,
unsigned int t_Width,
typename t_DataType>
WideType<t_DataType, t_Width> convBits2WideType (
ap_uint<t_Bits> p_bits){
template <unsigned int t_Bits, unsigned int t_Width, typename t_DataType>
WideType<t_DataType, t_Width> convBits2WideType(ap_uint<t_Bits> p_bits) {
#pragma HLS inline
#ifndef __SYNTHESIS__
assert ((t_Bits>t_Width) && (t_Bits%t_Width == 0));
#endif
#ifndef __SYNTHESIS__
assert((t_Bits > t_Width) && (t_Bits % t_Width == 0));
#endif
const unsigned int t_DataBits = sizeof(t_DataType) * 8;
const unsigned int t_InEntryBits = t_Bits / t_Width;
WideType<t_DataType, t_Width> l_res;
for (unsigned int i=0; i<t_Width; ++i) {
for (unsigned int i = 0; i < t_Width; ++i) {
#pragma HLS UNROLL
BitConv<t_DataType> l_bitConv;
ap_uint<t_InEntryBits> l_inDatBits = p_bits.range((i+1)*t_InEntryBits-1, i*t_InEntryBits);
ap_uint<t_InEntryBits> l_inDatBits = p_bits.range((i + 1) * t_InEntryBits - 1, i * t_InEntryBits);
ap_uint<t_DataBits> l_datBits = l_inDatBits;
t_DataType l_val = l_bitConv.toType(l_datBits);
l_res[i] = l_val;
Expand Down
6 changes: 1 addition & 5 deletions L3/benchmarks/gemm/gemm_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ int main(int argc, char** argv) {
#endif
}


int i, j; // i-row l_numKernel -1 ,j- column l_numKernel -1

vector<XFBLAS_dataType*> goldenC;
Expand Down Expand Up @@ -147,7 +146,6 @@ int main(int argc, char** argv) {
c[kernelIndex], n, kernelIndex);
}


#ifdef XFBLAS_LAUNCH_ASYNC
for (int kernelIndex = 0; kernelIndex < l_numKernel; kernelIndex++) {
xfblasGetMatrixRestrictedAsync(c[kernelIndex], kernelIndex);
Expand All @@ -159,7 +157,6 @@ int main(int argc, char** argv) {
status = xfblasGetMatrixRestricted(c[kernelIndex], kernelIndex);
}
#endif


showTimeData("copyFromFpga", l_tp_loop[l_tpIdx], l_tp_loop[l_tpIdx + 1]);
l_tpIdx++;
Expand All @@ -170,7 +167,6 @@ int main(int argc, char** argv) {
memcpy(tmp_c, c[kernelIndex], m * n * sizeof(XFBLAS_dataType));
resultC.push_back(tmp_c);
}


for (int kernelIndex = 0; kernelIndex < l_numKernel; kernelIndex++) {
xfblasFree(a[kernelIndex], kernelIndex);
Expand All @@ -188,7 +184,7 @@ int main(int argc, char** argv) {
a.clear();
b.clear();
c.clear();

chrono::duration<double> l_timeApi = l_timeApiSum;
double l_timeMs = l_timeApi.count() * 1e3;

Expand Down
7 changes: 3 additions & 4 deletions L3/benchmarks/gemm/gemm_mkl/gemm_mkl_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ XFBLAS_dataType* createMat(int p_rows, int p_cols, bool is_zero = false) {

void initMat(XFBLAS_dataType* mat, int p_rows, int p_cols, bool is_zero) {
srand(time(NULL));
for (int j = 0; j < p_rows; j++){
for (int i = 0; i < p_cols; i++){
mat[IDX2R(j, i, p_cols)] = 1;

for (int j = 0; j < p_rows; j++) {
for (int i = 0; i < p_cols; i++) {
mat[IDX2R(j, i, p_cols)] = 1;
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions L3/include/sw/xf_blas/helpers/funcs/fcn_host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class FCNHost : public BLASHost {

return XFBLAS_STATUS_SUCCESS;
}

virtual xfblasStatus_t addFCNOpByAddress(unsigned int l_aOff,
unsigned int l_bOff,
unsigned int l_cOff,
Expand All @@ -145,7 +145,6 @@ class FCNHost : public BLASHost {
int p_postShift,
short p_preluScale,
short p_preluAlpha) {

FcnArgs args(l_aOff, l_bOff, l_cOff, l_xOff, p_m, p_k, p_n, p_lda, p_ldb, p_ldc, p_ldx, p_postScale,
p_postShift, p_preluScale, p_preluAlpha);
this->addInstr(&args);
Expand Down

0 comments on commit 888dd95

Please sign in to comment.