Skip to content

Commit

Permalink
Squashed 'solver' changes from 0736509..fac836c (#551)
Browse files Browse the repository at this point in the history
fac836c Merge pull request Xilinx#397 from changg/fix_sc_user_buf_issue
7f86b2a lower gesvj and gesvdj build frequency (Xilinx#404)
9b11338 add test cases to satisfy coverage check (Xilinx#402)
dd8ab1a update Makefile (Xilinx#399)
0529211 fix unmatch description.json and run_hls.tcl (Xilinx#403)
46f0291 add svd testcases to cover different datatype and arch (Xilinx#401)
6033f19 update doc (Xilinx#400)
d153696 lower frequency for vck190 (Xilinx#398)
89cc38c add case to test svd with ARCH=1 flow (Xilinx#396)
7a58a96 fix sc user buffer issue
5ad18c5 Fix cr 1125848 (Xilinx#395)
9086052 add explanation to geqrf's template parameter NCU (Xilinx#394)
161f512 add cases  (Xilinx#392)
bac2e95 remove email from Jenkinsfile:https://jira.xilinx.com/browse/CR-1124831 (Xilinx#390)
a895316 suggestions typo (Xilinx#393)
abab08c fix grammar typo (Xilinx#391)
273b291 add Cholesky testcase, modify code to support std::complex (Xilinx#385)
b0c1d47 Merge pull request Xilinx#389 from liyuanz/replace_cflags
0d5a187 replace cflags with clflags
2001c6f Merge pull request Xilinx#386 from liyuanz/replace_blacklist
ea458f7 update matrix_multiply.hpp (Xilinx#383)
44a3909 replace whiltelist/blacklist to allowlist/blocklist
46ccd80 Merge pull request Xilinx#379 from changg/fix_scs
73e3c2e fix sc mks
d6e0a2c Merge pull request Xilinx#374 from liyuanz/next
7616f08 Merge pull request Xilinx#378 from liyuanz/replace_targets
4607b3f update targes
1adbd01 update
7f9b575 update
37f3ccb update
279ef56 update makefile and utils.mk
bc80607 porting SVD (Xilinx#367)
4c04753 porting Qr inverse  (Xilinx#363)
9215286 Cholesky inverse (Xilinx#368)
d71e98e Merge pull request Xilinx#371 from changg/metadata
1e86aa2 draft metadata files
fe085e1 aws-support (Xilinx#366)
9138059 change qrf, from array based to stream based (Xilinx#364)
7d2f8ed porting QRF cleanup  (Xilinx#358)
d0a1d5b Porting QRF to solver (Xilinx#356)
ad53906 change 2021.2_stable_latest to 2022.1_stable_latest

Co-authored-by: sdausr <[email protected]>
  • Loading branch information
2 people authored and GitHub Enterprise committed Apr 13, 2022
1 parent 27ca72f commit 2a748c4
Show file tree
Hide file tree
Showing 702 changed files with 45,710 additions and 3,800 deletions.
2 changes: 1 addition & 1 deletion solver/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

VitisLibPipeline (branch: 'next', libname: 'xf_solver', TARGETS: 'hls_csim:hls_csynth:hls_cosim:vitis_sw_emu:vitis_hw_emu:vitis_hw_build',
upstream_dependencies: 'xf_utils_hw,next,../utils',
email: '[email protected]', devtest: 'RunDeploy.sh', TOOLVERSION: '2021.2_stable_latest')
devtest: 'RunDeploy.sh', TOOLVERSION: '2022.1_stable_latest')
365 changes: 365 additions & 0 deletions solver/L1/include/hw/back_substitute.hpp

Large diffs are not rendered by default.

731 changes: 731 additions & 0 deletions solver/L1/include/hw/cholesky.hpp

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions solver/L1/include/hw/cholesky_inverse.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
/*
* Copyright 2021 Xilinx, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file cholesky_inverse.hpp
* @brief This file contains Cholesky Inverse functions
* choleskyInverse: Entry point function
*/

#ifndef _XF_SOLVER_CHOLESKY_INVERSE_HPP_
#define _XF_SOLVER_CHOLESKY_INVERSE_HPP_

#include "ap_fixed.h"
#include "hls_x_complex.h"
#include "utils/std_complex_utils.h"
#include "utils/x_matrix_utils.hpp"
#include "hls_stream.h"

#include "cholesky.hpp"
#include "back_substitute.hpp"
#include "matrix_multiply.hpp"

namespace xf {
namespace solver {

// ===================================================================================================================
// Default traits struct defining the internal variable types for the Cholesky Inverse function
template <int RowsColsA, typename InputType, typename OutputType>
struct choleskyInverseTraits {
typedef InputType CHOLESKY_OUT;
typedef choleskyTraits<false, RowsColsA, InputType, InputType> CHOLESKY_TRAITS;
typedef InputType BACK_SUBSTITUTE_OUT;
typedef backSubstituteTraits<RowsColsA, InputType, InputType> BACK_SUBSTITUTE_TRAITS;
typedef matrixMultiplyTraits<NoTranspose,
ConjugateTranspose,
RowsColsA,
RowsColsA,
RowsColsA,
RowsColsA,
InputType,
OutputType>
MATRIX_MULTIPLY_TRAITS;
};

// Specialization for ap_fixed
template <int RowsColsA,
int W1,
int I1,
ap_q_mode Q1,
ap_o_mode O1,
int N1,
int W2,
int I2,
ap_q_mode Q2,
ap_o_mode O2,
int N2>
struct choleskyInverseTraits<RowsColsA, ap_fixed<W1, I1, Q1, O1, N1>, ap_fixed<W2, I2, Q2, O2, N2> > {
// Cholesky decomposition output precision
static const int CholeskyOutputW = W1;
static const int CholeskyOutputI = I1;
static const ap_q_mode CholeskyOutputQ = Q1;
static const ap_o_mode CholeskyOutputO = O1;
static const int CholeskyOutputN = N1;
typedef ap_fixed<CholeskyOutputW, CholeskyOutputI, CholeskyOutputQ, CholeskyOutputO, CholeskyOutputN> CHOLESKY_OUT;
typedef choleskyTraits<false, RowsColsA, ap_fixed<W1, I1, Q1, O1, N1>, CHOLESKY_OUT> CHOLESKY_TRAITS;
// Back substitution output precision
static const int BackSubstitutionOutW = W2;
static const int BackSubstitutionOutI = I2;
static const ap_q_mode BackSubstitutionOutQ = Q2;
static const ap_o_mode BackSubstitutionOutO = O2;
static const int BackSubstitutionOutN = N2;
typedef ap_fixed<BackSubstitutionOutW,
BackSubstitutionOutI,
BackSubstitutionOutQ,
BackSubstitutionOutO,
BackSubstitutionOutN>
BACK_SUBSTITUTE_OUT;
typedef backSubstituteTraits<RowsColsA, CHOLESKY_OUT, BACK_SUBSTITUTE_OUT> BACK_SUBSTITUTE_TRAITS;
typedef matrixMultiplyTraits<NoTranspose,
ConjugateTranspose,
RowsColsA,
RowsColsA,
RowsColsA,
RowsColsA,
BACK_SUBSTITUTE_OUT,
ap_fixed<W2, I2, Q2, O2, N2> >
MATRIX_MULTIPLY_TRAITS;
};

// Further specialization for hls::complex<ap_fixed>
template <int RowsColsA,
int W1,
int I1,
ap_q_mode Q1,
ap_o_mode O1,
int N1,
int W2,
int I2,
ap_q_mode Q2,
ap_o_mode O2,
int N2>
struct choleskyInverseTraits<RowsColsA,
hls::x_complex<ap_fixed<W1, I1, Q1, O1, N1> >,
hls::x_complex<ap_fixed<W2, I2, Q2, O2, N2> > > {
// Cholesky decomposition output precision
static const int CholeskyOutputW = W1;
static const int CholeskyOutputI = I1;
static const ap_q_mode CholeskyOutputQ = Q1;
static const ap_o_mode CholeskyOutputO = O1;
static const int CholeskyOutputN = N1;
typedef hls::x_complex<
ap_fixed<CholeskyOutputW, CholeskyOutputI, CholeskyOutputQ, CholeskyOutputO, CholeskyOutputN> >
CHOLESKY_OUT;
typedef choleskyTraits<false, RowsColsA, hls::x_complex<ap_fixed<W1, I1, Q1, O1, N1> >, CHOLESKY_OUT>
CHOLESKY_TRAITS;
// Back substitution output precision
static const int BackSubstitutionOutW = W2;
static const int BackSubstitutionOutI = I2;
static const ap_q_mode BackSubstitutionOutQ = Q2;
static const ap_o_mode BackSubstitutionOutO = O2;
static const int BackSubstitutionOutN = N2;
typedef hls::x_complex<ap_fixed<BackSubstitutionOutW,
BackSubstitutionOutI,
BackSubstitutionOutQ,
BackSubstitutionOutO,
BackSubstitutionOutN> >
BACK_SUBSTITUTE_OUT;
typedef backSubstituteTraits<RowsColsA, CHOLESKY_OUT, BACK_SUBSTITUTE_OUT> BACK_SUBSTITUTE_TRAITS;
typedef matrixMultiplyTraits<NoTranspose,
ConjugateTranspose,
RowsColsA,
RowsColsA,
RowsColsA,
RowsColsA,
BACK_SUBSTITUTE_OUT,
hls::x_complex<ap_fixed<W2, I2, Q2, O2, N2> > >
MATRIX_MULTIPLY_TRAITS;
};

/**
* @brief CHOLESKY_INVERSE
* @tparam RowsColsA Defines the matrix dimensions
* @tparam InputType Input data type
* @tparam OutputType Output data type
* @tparam CholeskyInverseTraits Traits class
*
* @param matrixAStrm Stream of Square Hermitian/symmetric positive definite input matrix
* @param matrixInverseAStrm Stream of Inverse of input matrix
* @param cholesky_success Indicates if matrix A was successfully inverted. 0 = Success. 1 = Failure.
*/
template <int RowsColsA,
typename InputType,
typename OutputType,
typename CholeskyInverseTraits = choleskyInverseTraits<RowsColsA, InputType, OutputType> >
void choleskyInverse(hls::stream<InputType>& matrixAStrm,
hls::stream<OutputType>& matrixInverseAStrm,
int& cholesky_success) {
#pragma HLS DATAFLOW
hls::stream<typename CholeskyInverseTraits::CHOLESKY_OUT> matrixUStrm;
#pragma HLS STREAM variable = matrixUStrm depth = 16
hls::stream<typename CholeskyInverseTraits::BACK_SUBSTITUTE_OUT> matrixInverseUStrm;
#pragma HLS STREAM variable = matrixInverseUStrm depth = 16
int U_singular;

// Run Cholesky, get upper-triangular result
const bool LOWER_TRIANGULAR = false;
cholesky_success = cholesky<LOWER_TRIANGULAR, RowsColsA, InputType, typename CholeskyInverseTraits::CHOLESKY_OUT,
typename CholeskyInverseTraits::CHOLESKY_TRAITS>(matrixAStrm, matrixUStrm);

// Run back-substitution to compute U^-1
// This doesn't work in-place, so use an additional array InverseU
backSubstitute<RowsColsA, typename CholeskyInverseTraits::CHOLESKY_OUT,
typename CholeskyInverseTraits::BACK_SUBSTITUTE_OUT,
typename CholeskyInverseTraits::BACK_SUBSTITUTE_TRAITS>(matrixUStrm, matrixInverseUStrm, U_singular);
// A^-1 = U^-1*U^-t (equivalent to L-t*L-1)
matrixMultiply<NoTranspose, ConjugateTranspose, RowsColsA, RowsColsA, RowsColsA, RowsColsA,
typename CholeskyInverseTraits::BACK_SUBSTITUTE_OUT, OutputType,
typename CholeskyInverseTraits::MATRIX_MULTIPLY_TRAITS>(matrixInverseUStrm, matrixInverseAStrm);
}

} // end namespace solver
} // end namespace xf

#endif
Loading

0 comments on commit 2a748c4

Please sign in to comment.