├── ISPD16.md ├── ISPD17.md ├── LICENSE ├── README.md ├── src ├── Makefile ├── alg │ ├── Eigen │ │ ├── CMakeLists.txt │ │ ├── Cholesky │ │ ├── CholmodSupport │ │ ├── Core │ │ ├── Dense │ │ ├── Eigen │ │ ├── Eigenvalues │ │ ├── Geometry │ │ ├── Householder │ │ ├── IterativeLinearSolvers │ │ ├── Jacobi │ │ ├── LU │ │ ├── MetisSupport │ │ ├── OrderingMethods │ │ ├── PaStiXSupport │ │ ├── PardisoSupport │ │ ├── QR │ │ ├── QtAlignedMalloc │ │ ├── SPQRSupport │ │ ├── SVD │ │ ├── Sparse │ │ ├── SparseCholesky │ │ ├── SparseCore │ │ ├── SparseLU │ │ ├── SparseQR │ │ ├── StdDeque │ │ ├── StdList │ │ ├── StdVector │ │ ├── SuperLUSupport │ │ ├── UmfPackSupport │ │ └── src │ │ │ ├── Cholesky │ │ │ ├── LDLT.h │ │ │ ├── LLT.h │ │ │ └── LLT_LAPACKE.h │ │ │ ├── CholmodSupport │ │ │ └── CholmodSupport.h │ │ │ ├── Core │ │ │ ├── Array.h │ │ │ ├── ArrayBase.h │ │ │ ├── ArrayWrapper.h │ │ │ ├── Assign.h │ │ │ ├── AssignEvaluator.h │ │ │ ├── Assign_MKL.h │ │ │ ├── BandMatrix.h │ │ │ ├── Block.h │ │ │ ├── BooleanRedux.h │ │ │ ├── CommaInitializer.h │ │ │ ├── ConditionEstimator.h │ │ │ ├── CoreEvaluators.h │ │ │ ├── CoreIterators.h │ │ │ ├── CwiseBinaryOp.h │ │ │ ├── CwiseNullaryOp.h │ │ │ ├── CwiseTernaryOp.h │ │ │ ├── CwiseUnaryOp.h │ │ │ ├── CwiseUnaryView.h │ │ │ ├── DenseBase.h │ │ │ ├── DenseCoeffsBase.h │ │ │ ├── DenseStorage.h │ │ │ ├── Diagonal.h │ │ │ ├── DiagonalMatrix.h │ │ │ ├── DiagonalProduct.h │ │ │ ├── Dot.h │ │ │ ├── EigenBase.h │ │ │ ├── ForceAlignedAccess.h │ │ │ ├── Fuzzy.h │ │ │ ├── GeneralProduct.h │ │ │ ├── GenericPacketMath.h │ │ │ ├── GlobalFunctions.h │ │ │ ├── IO.h │ │ │ ├── Inverse.h │ │ │ ├── Map.h │ │ │ ├── MapBase.h │ │ │ ├── MathFunctions.h │ │ │ ├── MathFunctionsImpl.h │ │ │ ├── Matrix.h │ │ │ ├── MatrixBase.h │ │ │ ├── NestByValue.h │ │ │ ├── NoAlias.h │ │ │ ├── NumTraits.h │ │ │ ├── PermutationMatrix.h │ │ │ ├── PlainObjectBase.h │ │ │ ├── Product.h │ │ │ ├── ProductEvaluators.h │ │ │ ├── Random.h │ │ │ ├── Redux.h │ │ │ ├── Ref.h │ │ │ ├── Replicate.h │ │ │ ├── ReturnByValue.h │ │ │ ├── Reverse.h │ │ │ ├── Select.h │ │ │ ├── SelfAdjointView.h │ │ │ ├── SelfCwiseBinaryOp.h │ │ │ ├── Solve.h │ │ │ ├── SolveTriangular.h │ │ │ ├── SolverBase.h │ │ │ ├── StableNorm.h │ │ │ ├── Stride.h │ │ │ ├── Swap.h │ │ │ ├── Transpose.h │ │ │ ├── Transpositions.h │ │ │ ├── TriangularMatrix.h │ │ │ ├── VectorBlock.h │ │ │ ├── VectorwiseOp.h │ │ │ ├── Visitor.h │ │ │ ├── arch │ │ │ │ ├── AVX │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── AVX512 │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── AltiVec │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── CUDA │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── Half.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ ├── PacketMathHalf.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ ├── Default │ │ │ │ │ └── Settings.h │ │ │ │ ├── NEON │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ │ ├── SSE │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ ├── PacketMath.h │ │ │ │ │ └── TypeCasting.h │ │ │ │ └── ZVector │ │ │ │ │ ├── Complex.h │ │ │ │ │ ├── MathFunctions.h │ │ │ │ │ └── PacketMath.h │ │ │ ├── functors │ │ │ │ ├── AssignmentFunctors.h │ │ │ │ ├── BinaryFunctors.h │ │ │ │ ├── NullaryFunctors.h │ │ │ │ ├── StlFunctors.h │ │ │ │ ├── TernaryFunctors.h │ │ │ │ └── UnaryFunctors.h │ │ │ ├── products │ │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ │ ├── GeneralMatrixMatrix.h │ │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ │ ├── GeneralMatrixMatrixTriangular_BLAS.h │ │ │ │ ├── GeneralMatrixMatrix_BLAS.h │ │ │ │ ├── GeneralMatrixVector.h │ │ │ │ ├── GeneralMatrixVector_BLAS.h │ │ │ │ ├── Parallelizer.h │ │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ │ ├── SelfadjointMatrixMatrix_BLAS.h │ │ │ │ ├── SelfadjointMatrixVector.h │ │ │ │ ├── SelfadjointMatrixVector_BLAS.h │ │ │ │ ├── SelfadjointProduct.h │ │ │ │ ├── SelfadjointRank2Update.h │ │ │ │ ├── TriangularMatrixMatrix.h │ │ │ │ ├── TriangularMatrixMatrix_BLAS.h │ │ │ │ ├── TriangularMatrixVector.h │ │ │ │ ├── TriangularMatrixVector_BLAS.h │ │ │ │ ├── TriangularSolverMatrix.h │ │ │ │ ├── TriangularSolverMatrix_BLAS.h │ │ │ │ └── TriangularSolverVector.h │ │ │ └── util │ │ │ │ ├── BlasUtil.h │ │ │ │ ├── Constants.h │ │ │ │ ├── DisableStupidWarnings.h │ │ │ │ ├── ForwardDeclarations.h │ │ │ │ ├── MKL_support.h │ │ │ │ ├── Macros.h │ │ │ │ ├── Memory.h │ │ │ │ ├── Meta.h │ │ │ │ ├── NonMPL2.h │ │ │ │ ├── ReenableStupidWarnings.h │ │ │ │ ├── StaticAssert.h │ │ │ │ └── XprHelper.h │ │ │ ├── Eigenvalues │ │ │ ├── ComplexEigenSolver.h │ │ │ ├── ComplexSchur.h │ │ │ ├── ComplexSchur_LAPACKE.h │ │ │ ├── EigenSolver.h │ │ │ ├── GeneralizedEigenSolver.h │ │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ │ ├── HessenbergDecomposition.h │ │ │ ├── MatrixBaseEigenvalues.h │ │ │ ├── RealQZ.h │ │ │ ├── RealSchur.h │ │ │ ├── RealSchur_LAPACKE.h │ │ │ ├── SelfAdjointEigenSolver.h │ │ │ ├── SelfAdjointEigenSolver_LAPACKE.h │ │ │ └── Tridiagonalization.h │ │ │ ├── Geometry │ │ │ ├── AlignedBox.h │ │ │ ├── AngleAxis.h │ │ │ ├── EulerAngles.h │ │ │ ├── Homogeneous.h │ │ │ ├── Hyperplane.h │ │ │ ├── OrthoMethods.h │ │ │ ├── ParametrizedLine.h │ │ │ ├── Quaternion.h │ │ │ ├── Rotation2D.h │ │ │ ├── RotationBase.h │ │ │ ├── Scaling.h │ │ │ ├── Transform.h │ │ │ ├── Translation.h │ │ │ ├── Umeyama.h │ │ │ └── arch │ │ │ │ └── Geometry_SSE.h │ │ │ ├── Householder │ │ │ ├── BlockHouseholder.h │ │ │ ├── Householder.h │ │ │ └── HouseholderSequence.h │ │ │ ├── IterativeLinearSolvers │ │ │ ├── BasicPreconditioners.h │ │ │ ├── BiCGSTAB.h │ │ │ ├── ConjugateGradient.h │ │ │ ├── IncompleteCholesky.h │ │ │ ├── IncompleteLUT.h │ │ │ ├── IterativeSolverBase.h │ │ │ ├── LeastSquareConjugateGradient.h │ │ │ └── SolveWithGuess.h │ │ │ ├── Jacobi │ │ │ └── Jacobi.h │ │ │ ├── LU │ │ │ ├── Determinant.h │ │ │ ├── FullPivLU.h │ │ │ ├── InverseImpl.h │ │ │ ├── PartialPivLU.h │ │ │ ├── PartialPivLU_LAPACKE.h │ │ │ └── arch │ │ │ │ └── Inverse_SSE.h │ │ │ ├── MetisSupport │ │ │ └── MetisSupport.h │ │ │ ├── OrderingMethods │ │ │ ├── Amd.h │ │ │ ├── Eigen_Colamd.h │ │ │ └── Ordering.h │ │ │ ├── PaStiXSupport │ │ │ └── PaStiXSupport.h │ │ │ ├── PardisoSupport │ │ │ └── PardisoSupport.h │ │ │ ├── QR │ │ │ ├── ColPivHouseholderQR.h │ │ │ ├── ColPivHouseholderQR_LAPACKE.h │ │ │ ├── CompleteOrthogonalDecomposition.h │ │ │ ├── FullPivHouseholderQR.h │ │ │ ├── HouseholderQR.h │ │ │ └── HouseholderQR_LAPACKE.h │ │ │ ├── SPQRSupport │ │ │ └── SuiteSparseQRSupport.h │ │ │ ├── SVD │ │ │ ├── BDCSVD.h │ │ │ ├── JacobiSVD.h │ │ │ ├── JacobiSVD_LAPACKE.h │ │ │ ├── SVDBase.h │ │ │ └── UpperBidiagonalization.h │ │ │ ├── SparseCholesky │ │ │ ├── SimplicialCholesky.h │ │ │ └── SimplicialCholesky_impl.h │ │ │ ├── SparseCore │ │ │ ├── AmbiVector.h │ │ │ ├── CompressedStorage.h │ │ │ ├── ConservativeSparseSparseProduct.h │ │ │ ├── MappedSparseMatrix.h │ │ │ ├── SparseAssign.h │ │ │ ├── SparseBlock.h │ │ │ ├── SparseColEtree.h │ │ │ ├── SparseCompressedBase.h │ │ │ ├── SparseCwiseBinaryOp.h │ │ │ ├── SparseCwiseUnaryOp.h │ │ │ ├── SparseDenseProduct.h │ │ │ ├── SparseDiagonalProduct.h │ │ │ ├── SparseDot.h │ │ │ ├── SparseFuzzy.h │ │ │ ├── SparseMap.h │ │ │ ├── SparseMatrix.h │ │ │ ├── SparseMatrixBase.h │ │ │ ├── SparsePermutation.h │ │ │ ├── SparseProduct.h │ │ │ ├── SparseRedux.h │ │ │ ├── SparseRef.h │ │ │ ├── SparseSelfAdjointView.h │ │ │ ├── SparseSolverBase.h │ │ │ ├── SparseSparseProductWithPruning.h │ │ │ ├── SparseTranspose.h │ │ │ ├── SparseTriangularView.h │ │ │ ├── SparseUtil.h │ │ │ ├── SparseVector.h │ │ │ ├── SparseView.h │ │ │ └── TriangularSolver.h │ │ │ ├── SparseLU │ │ │ ├── SparseLU.h │ │ │ ├── SparseLUImpl.h │ │ │ ├── SparseLU_Memory.h │ │ │ ├── SparseLU_Structs.h │ │ │ ├── SparseLU_SupernodalMatrix.h │ │ │ ├── SparseLU_Utils.h │ │ │ ├── SparseLU_column_bmod.h │ │ │ ├── SparseLU_column_dfs.h │ │ │ ├── SparseLU_copy_to_ucol.h │ │ │ ├── SparseLU_gemm_kernel.h │ │ │ ├── SparseLU_heap_relax_snode.h │ │ │ ├── SparseLU_kernel_bmod.h │ │ │ ├── SparseLU_panel_bmod.h │ │ │ ├── SparseLU_panel_dfs.h │ │ │ ├── SparseLU_pivotL.h │ │ │ ├── SparseLU_pruneL.h │ │ │ └── SparseLU_relax_snode.h │ │ │ ├── SparseQR │ │ │ └── SparseQR.h │ │ │ ├── StlSupport │ │ │ ├── StdDeque.h │ │ │ ├── StdList.h │ │ │ ├── StdVector.h │ │ │ └── details.h │ │ │ ├── SuperLUSupport │ │ │ └── SuperLUSupport.h │ │ │ ├── UmfPackSupport │ │ │ └── UmfPackSupport.h │ │ │ ├── misc │ │ │ ├── Image.h │ │ │ ├── Kernel.h │ │ │ ├── RealSvd2x2.h │ │ │ ├── blas.h │ │ │ ├── lapack.h │ │ │ ├── lapacke.h │ │ │ └── lapacke_mangling.h │ │ │ └── plugins │ │ │ ├── ArrayCwiseBinaryOps.h │ │ │ ├── ArrayCwiseUnaryOps.h │ │ │ ├── BlockMethods.h │ │ │ ├── CommonCwiseBinaryOps.h │ │ │ ├── CommonCwiseUnaryOps.h │ │ │ ├── MatrixCwiseBinaryOps.h │ │ │ └── MatrixCwiseUnaryOps.h │ ├── bipartite.cpp │ ├── bipartite.h │ ├── lpsolve │ │ ├── inc │ │ │ ├── lp_Hash.h │ │ │ ├── lp_SOS.h │ │ │ ├── lp_lib.h │ │ │ ├── lp_matrix.h │ │ │ ├── lp_mipbb.h │ │ │ ├── lp_types.h │ │ │ └── lp_utils.h │ │ ├── lib32 │ │ │ └── liblpsolve55.a │ │ └── lib64 │ │ │ └── liblpsolve55.a │ ├── matching.cpp │ ├── matching.h │ └── patoh │ │ ├── libpatoh.a │ │ └── patoh.h ├── cong │ ├── cong.h │ ├── cong_est_base.cpp │ ├── cong_est_base.h │ ├── cong_est_bb.cpp │ ├── cong_est_bb.h │ ├── cong_gp.cpp │ ├── cong_gp.h │ ├── cong_partition.cpp │ └── cong_partition.h ├── db │ ├── clkrgn.cpp │ ├── clkrgn.h │ ├── db.cpp │ ├── db.h │ ├── db_bookshelf.cpp │ ├── db_draw.cpp │ ├── group.cpp │ ├── group.h │ ├── instance.cpp │ ├── instance.h │ ├── net.cpp │ ├── net.h │ ├── site.cpp │ ├── site.h │ ├── swbox.cpp │ └── swbox.h ├── dp │ ├── dp.cpp │ ├── dp.h │ ├── dp_ble.cpp │ ├── dp_data.cpp │ ├── dp_data.h │ ├── dp_main.h │ └── dp_pack.cpp ├── eval.sh ├── global.h ├── gp │ ├── gp.cpp │ ├── gp.h │ ├── gp_data.cpp │ ├── gp_data.h │ ├── gp_main.cpp │ ├── gp_main.h │ ├── gp_qsolve.cpp │ ├── gp_qsolve.h │ ├── gp_region.cpp │ ├── gp_region.h │ ├── gp_setting.cpp │ ├── gp_setting.h │ ├── gp_spread.cpp │ └── gp_spread.h ├── lg │ ├── lg.cpp │ ├── lg.h │ ├── lg_data.cpp │ ├── lg_data.h │ ├── lg_dp_chain.cpp │ ├── lg_dp_chain.h │ ├── lg_dp_utils.cpp │ ├── lg_dp_utils.h │ ├── lg_main.cpp │ └── lg_main.h ├── lgclk │ ├── lgclk.cpp │ ├── lgclk.h │ ├── lgclk_colrgn.cpp │ ├── lgclk_colrgn.h │ ├── lgclk_data.cpp │ ├── lgclk_data.h │ ├── lgclk_plan.cpp │ └── lgclk_plan.h ├── main.cpp ├── pack │ ├── ble.cpp │ ├── ble.h │ ├── clb.h │ ├── clb1.cpp │ ├── clb1.h │ ├── clb2.cpp │ ├── clb2.h │ ├── clb2_lutpg.cpp │ ├── clb2_lutpg.h │ ├── clb2_res1.cpp │ ├── clb2_res1.h │ ├── clb2_res2.cpp │ ├── clb2_res2.h │ ├── clb2_res_base.cpp │ ├── clb2_res_base.h │ ├── clb_base.h │ ├── pack.cpp │ ├── pack.h │ ├── pack_ble.cpp │ └── pack_ble.h ├── run.sh └── utils │ ├── draw.cpp │ ├── draw.h │ ├── geo.h │ ├── log.cpp │ ├── log.h │ └── misc.h └── toy_example ├── design.aux ├── design.dcp ├── design.lib ├── design.nets ├── design.nodes ├── design.pl ├── design.scl └── design.wts /ISPD16.md: -------------------------------------------------------------------------------- 1 | ### Results on ISPD'16 benchmarks 2 | 3 | | **Design** | **Routed Wirelength** | **Runtime (Sec)** | 4 | | :-----------: | :-------------------: | :---------------: | 5 | | FPGA-example1 | 11151 | 2 | 6 | | FPGA-example2 | 3218541 | 247 | 7 | | FPGA-example3 | 9207106 | 422 | 8 | | FPGA-example4 | 9985928 | 1000 | 9 | | FPGA01 | 350060 | 38 | 10 | | FPGA02 | 635044 | 59 | 11 | | FPGA03 | 3251264 | 232 | 12 | | FPGA04 | 5492214 | 321 | 13 | | FPGA05 | 9909270 | 357 | 14 | | FPGA06 | 6144522 | 548 | 15 | | FPGA07 | 9593240 | 654 | 16 | | FPGA08 | 8087931 | 421 | 17 | | FPGA09 | 12062928 | 681 | 18 | | FPGA10 | 6972278 | 1046 | 19 | | FPGA11 | 10918250 | 655 | 20 | | FPGA12 | 7239553 | 798 | -------------------------------------------------------------------------------- /ISPD17.md: -------------------------------------------------------------------------------- 1 | ### Results on ISPD'17 benchmarks 2 | 3 | | **Design** | **Routed Wirelength** | **Runtime (Sec)** | 4 | | :----------: | :-------------------: | :---------------: | 5 | | clk\_design1 | 23030 | 6 | 6 | | clk\_design2 | 313086 | 41 | 7 | | clk\_design3 | 1541629 | 185 | 8 | | clk\_design4 | 3134160 | 339 | 9 | | clk\_design5 | 4800900 | 485 | 10 | | CLK-FPGA01 | 2011452 | 260 | 11 | | CLK-FPGA02 | 2167861 | 236 | 12 | | CLK-FPGA03 | 5265206 | 506 | 13 | | CLK-FPGA04 | 3606567 | 328 | 14 | | CLK-FPGA05 | 4660136 | 486 | 15 | | CLK-FPGA06 | 5736998 | 532 | 16 | | CLK-FPGA07 | 2325787 | 290 | 17 | | CLK-FPGA08 | 1778292 | 232 | 18 | | CLK-FPGA09 | 2530105 | 336 | 19 | | CLK-FPGA10 | 4495500 | 465 | 20 | | CLK-FPGA11 | 4189622 | 408 | 21 | | CLK-FPGA12 | 3387586 | 365 | 22 | | CLK-FPGA13 | 3833106 | 386 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | READ THIS LICENSE AGREEMENT CAREFULLY BEFORE USING THIS PRODUCT. BY USING THIS PRODUCT YOU INDICATE YOUR ACCEPTANCE OF THE TERMS OF THE FOLLOWING AGREEMENT. THESE TERMS APPLY TO YOU AND ANY SUBSEQUENT LICENSEE OF THIS PRODUCT. 2 | 3 | 4 | 5 | License Agreement for RippleFPGA 6 | 7 | 8 | 9 | Copyright (c) 2019 by The Chinese University of Hong Kong 10 | 11 | 12 | 13 | All rights reserved 14 | 15 | 16 | 17 | CU-SD LICENSE (adapted from the original BSD license) Redistribution of the any code, with or without modification, are permitted provided that the conditions below are met. 18 | 19 | 20 | 21 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 22 | 23 | 24 | 25 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 26 | 27 | 28 | 29 | Neither the name nor trademark of the copyright holder or the author may be used to endorse or promote products derived from this software without specific prior written permission. 30 | 31 | 32 | 33 | Users are entirely responsible, to the exclusion of the author, for compliance with (a) regulations set by owners or administrators of employed equipment, (b) licensing terms of any other software, and (c) local, national, and international regulations regarding use, including those regarding import, export, and use of encryption software. 34 | 35 | 36 | 37 | THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | 39 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | SHELL=/bin/bash 2 | 3 | OPT := -O3 -DNDEBUG 4 | LIBS := -pthread 5 | ifeq ($(mode),debug) 6 | OPT := -O0 -g -DWRITE -DWRITE_GROUP -DDRAW 7 | LIBS += -lgd 8 | else 9 | ifeq ($(mode),release) 10 | OPT += -static -DSINGLE_THREAD 11 | else 12 | ifeq ($(mode),release_mt) 13 | OPT += -static 14 | LIBS = -Wl,--whole-archive -lpthread -Wl,--no-whole-archive 15 | else 16 | OPT += -DWRITE_GROUP 17 | endif 18 | endif 19 | endif 20 | 21 | target = ../bin 22 | 23 | WFLAG = -Wall 24 | DEPFLAG = -MMD -MP 25 | 26 | CC = g++-4.8 -std=c++11 $(OPT) $(WFLAG) $(DEPFLAG) $(INCLUDE) 27 | 28 | INCLUDE = -I. -I../../boost_1_62_0 29 | LIBS += $(addprefix alg/, patoh/libpatoh.a lpsolve/lib64/liblpsolve55.a) \ 30 | -lboost_system -ldl 31 | 32 | CC_OBJS = main 33 | UT_OBJS = $(addprefix utils/, log draw) 34 | DB_OBJS = $(addprefix db/, db db_draw db_bookshelf site instance net group swbox clkrgn) 35 | PC_OBJS = $(addprefix pack/, pack ble clb1 clb2 clb2_lutpg clb2_res_base clb2_res1 clb2_res2 pack_ble) 36 | GP_OBJS = $(addprefix gp/, gp gp_data gp_main gp_qsolve gp_spread gp_region gp_setting) 37 | LG_OBJS = $(addprefix lg/, lg_dp_utils lg lg_main lg_data lg_dp_chain) 38 | CLK_OBJS = $(addprefix lgclk/, lgclk lgclk_data lgclk_colrgn lgclk_plan) 39 | CONG_OBJS = $(addprefix cong/, cong_est_base cong_est_bb cong_gp cong_partition) 40 | DP_OBJS = $(addprefix dp/, dp dp_pack dp_ble dp_data) 41 | ALG_OBJS = $(addprefix alg/, matching bipartite) 42 | 43 | OBJS = $(addsuffix .o, $(CC_OBJS) $(UT_OBJS) $(DB_OBJS) $(IO_OBJS) $(ALG_OBJS) \ 44 | $(DP_OBJS) $(GP_OBJS) $(VI_OBJS) $(MM_OBJS) $(PC_OBJS) $(LG_OBJS) $(GR_OBJS) \ 45 | $(CONG_OBJS) $(CLK_OBJS)) 46 | 47 | BFILE = placer 48 | 49 | TAR_FILES = $(BFILE) run.sh eval.sh ../toy_example 50 | 51 | .PHONY: all clean tags 52 | all: $(BFILE) 53 | @date +'%D %T' 54 | mkdir -p $(target) 55 | cp -ur $(TAR_FILES) $(target)/ 56 | 57 | $(BFILE): $(OBJS) 58 | $(CC) -o $@ $(OBJS) $(LIBS) 59 | 60 | %.o : %.cpp 61 | $(CC) -o $@ -c $< 62 | 63 | -include $(OBJS:.o=.d) 64 | 65 | clean: 66 | rm -f {*,*/*,*/*/*}.{o,d} $(BFILE) 67 | 68 | tags: 69 | cscope -Rbq 70 | ctags -R *.cpp *.h -------------------------------------------------------------------------------- /src/alg/Eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h") 20 | -------------------------------------------------------------------------------- /src/alg/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLESKY_MODULE_H 9 | #define EIGEN_CHOLESKY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Cholesky_Module Cholesky module 16 | * 17 | * 18 | * 19 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 20 | * Those decompositions are also accessible via the following methods: 21 | * - MatrixBase::llt() 22 | * - MatrixBase::ldlt() 23 | * - SelfAdjointView::llt() 24 | * - SelfAdjointView::ldlt() 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | */ 30 | 31 | #include "src/Cholesky/LLT.h" 32 | #include "src/Cholesky/LDLT.h" 33 | #ifdef EIGEN_USE_LAPACKE 34 | #include "src/misc/lapacke.h" 35 | #include "src/Cholesky/LLT_LAPACKE.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_CHOLESKY_MODULE_H 41 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 42 | -------------------------------------------------------------------------------- /src/alg/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 9 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup CholmodSupport_Module CholmodSupport module 21 | * 22 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 23 | * It provides the two following main factorization classes: 24 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 25 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 26 | * 27 | * For the sake of completeness, this module also propose the two following classes: 28 | * - class CholmodSimplicialLLT 29 | * - class CholmodSimplicialLDLT 30 | * Note that these classes does not bring any particular advantage compared to the built-in 31 | * SimplicialLLT and SimplicialLDLT factorization classes. 32 | * 33 | * \code 34 | * #include 35 | * \endcode 36 | * 37 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 38 | * The dependencies depend on how cholmod has been compiled. 39 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 40 | * 41 | */ 42 | 43 | #include "src/CholmodSupport/CholmodSupport.h" 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 48 | 49 | -------------------------------------------------------------------------------- /src/alg/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /src/alg/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /src/alg/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_EIGENVALUES_MODULE_H 9 | #define EIGEN_EIGENVALUES_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | #include "LU" 19 | #include "Geometry" 20 | 21 | /** \defgroup Eigenvalues_Module Eigenvalues module 22 | * 23 | * 24 | * 25 | * This module mainly provides various eigenvalue solvers. 26 | * This module also provides some MatrixBase methods, including: 27 | * - MatrixBase::eigenvalues(), 28 | * - MatrixBase::operatorNorm() 29 | * 30 | * \code 31 | * #include 32 | * \endcode 33 | */ 34 | 35 | #include "src/misc/RealSvd2x2.h" 36 | #include "src/Eigenvalues/Tridiagonalization.h" 37 | #include "src/Eigenvalues/RealSchur.h" 38 | #include "src/Eigenvalues/EigenSolver.h" 39 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 40 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 41 | #include "src/Eigenvalues/HessenbergDecomposition.h" 42 | #include "src/Eigenvalues/ComplexSchur.h" 43 | #include "src/Eigenvalues/ComplexEigenSolver.h" 44 | #include "src/Eigenvalues/RealQZ.h" 45 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 46 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 47 | #ifdef EIGEN_USE_LAPACKE 48 | #include "src/misc/lapacke.h" 49 | #include "src/Eigenvalues/RealSchur_LAPACKE.h" 50 | #include "src/Eigenvalues/ComplexSchur_LAPACKE.h" 51 | #include "src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h" 52 | #endif 53 | 54 | #include "src/Core/util/ReenableStupidWarnings.h" 55 | 56 | #endif // EIGEN_EIGENVALUES_MODULE_H 57 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 58 | -------------------------------------------------------------------------------- /src/alg/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_GEOMETRY_MODULE_H 9 | #define EIGEN_GEOMETRY_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SVD" 16 | #include "LU" 17 | #include 18 | 19 | /** \defgroup Geometry_Module Geometry module 20 | * 21 | * This module provides support for: 22 | * - fixed-size homogeneous transformations 23 | * - translation, scaling, 2D and 3D rotations 24 | * - \link Quaternion quaternions \endlink 25 | * - cross products (\ref MatrixBase::cross, \ref MatrixBase::cross3) 26 | * - orthognal vector generation (\ref MatrixBase::unitOrthogonal) 27 | * - some linear components: \link ParametrizedLine parametrized-lines \endlink and \link Hyperplane hyperplanes \endlink 28 | * - \link AlignedBox axis aligned bounding boxes \endlink 29 | * - \link umeyama least-square transformation fitting \endlink 30 | * 31 | * \code 32 | * #include 33 | * \endcode 34 | */ 35 | 36 | #include "src/Geometry/OrthoMethods.h" 37 | #include "src/Geometry/EulerAngles.h" 38 | 39 | #include "src/Geometry/Homogeneous.h" 40 | #include "src/Geometry/RotationBase.h" 41 | #include "src/Geometry/Rotation2D.h" 42 | #include "src/Geometry/Quaternion.h" 43 | #include "src/Geometry/AngleAxis.h" 44 | #include "src/Geometry/Transform.h" 45 | #include "src/Geometry/Translation.h" 46 | #include "src/Geometry/Scaling.h" 47 | #include "src/Geometry/Hyperplane.h" 48 | #include "src/Geometry/ParametrizedLine.h" 49 | #include "src/Geometry/AlignedBox.h" 50 | #include "src/Geometry/Umeyama.h" 51 | 52 | // Use the SSE optimized version whenever possible. At the moment the 53 | // SSE version doesn't compile when AVX is enabled 54 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 55 | #include "src/Geometry/arch/Geometry_SSE.h" 56 | #endif 57 | 58 | #include "src/Core/util/ReenableStupidWarnings.h" 59 | 60 | #endif // EIGEN_GEOMETRY_MODULE_H 61 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 62 | 63 | -------------------------------------------------------------------------------- /src/alg/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 31 | -------------------------------------------------------------------------------- /src/alg/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 9 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | 14 | #include "src/Core/util/DisableStupidWarnings.h" 15 | 16 | /** 17 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 18 | * 19 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 20 | * Those solvers are accessible via the following classes: 21 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 22 | * - LeastSquaresConjugateGradient for rectangular least-square problems, 23 | * - BiCGSTAB for general square matrices. 24 | * 25 | * These iterative solvers are associated with some preconditioners: 26 | * - IdentityPreconditioner - not really useful 27 | * - DiagonalPreconditioner - also called Jacobi preconditioner, work very well on diagonal dominant matrices. 28 | * - IncompleteLUT - incomplete LU factorization with dual thresholding 29 | * 30 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 31 | * 32 | \code 33 | #include 34 | \endcode 35 | */ 36 | 37 | #include "src/IterativeLinearSolvers/SolveWithGuess.h" 38 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 39 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 40 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 41 | #include "src/IterativeLinearSolvers/LeastSquareConjugateGradient.h" 42 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 43 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 44 | #include "src/IterativeLinearSolvers/IncompleteCholesky.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 49 | -------------------------------------------------------------------------------- /src/alg/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | 34 | -------------------------------------------------------------------------------- /src/alg/Eigen/LU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_LU_MODULE_H 9 | #define EIGEN_LU_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup LU_Module LU module 16 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 17 | * This module defines the following MatrixBase methods: 18 | * - MatrixBase::inverse() 19 | * - MatrixBase::determinant() 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/misc/Kernel.h" 27 | #include "src/misc/Image.h" 28 | #include "src/LU/FullPivLU.h" 29 | #include "src/LU/PartialPivLU.h" 30 | #ifdef EIGEN_USE_LAPACKE 31 | #include "src/misc/lapacke.h" 32 | #include "src/LU/PartialPivLU_LAPACKE.h" 33 | #endif 34 | #include "src/LU/Determinant.h" 35 | #include "src/LU/InverseImpl.h" 36 | 37 | // Use the SSE optimized version whenever possible. At the moment the 38 | // SSE version doesn't compile when AVX is enabled 39 | #if defined EIGEN_VECTORIZE_SSE && !defined EIGEN_VECTORIZE_AVX 40 | #include "src/LU/arch/Inverse_SSE.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_LU_MODULE_H 46 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 47 | -------------------------------------------------------------------------------- /src/alg/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /src/alg/Eigen/OrderingMethods: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_ORDERINGMETHODS_MODULE_H 9 | #define EIGEN_ORDERINGMETHODS_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** 16 | * \defgroup OrderingMethods_Module OrderingMethods module 17 | * 18 | * This module is currently for internal use only 19 | * 20 | * It defines various built-in and external ordering methods for sparse matrices. 21 | * They are typically used to reduce the number of elements during 22 | * the sparse matrix decomposition (LLT, LU, QR). 23 | * Precisely, in a preprocessing step, a permutation matrix P is computed using 24 | * those ordering methods and applied to the columns of the matrix. 25 | * Using for instance the sparse Cholesky decomposition, it is expected that 26 | * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A). 27 | * 28 | * 29 | * Usage : 30 | * \code 31 | * #include 32 | * \endcode 33 | * 34 | * A simple usage is as a template parameter in the sparse decomposition classes : 35 | * 36 | * \code 37 | * SparseLU > solver; 38 | * \endcode 39 | * 40 | * \code 41 | * SparseQR > solver; 42 | * \endcode 43 | * 44 | * It is possible as well to call directly a particular ordering method for your own purpose, 45 | * \code 46 | * AMDOrdering ordering; 47 | * PermutationMatrix perm; 48 | * SparseMatrix A; 49 | * //Fill the matrix ... 50 | * 51 | * ordering(A, perm); // Call AMD 52 | * \endcode 53 | * 54 | * \note Some of these methods (like AMD or METIS), need the sparsity pattern 55 | * of the input matrix to be symmetric. When the matrix is structurally unsymmetric, 56 | * Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method. 57 | * If your matrix is already symmetric (at leat in structure), you can avoid that 58 | * by calling the method with a SelfAdjointView type. 59 | * 60 | * \code 61 | * // Call the ordering on the pattern of the lower triangular matrix A 62 | * ordering(A.selfadjointView(), perm); 63 | * \endcode 64 | */ 65 | 66 | #ifndef EIGEN_MPL2_ONLY 67 | #include "src/OrderingMethods/Amd.h" 68 | #endif 69 | 70 | #include "src/OrderingMethods/Ordering.h" 71 | #include "src/Core/util/ReenableStupidWarnings.h" 72 | 73 | #endif // EIGEN_ORDERINGMETHODS_MODULE_H 74 | -------------------------------------------------------------------------------- /src/alg/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 9 | #define EIGEN_PASTIXSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | } 19 | 20 | #ifdef complex 21 | #undef complex 22 | #endif 23 | 24 | /** \ingroup Support_modules 25 | * \defgroup PaStiXSupport_Module PaStiXSupport module 26 | * 27 | * This module provides an interface to the PaSTiX library. 28 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 29 | * It provides the two following main factorization classes: 30 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 31 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 32 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 33 | * 34 | * \code 35 | * #include 36 | * \endcode 37 | * 38 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 39 | * The dependencies depend on how PaSTiX has been compiled. 40 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 41 | * 42 | */ 43 | 44 | #include "src/PaStiXSupport/PaStiXSupport.h" 45 | 46 | #include "src/Core/util/ReenableStupidWarnings.h" 47 | 48 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 49 | -------------------------------------------------------------------------------- /src/alg/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 9 | #define EIGEN_PARDISOSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup PardisoSupport_Module PardisoSupport module 19 | * 20 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 27 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 28 | * 29 | */ 30 | 31 | #include "src/PardisoSupport/PardisoSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /src/alg/Eigen/QR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QR_MODULE_H 9 | #define EIGEN_QR_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Cholesky" 16 | #include "Jacobi" 17 | #include "Householder" 18 | 19 | /** \defgroup QR_Module QR module 20 | * 21 | * 22 | * 23 | * This module provides various QR decompositions 24 | * This module also provides some MatrixBase methods, including: 25 | * - MatrixBase::householderQr() 26 | * - MatrixBase::colPivHouseholderQr() 27 | * - MatrixBase::fullPivHouseholderQr() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/QR/HouseholderQR.h" 35 | #include "src/QR/FullPivHouseholderQR.h" 36 | #include "src/QR/ColPivHouseholderQR.h" 37 | #include "src/QR/CompleteOrthogonalDecomposition.h" 38 | #ifdef EIGEN_USE_LAPACKE 39 | #include "src/misc/lapacke.h" 40 | #include "src/QR/HouseholderQR_LAPACKE.h" 41 | #include "src/QR/ColPivHouseholderQR_LAPACKE.h" 42 | #endif 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_QR_MODULE_H 47 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 48 | -------------------------------------------------------------------------------- /src/alg/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 41 | -------------------------------------------------------------------------------- /src/alg/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 9 | #define EIGEN_SPQRSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "SuiteSparseQR.hpp" 16 | 17 | /** \ingroup Support_modules 18 | * \defgroup SPQRSupport_Module SuiteSparseQR module 19 | * 20 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 27 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 28 | * 29 | */ 30 | 31 | #include "src/CholmodSupport/CholmodSupport.h" 32 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/alg/Eigen/SVD: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SVD_MODULE_H 9 | #define EIGEN_SVD_MODULE_H 10 | 11 | #include "QR" 12 | #include "Householder" 13 | #include "Jacobi" 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | /** \defgroup SVD_Module SVD module 18 | * 19 | * 20 | * 21 | * This module provides SVD decomposition for matrices (both real and complex). 22 | * Two decomposition algorithms are provided: 23 | * - JacobiSVD implementing two-sided Jacobi iterations is numerically very accurate, fast for small matrices, but very slow for larger ones. 24 | * - BDCSVD implementing a recursive divide & conquer strategy on top of an upper-bidiagonalization which remains fast for large problems. 25 | * These decompositions are accessible via the respective classes and following MatrixBase methods: 26 | * - MatrixBase::jacobiSvd() 27 | * - MatrixBase::bdcSvd() 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | */ 33 | 34 | #include "src/misc/RealSvd2x2.h" 35 | #include "src/SVD/UpperBidiagonalization.h" 36 | #include "src/SVD/SVDBase.h" 37 | #include "src/SVD/JacobiSVD.h" 38 | #include "src/SVD/BDCSVD.h" 39 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 40 | #include "src/misc/lapacke.h" 41 | #include "src/SVD/JacobiSVD_LAPACKE.h" 42 | #endif 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_SVD_MODULE_H 47 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 48 | -------------------------------------------------------------------------------- /src/alg/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #include "SparseCholesky" 29 | #include "SparseLU" 30 | #include "SparseQR" 31 | #include "IterativeLinearSolvers" 32 | 33 | #endif // EIGEN_SPARSE_MODULE_H 34 | 35 | -------------------------------------------------------------------------------- /src/alg/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #ifdef EIGEN_MPL2_ONLY 34 | #error The SparseCholesky module has nothing to offer in MPL2 only mode 35 | #endif 36 | 37 | #include "src/SparseCholesky/SimplicialCholesky.h" 38 | 39 | #ifndef EIGEN_MPL2_ONLY 40 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 41 | #endif 42 | 43 | #include "src/Core/util/ReenableStupidWarnings.h" 44 | 45 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 46 | -------------------------------------------------------------------------------- /src/alg/Eigen/SparseCore: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSECORE_MODULE_H 9 | #define EIGEN_SPARSECORE_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | /** 22 | * \defgroup SparseCore_Module SparseCore module 23 | * 24 | * This module provides a sparse matrix representation, and basic associated matrix manipulations 25 | * and operations. 26 | * 27 | * See the \ref TutorialSparse "Sparse tutorial" 28 | * 29 | * \code 30 | * #include 31 | * \endcode 32 | * 33 | * This module depends on: Core. 34 | */ 35 | 36 | #include "src/SparseCore/SparseUtil.h" 37 | #include "src/SparseCore/SparseMatrixBase.h" 38 | #include "src/SparseCore/SparseAssign.h" 39 | #include "src/SparseCore/CompressedStorage.h" 40 | #include "src/SparseCore/AmbiVector.h" 41 | #include "src/SparseCore/SparseCompressedBase.h" 42 | #include "src/SparseCore/SparseMatrix.h" 43 | #include "src/SparseCore/SparseMap.h" 44 | #include "src/SparseCore/MappedSparseMatrix.h" 45 | #include "src/SparseCore/SparseVector.h" 46 | #include "src/SparseCore/SparseRef.h" 47 | #include "src/SparseCore/SparseCwiseUnaryOp.h" 48 | #include "src/SparseCore/SparseCwiseBinaryOp.h" 49 | #include "src/SparseCore/SparseTranspose.h" 50 | #include "src/SparseCore/SparseBlock.h" 51 | #include "src/SparseCore/SparseDot.h" 52 | #include "src/SparseCore/SparseRedux.h" 53 | #include "src/SparseCore/SparseView.h" 54 | #include "src/SparseCore/SparseDiagonalProduct.h" 55 | #include "src/SparseCore/ConservativeSparseSparseProduct.h" 56 | #include "src/SparseCore/SparseSparseProductWithPruning.h" 57 | #include "src/SparseCore/SparseProduct.h" 58 | #include "src/SparseCore/SparseDenseProduct.h" 59 | #include "src/SparseCore/SparseSelfAdjointView.h" 60 | #include "src/SparseCore/SparseTriangularView.h" 61 | #include "src/SparseCore/TriangularSolver.h" 62 | #include "src/SparseCore/SparsePermutation.h" 63 | #include "src/SparseCore/SparseFuzzy.h" 64 | #include "src/SparseCore/SparseSolverBase.h" 65 | 66 | #include "src/Core/util/ReenableStupidWarnings.h" 67 | 68 | #endif // EIGEN_SPARSECORE_MODULE_H 69 | 70 | -------------------------------------------------------------------------------- /src/alg/Eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | // Ordering interface 24 | #include "OrderingMethods" 25 | 26 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 27 | 28 | #include "src/SparseLU/SparseLU_Structs.h" 29 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 30 | #include "src/SparseLU/SparseLUImpl.h" 31 | #include "src/SparseCore/SparseColEtree.h" 32 | #include "src/SparseLU/SparseLU_Memory.h" 33 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 34 | #include "src/SparseLU/SparseLU_relax_snode.h" 35 | #include "src/SparseLU/SparseLU_pivotL.h" 36 | #include "src/SparseLU/SparseLU_panel_dfs.h" 37 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 38 | #include "src/SparseLU/SparseLU_panel_bmod.h" 39 | #include "src/SparseLU/SparseLU_column_dfs.h" 40 | #include "src/SparseLU/SparseLU_column_bmod.h" 41 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 42 | #include "src/SparseLU/SparseLU_pruneL.h" 43 | #include "src/SparseLU/SparseLU_Utils.h" 44 | #include "src/SparseLU/SparseLU.h" 45 | 46 | #endif // EIGEN_SPARSELU_MODULE_H 47 | -------------------------------------------------------------------------------- /src/alg/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSEQR_MODULE_H 9 | #define EIGEN_SPARSEQR_MODULE_H 10 | 11 | #include "SparseCore" 12 | #include "OrderingMethods" 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup SparseQR_Module SparseQR module 16 | * \brief Provides QR decomposition for sparse matrices 17 | * 18 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 19 | * The columns of the input matrix should be reordered to limit the fill-in during the 20 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 21 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 22 | * of built-in and external ordering methods. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | * 28 | * 29 | */ 30 | 31 | #include "OrderingMethods" 32 | #include "src/SparseCore/SparseColEtree.h" 33 | #include "src/SparseQR/SparseQR.h" 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/alg/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /src/alg/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 /* MSVC auto aligns in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /src/alg/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /src/alg/Eigen/SuperLUSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SUPERLUSUPPORT_MODULE_H 9 | #define EIGEN_SUPERLUSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #ifdef EMPTY 16 | #define EIGEN_EMPTY_WAS_ALREADY_DEFINED 17 | #endif 18 | 19 | typedef int int_t; 20 | #include 21 | #include 22 | #include 23 | 24 | // slu_util.h defines a preprocessor token named EMPTY which is really polluting, 25 | // so we remove it in favor of a SUPERLU_EMPTY token. 26 | // If EMPTY was already defined then we don't undef it. 27 | 28 | #if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED) 29 | # undef EIGEN_EMPTY_WAS_ALREADY_DEFINED 30 | #elif defined(EMPTY) 31 | # undef EMPTY 32 | #endif 33 | 34 | #define SUPERLU_EMPTY (-1) 35 | 36 | namespace Eigen { struct SluMatrix; } 37 | 38 | /** \ingroup Support_modules 39 | * \defgroup SuperLUSupport_Module SuperLUSupport module 40 | * 41 | * This module provides an interface to the SuperLU library. 42 | * It provides the following factorization class: 43 | * - class SuperLU: a supernodal sequential LU factorization. 44 | * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods). 45 | * 46 | * \warning This wrapper requires at least versions 4.0 of SuperLU. The 3.x versions are not supported. 47 | * 48 | * \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting. 49 | * 50 | * \code 51 | * #include 52 | * \endcode 53 | * 54 | * In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies. 55 | * The dependencies depend on how superlu has been compiled. 56 | * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task. 57 | * 58 | */ 59 | 60 | #include "src/SuperLUSupport/SuperLUSupport.h" 61 | 62 | #include "src/Core/util/ReenableStupidWarnings.h" 63 | 64 | #endif // EIGEN_SUPERLUSUPPORT_MODULE_H 65 | -------------------------------------------------------------------------------- /src/alg/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 9 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | /** \ingroup Support_modules 20 | * \defgroup UmfPackSupport_Module UmfPackSupport module 21 | * 22 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 23 | * It provides the following factorization class: 24 | * - class UmfPackLU: a multifrontal sequential LU factorization. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 31 | * The dependencies depend on how umfpack has been compiled. 32 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/UmfPackSupport/UmfPackSupport.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 41 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/Assign.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2007 Michael Olbrich 5 | // Copyright (C) 2006-2010 Benoit Jacob 6 | // Copyright (C) 2008 Gael Guennebaud 7 | // 8 | // This Source Code Form is subject to the terms of the Mozilla 9 | // Public License v. 2.0. If a copy of the MPL was not distributed 10 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | 12 | #ifndef EIGEN_ASSIGN_H 13 | #define EIGEN_ASSIGN_H 14 | 15 | namespace Eigen { 16 | 17 | template 18 | template 19 | EIGEN_STRONG_INLINE Derived& DenseBase 20 | ::lazyAssign(const DenseBase& other) 21 | { 22 | enum{ 23 | SameType = internal::is_same::value 24 | }; 25 | 26 | EIGEN_STATIC_ASSERT_LVALUE(Derived) 27 | EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) 28 | EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 29 | 30 | eigen_assert(rows() == other.rows() && cols() == other.cols()); 31 | internal::call_assignment_no_alias(derived(),other.derived()); 32 | 33 | return derived(); 34 | } 35 | 36 | template 37 | template 38 | EIGEN_DEVICE_FUNC 39 | EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) 40 | { 41 | internal::call_assignment(derived(), other.derived()); 42 | return derived(); 43 | } 44 | 45 | template 46 | EIGEN_DEVICE_FUNC 47 | EIGEN_STRONG_INLINE Derived& DenseBase::operator=(const DenseBase& other) 48 | { 49 | internal::call_assignment(derived(), other.derived()); 50 | return derived(); 51 | } 52 | 53 | template 54 | EIGEN_DEVICE_FUNC 55 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const MatrixBase& other) 56 | { 57 | internal::call_assignment(derived(), other.derived()); 58 | return derived(); 59 | } 60 | 61 | template 62 | template 63 | EIGEN_DEVICE_FUNC 64 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const DenseBase& other) 65 | { 66 | internal::call_assignment(derived(), other.derived()); 67 | return derived(); 68 | } 69 | 70 | template 71 | template 72 | EIGEN_DEVICE_FUNC 73 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const EigenBase& other) 74 | { 75 | internal::call_assignment(derived(), other.derived()); 76 | return derived(); 77 | } 78 | 79 | template 80 | template 81 | EIGEN_DEVICE_FUNC 82 | EIGEN_STRONG_INLINE Derived& MatrixBase::operator=(const ReturnByValue& other) 83 | { 84 | other.derived().evalTo(derived()); 85 | return derived(); 86 | } 87 | 88 | } // end namespace Eigen 89 | 90 | #endif // EIGEN_ASSIGN_H 91 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/DiagonalProduct.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2007-2009 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/MathFunctionsImpl.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2014 Pedro Gonnet (pedro.gonnet@gmail.com) 5 | // Copyright (C) 2016 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_MATHFUNCTIONSIMPL_H 12 | #define EIGEN_MATHFUNCTIONSIMPL_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | /** \internal \returns the hyperbolic tan of \a a (coeff-wise) 19 | Doesn't do anything fancy, just a 13/6-degree rational interpolant which 20 | is accurate up to a couple of ulp in the range [-9, 9], outside of which 21 | the tanh(x) = +/-1. 22 | 23 | This implementation works on both scalars and packets. 24 | */ 25 | template 26 | T generic_fast_tanh_float(const T& a_x) 27 | { 28 | // Clamp the inputs to the range [-9, 9] since anything outside 29 | // this range is +/-1.0f in single-precision. 30 | const T plus_9 = pset1(9.f); 31 | const T minus_9 = pset1(-9.f); 32 | // NOTE GCC prior to 6.3 might improperly optimize this max/min 33 | // step such that if a_x is nan, x will be either 9 or -9, 34 | // and tanh will return 1 or -1 instead of nan. 35 | // This is supposed to be fixed in gcc6.3, 36 | // see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72867 37 | const T x = pmax(minus_9,pmin(plus_9,a_x)); 38 | // The monomial coefficients of the numerator polynomial (odd). 39 | const T alpha_1 = pset1(4.89352455891786e-03f); 40 | const T alpha_3 = pset1(6.37261928875436e-04f); 41 | const T alpha_5 = pset1(1.48572235717979e-05f); 42 | const T alpha_7 = pset1(5.12229709037114e-08f); 43 | const T alpha_9 = pset1(-8.60467152213735e-11f); 44 | const T alpha_11 = pset1(2.00018790482477e-13f); 45 | const T alpha_13 = pset1(-2.76076847742355e-16f); 46 | 47 | // The monomial coefficients of the denominator polynomial (even). 48 | const T beta_0 = pset1(4.89352518554385e-03f); 49 | const T beta_2 = pset1(2.26843463243900e-03f); 50 | const T beta_4 = pset1(1.18534705686654e-04f); 51 | const T beta_6 = pset1(1.19825839466702e-06f); 52 | 53 | // Since the polynomials are odd/even, we need x^2. 54 | const T x2 = pmul(x, x); 55 | 56 | // Evaluate the numerator polynomial p. 57 | T p = pmadd(x2, alpha_13, alpha_11); 58 | p = pmadd(x2, p, alpha_9); 59 | p = pmadd(x2, p, alpha_7); 60 | p = pmadd(x2, p, alpha_5); 61 | p = pmadd(x2, p, alpha_3); 62 | p = pmadd(x2, p, alpha_1); 63 | p = pmul(x, p); 64 | 65 | // Evaluate the denominator polynomial p. 66 | T q = pmadd(x2, beta_6, beta_4); 67 | q = pmadd(x2, q, beta_2); 68 | q = pmadd(x2, q, beta_0); 69 | 70 | // Divide the numerator by the denominator. 71 | return pdiv(p, q); 72 | } 73 | 74 | } // end namespace internal 75 | 76 | } // end namespace Eigen 77 | 78 | #endif // EIGEN_MATHFUNCTIONSIMPL_H 79 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/SelfCwiseBinaryOp.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SELFCWISEBINARYOP_H 11 | #define EIGEN_SELFCWISEBINARYOP_H 12 | 13 | namespace Eigen { 14 | 15 | // TODO generalize the scalar type of 'other' 16 | 17 | template 18 | EIGEN_STRONG_INLINE Derived& DenseBase::operator*=(const Scalar& other) 19 | { 20 | typedef typename Derived::PlainObject PlainObject; 21 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op()); 22 | return derived(); 23 | } 24 | 25 | template 26 | EIGEN_STRONG_INLINE Derived& ArrayBase::operator+=(const Scalar& other) 27 | { 28 | typedef typename Derived::PlainObject PlainObject; 29 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::add_assign_op()); 30 | return derived(); 31 | } 32 | 33 | template 34 | EIGEN_STRONG_INLINE Derived& ArrayBase::operator-=(const Scalar& other) 35 | { 36 | typedef typename Derived::PlainObject PlainObject; 37 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::sub_assign_op()); 38 | return derived(); 39 | } 40 | 41 | template 42 | EIGEN_STRONG_INLINE Derived& DenseBase::operator/=(const Scalar& other) 43 | { 44 | typedef typename Derived::PlainObject PlainObject; 45 | internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op()); 46 | return derived(); 47 | } 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_SELFCWISEBINARYOP_H 52 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/Swap.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2006-2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SWAP_H 11 | #define EIGEN_SWAP_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // Overload default assignPacket behavior for swapping them 18 | template 19 | class generic_dense_assignment_kernel, Specialized> 20 | : public generic_dense_assignment_kernel, BuiltIn> 21 | { 22 | protected: 23 | typedef generic_dense_assignment_kernel, BuiltIn> Base; 24 | using Base::m_dst; 25 | using Base::m_src; 26 | using Base::m_functor; 27 | 28 | public: 29 | typedef typename Base::Scalar Scalar; 30 | typedef typename Base::DstXprType DstXprType; 31 | typedef swap_assign_op Functor; 32 | 33 | EIGEN_DEVICE_FUNC generic_dense_assignment_kernel(DstEvaluatorTypeT &dst, const SrcEvaluatorTypeT &src, const Functor &func, DstXprType& dstExpr) 34 | : Base(dst, src, func, dstExpr) 35 | {} 36 | 37 | template 38 | void assignPacket(Index row, Index col) 39 | { 40 | PacketType tmp = m_src.template packet(row,col); 41 | const_cast(m_src).template writePacket(row,col, m_dst.template packet(row,col)); 42 | m_dst.template writePacket(row,col,tmp); 43 | } 44 | 45 | template 46 | void assignPacket(Index index) 47 | { 48 | PacketType tmp = m_src.template packet(index); 49 | const_cast(m_src).template writePacket(index, m_dst.template packet(index)); 50 | m_dst.template writePacket(index,tmp); 51 | } 52 | 53 | // TODO find a simple way not to have to copy/paste this function from generic_dense_assignment_kernel, by simple I mean no CRTP (Gael) 54 | template 55 | void assignPacketByOuterInner(Index outer, Index inner) 56 | { 57 | Index row = Base::rowIndexByOuterInner(outer, inner); 58 | Index col = Base::colIndexByOuterInner(outer, inner); 59 | assignPacket(row, col); 60 | } 61 | }; 62 | 63 | } // namespace internal 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN_SWAP_H 68 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/arch/AVX/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_AVX_H 11 | #define EIGEN_TYPE_CASTING_AVX_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // For now we use SSE to handle integers, so we can't use AVX instructions to cast 18 | // from int to float 19 | template <> 20 | struct type_casting_traits { 21 | enum { 22 | VectorizedCast = 0, 23 | SrcCoeffRatio = 1, 24 | TgtCoeffRatio = 1 25 | }; 26 | }; 27 | 28 | template <> 29 | struct type_casting_traits { 30 | enum { 31 | VectorizedCast = 0, 32 | SrcCoeffRatio = 1, 33 | TgtCoeffRatio = 1 34 | }; 35 | }; 36 | 37 | 38 | 39 | template<> EIGEN_STRONG_INLINE Packet8i pcast(const Packet8f& a) { 40 | return _mm256_cvtps_epi32(a); 41 | } 42 | 43 | template<> EIGEN_STRONG_INLINE Packet8f pcast(const Packet8i& a) { 44 | return _mm256_cvtepi32_ps(a); 45 | } 46 | 47 | } // end namespace internal 48 | 49 | } // end namespace Eigen 50 | 51 | #endif // EIGEN_TYPE_CASTING_AVX_H 52 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/arch/CUDA/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2014 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MATH_FUNCTIONS_CUDA_H 11 | #define EIGEN_MATH_FUNCTIONS_CUDA_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | // Make sure this is only available when targeting a GPU: we don't want to 18 | // introduce conflicts between these packet_traits definitions and the ones 19 | // we'll use on the host side (SSE, AVX, ...) 20 | #if defined(__CUDACC__) && defined(EIGEN_USE_GPU) 21 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 22 | float4 plog(const float4& a) 23 | { 24 | return make_float4(logf(a.x), logf(a.y), logf(a.z), logf(a.w)); 25 | } 26 | 27 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 28 | double2 plog(const double2& a) 29 | { 30 | using ::log; 31 | return make_double2(log(a.x), log(a.y)); 32 | } 33 | 34 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 35 | float4 plog1p(const float4& a) 36 | { 37 | return make_float4(log1pf(a.x), log1pf(a.y), log1pf(a.z), log1pf(a.w)); 38 | } 39 | 40 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 41 | double2 plog1p(const double2& a) 42 | { 43 | return make_double2(log1p(a.x), log1p(a.y)); 44 | } 45 | 46 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 47 | float4 pexp(const float4& a) 48 | { 49 | return make_float4(expf(a.x), expf(a.y), expf(a.z), expf(a.w)); 50 | } 51 | 52 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 53 | double2 pexp(const double2& a) 54 | { 55 | using ::exp; 56 | return make_double2(exp(a.x), exp(a.y)); 57 | } 58 | 59 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 60 | float4 psqrt(const float4& a) 61 | { 62 | return make_float4(sqrtf(a.x), sqrtf(a.y), sqrtf(a.z), sqrtf(a.w)); 63 | } 64 | 65 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 66 | double2 psqrt(const double2& a) 67 | { 68 | using ::sqrt; 69 | return make_double2(sqrt(a.x), sqrt(a.y)); 70 | } 71 | 72 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 73 | float4 prsqrt(const float4& a) 74 | { 75 | return make_float4(rsqrtf(a.x), rsqrtf(a.y), rsqrtf(a.z), rsqrtf(a.w)); 76 | } 77 | 78 | template<> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 79 | double2 prsqrt(const double2& a) 80 | { 81 | return make_double2(rsqrt(a.x), rsqrt(a.y)); 82 | } 83 | 84 | 85 | #endif 86 | 87 | } // end namespace internal 88 | 89 | } // end namespace Eigen 90 | 91 | #endif // EIGEN_MATH_FUNCTIONS_CUDA_H 92 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 100 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/arch/NEON/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | /* The sin, cos, exp, and log functions of this file come from 9 | * Julien Pommier's sse math library: http://gruntthepeon.free.fr/ssemath/ 10 | */ 11 | 12 | #ifndef EIGEN_MATH_FUNCTIONS_NEON_H 13 | #define EIGEN_MATH_FUNCTIONS_NEON_H 14 | 15 | namespace Eigen { 16 | 17 | namespace internal { 18 | 19 | template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED 20 | Packet4f pexp(const Packet4f& _x) 21 | { 22 | Packet4f x = _x; 23 | Packet4f tmp, fx; 24 | 25 | _EIGEN_DECLARE_CONST_Packet4f(1 , 1.0f); 26 | _EIGEN_DECLARE_CONST_Packet4f(half, 0.5f); 27 | _EIGEN_DECLARE_CONST_Packet4i(0x7f, 0x7f); 28 | _EIGEN_DECLARE_CONST_Packet4f(exp_hi, 88.3762626647950f); 29 | _EIGEN_DECLARE_CONST_Packet4f(exp_lo, -88.3762626647949f); 30 | _EIGEN_DECLARE_CONST_Packet4f(cephes_LOG2EF, 1.44269504088896341f); 31 | _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_C1, 0.693359375f); 32 | _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_C2, -2.12194440e-4f); 33 | _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p0, 1.9875691500E-4f); 34 | _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p1, 1.3981999507E-3f); 35 | _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p2, 8.3334519073E-3f); 36 | _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p3, 4.1665795894E-2f); 37 | _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p4, 1.6666665459E-1f); 38 | _EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p5, 5.0000001201E-1f); 39 | 40 | x = vminq_f32(x, p4f_exp_hi); 41 | x = vmaxq_f32(x, p4f_exp_lo); 42 | 43 | /* express exp(x) as exp(g + n*log(2)) */ 44 | fx = vmlaq_f32(p4f_half, x, p4f_cephes_LOG2EF); 45 | 46 | /* perform a floorf */ 47 | tmp = vcvtq_f32_s32(vcvtq_s32_f32(fx)); 48 | 49 | /* if greater, substract 1 */ 50 | Packet4ui mask = vcgtq_f32(tmp, fx); 51 | mask = vandq_u32(mask, vreinterpretq_u32_f32(p4f_1)); 52 | 53 | fx = vsubq_f32(tmp, vreinterpretq_f32_u32(mask)); 54 | 55 | tmp = vmulq_f32(fx, p4f_cephes_exp_C1); 56 | Packet4f z = vmulq_f32(fx, p4f_cephes_exp_C2); 57 | x = vsubq_f32(x, tmp); 58 | x = vsubq_f32(x, z); 59 | 60 | Packet4f y = vmulq_f32(p4f_cephes_exp_p0, x); 61 | z = vmulq_f32(x, x); 62 | y = vaddq_f32(y, p4f_cephes_exp_p1); 63 | y = vmulq_f32(y, x); 64 | y = vaddq_f32(y, p4f_cephes_exp_p2); 65 | y = vmulq_f32(y, x); 66 | y = vaddq_f32(y, p4f_cephes_exp_p3); 67 | y = vmulq_f32(y, x); 68 | y = vaddq_f32(y, p4f_cephes_exp_p4); 69 | y = vmulq_f32(y, x); 70 | y = vaddq_f32(y, p4f_cephes_exp_p5); 71 | 72 | y = vmulq_f32(y, z); 73 | y = vaddq_f32(y, x); 74 | y = vaddq_f32(y, p4f_1); 75 | 76 | /* build 2^n */ 77 | int32x4_t mm; 78 | mm = vcvtq_s32_f32(fx); 79 | mm = vaddq_s32(mm, p4i_0x7f); 80 | mm = vshlq_n_s32(mm, 23); 81 | Packet4f pow2n = vreinterpretq_f32_s32(mm); 82 | 83 | y = vmulq_f32(y, pow2n); 84 | return y; 85 | } 86 | 87 | } // end namespace internal 88 | 89 | } // end namespace Eigen 90 | 91 | #endif // EIGEN_MATH_FUNCTIONS_NEON_H 92 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/arch/SSE/TypeCasting.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2015 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TYPE_CASTING_SSE_H 11 | #define EIGEN_TYPE_CASTING_SSE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template <> 18 | struct type_casting_traits { 19 | enum { 20 | VectorizedCast = 1, 21 | SrcCoeffRatio = 1, 22 | TgtCoeffRatio = 1 23 | }; 24 | }; 25 | 26 | template<> EIGEN_STRONG_INLINE Packet4i pcast(const Packet4f& a) { 27 | return _mm_cvttps_epi32(a); 28 | } 29 | 30 | 31 | template <> 32 | struct type_casting_traits { 33 | enum { 34 | VectorizedCast = 1, 35 | SrcCoeffRatio = 1, 36 | TgtCoeffRatio = 1 37 | }; 38 | }; 39 | 40 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet4i& a) { 41 | return _mm_cvtepi32_ps(a); 42 | } 43 | 44 | 45 | template <> 46 | struct type_casting_traits { 47 | enum { 48 | VectorizedCast = 1, 49 | SrcCoeffRatio = 2, 50 | TgtCoeffRatio = 1 51 | }; 52 | }; 53 | 54 | template<> EIGEN_STRONG_INLINE Packet4f pcast(const Packet2d& a, const Packet2d& b) { 55 | return _mm_shuffle_ps(_mm_cvtpd_ps(a), _mm_cvtpd_ps(b), (1 << 2) | (1 << 6)); 56 | } 57 | 58 | template <> 59 | struct type_casting_traits { 60 | enum { 61 | VectorizedCast = 1, 62 | SrcCoeffRatio = 1, 63 | TgtCoeffRatio = 2 64 | }; 65 | }; 66 | 67 | template<> EIGEN_STRONG_INLINE Packet2d pcast(const Packet4f& a) { 68 | // Simply discard the second half of the input 69 | return _mm_cvtps_pd(a); 70 | } 71 | 72 | 73 | } // end namespace internal 74 | 75 | } // end namespace Eigen 76 | 77 | #endif // EIGEN_TYPE_CASTING_SSE_H 78 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #elif defined __GNUC__ && __GNUC__>=6 12 | #pragma GCC diagnostic pop 13 | #endif 14 | 15 | #if defined __NVCC__ 16 | // Don't reenable the diagnostic messages, as it turns out these messages need 17 | // to be disabled at the point of the template instantiation (i.e the user code) 18 | // otherwise they'll be triggered by nvcc. 19 | // #pragma diag_default code_is_unreachable 20 | // #pragma diag_default initialization_not_reachable 21 | // #pragma diag_default 2651 22 | // #pragma diag_default 2653 23 | #endif 24 | 25 | #endif 26 | 27 | #endif // EIGEN_WARNINGS_DISABLED 28 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/LU/Determinant.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_DETERMINANT_H 11 | #define EIGEN_DETERMINANT_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template 18 | inline const typename Derived::Scalar bruteforce_det3_helper 19 | (const MatrixBase& matrix, int a, int b, int c) 20 | { 21 | return matrix.coeff(0,a) 22 | * (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b)); 23 | } 24 | 25 | template 26 | const typename Derived::Scalar bruteforce_det4_helper 27 | (const MatrixBase& matrix, int j, int k, int m, int n) 28 | { 29 | return (matrix.coeff(j,0) * matrix.coeff(k,1) - matrix.coeff(k,0) * matrix.coeff(j,1)) 30 | * (matrix.coeff(m,2) * matrix.coeff(n,3) - matrix.coeff(n,2) * matrix.coeff(m,3)); 31 | } 32 | 33 | template struct determinant_impl 36 | { 37 | static inline typename traits::Scalar run(const Derived& m) 38 | { 39 | if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0) 40 | return typename traits::Scalar(1); 41 | return m.partialPivLu().determinant(); 42 | } 43 | }; 44 | 45 | template struct determinant_impl 46 | { 47 | static inline typename traits::Scalar run(const Derived& m) 48 | { 49 | return m.coeff(0,0); 50 | } 51 | }; 52 | 53 | template struct determinant_impl 54 | { 55 | static inline typename traits::Scalar run(const Derived& m) 56 | { 57 | return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1); 58 | } 59 | }; 60 | 61 | template struct determinant_impl 62 | { 63 | static inline typename traits::Scalar run(const Derived& m) 64 | { 65 | return bruteforce_det3_helper(m,0,1,2) 66 | - bruteforce_det3_helper(m,1,0,2) 67 | + bruteforce_det3_helper(m,2,0,1); 68 | } 69 | }; 70 | 71 | template struct determinant_impl 72 | { 73 | static typename traits::Scalar run(const Derived& m) 74 | { 75 | // trick by Martin Costabel to compute 4x4 det with only 30 muls 76 | return bruteforce_det4_helper(m,0,1,2,3) 77 | - bruteforce_det4_helper(m,0,2,1,3) 78 | + bruteforce_det4_helper(m,0,3,1,2) 79 | + bruteforce_det4_helper(m,1,2,0,3) 80 | - bruteforce_det4_helper(m,1,3,0,2) 81 | + bruteforce_det4_helper(m,2,3,0,1); 82 | } 83 | }; 84 | 85 | } // end namespace internal 86 | 87 | /** \lu_module 88 | * 89 | * \returns the determinant of this matrix 90 | */ 91 | template 92 | inline typename internal::traits::Scalar MatrixBase::determinant() const 93 | { 94 | eigen_assert(rows() == cols()); 95 | typedef typename internal::nested_eval::type Nested; 96 | return internal::determinant_impl::type>::run(derived()); 97 | } 98 | 99 | } // end namespace Eigen 100 | 101 | #endif // EIGEN_DETERMINANT_H 102 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/QR/HouseholderQR_LAPACKE.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to LAPACKe 29 | * Householder QR decomposition of a matrix w/o pivoting based on 30 | * LAPACKE_?geqrf function. 31 | ******************************************************************************** 32 | */ 33 | 34 | #ifndef EIGEN_QR_LAPACKE_H 35 | #define EIGEN_QR_LAPACKE_H 36 | 37 | namespace Eigen { 38 | 39 | namespace internal { 40 | 41 | /** \internal Specialization for the data types supported by LAPACKe */ 42 | 43 | #define EIGEN_LAPACKE_QR_NOPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX) \ 44 | template \ 45 | struct householder_qr_inplace_blocked \ 46 | { \ 47 | static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index = 32, \ 48 | typename MatrixQR::Scalar* = 0) \ 49 | { \ 50 | lapack_int m = (lapack_int) mat.rows(); \ 51 | lapack_int n = (lapack_int) mat.cols(); \ 52 | lapack_int lda = (lapack_int) mat.outerStride(); \ 53 | lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ 54 | LAPACKE_##LAPACKE_PREFIX##geqrf( matrix_order, m, n, (LAPACKE_TYPE*)mat.data(), lda, (LAPACKE_TYPE*)hCoeffs.data()); \ 55 | hCoeffs.adjointInPlace(); \ 56 | } \ 57 | }; 58 | 59 | EIGEN_LAPACKE_QR_NOPIV(double, double, d) 60 | EIGEN_LAPACKE_QR_NOPIV(float, float, s) 61 | EIGEN_LAPACKE_QR_NOPIV(dcomplex, lapack_complex_double, z) 62 | EIGEN_LAPACKE_QR_NOPIV(scomplex, lapack_complex_float, c) 63 | 64 | } // end namespace internal 65 | 66 | } // end namespace Eigen 67 | 68 | #endif // EIGEN_QR_LAPACKE_H 69 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/SparseCore/MappedSparseMatrix.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MAPPED_SPARSEMATRIX_H 11 | #define EIGEN_MAPPED_SPARSEMATRIX_H 12 | 13 | namespace Eigen { 14 | 15 | /** \deprecated Use Map > 16 | * \class MappedSparseMatrix 17 | * 18 | * \brief Sparse matrix 19 | * 20 | * \param _Scalar the scalar type, i.e. the type of the coefficients 21 | * 22 | * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme. 23 | * 24 | */ 25 | namespace internal { 26 | template 27 | struct traits > : traits > 28 | {}; 29 | } // end namespace internal 30 | 31 | template 32 | class MappedSparseMatrix 33 | : public Map > 34 | { 35 | typedef Map > Base; 36 | 37 | public: 38 | 39 | typedef typename Base::StorageIndex StorageIndex; 40 | typedef typename Base::Scalar Scalar; 41 | 42 | inline MappedSparseMatrix(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, StorageIndex* innerIndexPtr, Scalar* valuePtr, StorageIndex* innerNonZeroPtr = 0) 43 | : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZeroPtr) 44 | {} 45 | 46 | /** Empty destructor */ 47 | inline ~MappedSparseMatrix() {} 48 | }; 49 | 50 | namespace internal { 51 | 52 | template 53 | struct evaluator > 54 | : evaluator > > 55 | { 56 | typedef MappedSparseMatrix<_Scalar,_Options,_StorageIndex> XprType; 57 | typedef evaluator > Base; 58 | 59 | evaluator() : Base() {} 60 | explicit evaluator(const XprType &mat) : Base(mat) {} 61 | }; 62 | 63 | } 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN_MAPPED_SPARSEMATRIX_H 68 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/SparseCore/SparseDot.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_DOT_H 11 | #define EIGEN_SPARSE_DOT_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | typename internal::traits::Scalar 18 | SparseMatrixBase::dot(const MatrixBase& other) const 19 | { 20 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 21 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 22 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 23 | EIGEN_STATIC_ASSERT((internal::is_same::value), 24 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 25 | 26 | eigen_assert(size() == other.size()); 27 | eigen_assert(other.size()>0 && "you are using a non initialized vector"); 28 | 29 | internal::evaluator thisEval(derived()); 30 | typename internal::evaluator::InnerIterator i(thisEval, 0); 31 | Scalar res(0); 32 | while (i) 33 | { 34 | res += numext::conj(i.value()) * other.coeff(i.index()); 35 | ++i; 36 | } 37 | return res; 38 | } 39 | 40 | template 41 | template 42 | typename internal::traits::Scalar 43 | SparseMatrixBase::dot(const SparseMatrixBase& other) const 44 | { 45 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 46 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived) 47 | EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived) 48 | EIGEN_STATIC_ASSERT((internal::is_same::value), 49 | YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) 50 | 51 | eigen_assert(size() == other.size()); 52 | 53 | internal::evaluator thisEval(derived()); 54 | typename internal::evaluator::InnerIterator i(thisEval, 0); 55 | 56 | internal::evaluator otherEval(other.derived()); 57 | typename internal::evaluator::InnerIterator j(otherEval, 0); 58 | 59 | Scalar res(0); 60 | while (i && j) 61 | { 62 | if (i.index()==j.index()) 63 | { 64 | res += numext::conj(i.value()) * j.value(); 65 | ++i; ++j; 66 | } 67 | else if (i.index() 76 | inline typename NumTraits::Scalar>::Real 77 | SparseMatrixBase::squaredNorm() const 78 | { 79 | return numext::real((*this).cwiseAbs2().sum()); 80 | } 81 | 82 | template 83 | inline typename NumTraits::Scalar>::Real 84 | SparseMatrixBase::norm() const 85 | { 86 | using std::sqrt; 87 | return sqrt(squaredNorm()); 88 | } 89 | 90 | template 91 | inline typename NumTraits::Scalar>::Real 92 | SparseMatrixBase::blueNorm() const 93 | { 94 | return internal::blueNorm_impl(*this); 95 | } 96 | } // end namespace Eigen 97 | 98 | #endif // EIGEN_SPARSE_DOT_H 99 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | template 17 | bool SparseMatrixBase::isApprox(const SparseMatrixBase& other, const RealScalar &prec) const 18 | { 19 | const typename internal::nested_eval::type actualA(derived()); 20 | typename internal::conditional::type, 22 | const PlainObject>::type actualB(other.derived()); 23 | 24 | return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm()); 25 | } 26 | 27 | } // end namespace Eigen 28 | 29 | #endif // EIGEN_SPARSE_FUZZY_H 30 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2014 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | internal::evaluator thisEval(derived()); 22 | for (Index j=0; j::InnerIterator iter(thisEval,j); iter; ++iter) 24 | res += iter.value(); 25 | return res; 26 | } 27 | 28 | template 29 | typename internal::traits >::Scalar 30 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 31 | { 32 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 33 | if(this->isCompressed()) 34 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 35 | else 36 | return Base::sum(); 37 | } 38 | 39 | template 40 | typename internal::traits >::Scalar 41 | SparseVector<_Scalar,_Options,_Index>::sum() const 42 | { 43 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 44 | return Matrix::Map(m_data.valuePtr(), m_data.size()).sum(); 45 | } 46 | 47 | } // end namespace Eigen 48 | 49 | #endif // EIGEN_SPARSEREDUX_H 50 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/SparseCore/SparseTranspose.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2015 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSETRANSPOSE_H 11 | #define EIGEN_SPARSETRANSPOSE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | template 17 | class SparseTransposeImpl 18 | : public SparseMatrixBase > 19 | {}; 20 | 21 | template 22 | class SparseTransposeImpl 23 | : public SparseCompressedBase > 24 | { 25 | typedef SparseCompressedBase > Base; 26 | public: 27 | using Base::derived; 28 | typedef typename Base::Scalar Scalar; 29 | typedef typename Base::StorageIndex StorageIndex; 30 | 31 | inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } 32 | 33 | inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); } 34 | inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); } 35 | inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); } 36 | inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); } 37 | 38 | inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); } 39 | inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); } 40 | inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); } 41 | inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); } 42 | }; 43 | } 44 | 45 | template class TransposeImpl 46 | : public internal::SparseTransposeImpl 47 | { 48 | protected: 49 | typedef internal::SparseTransposeImpl Base; 50 | }; 51 | 52 | namespace internal { 53 | 54 | template 55 | struct unary_evaluator, IteratorBased> 56 | : public evaluator_base > 57 | { 58 | typedef typename evaluator::InnerIterator EvalIterator; 59 | public: 60 | typedef Transpose XprType; 61 | 62 | inline Index nonZerosEstimate() const { 63 | return m_argImpl.nonZerosEstimate(); 64 | } 65 | 66 | class InnerIterator : public EvalIterator 67 | { 68 | public: 69 | EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer) 70 | : EvalIterator(unaryOp.m_argImpl,outer) 71 | {} 72 | 73 | Index row() const { return EvalIterator::col(); } 74 | Index col() const { return EvalIterator::row(); } 75 | }; 76 | 77 | enum { 78 | CoeffReadCost = evaluator::CoeffReadCost, 79 | Flags = XprType::Flags 80 | }; 81 | 82 | explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {} 83 | 84 | protected: 85 | evaluator m_argImpl; 86 | }; 87 | 88 | } // end namespace internal 89 | 90 | } // end namespace Eigen 91 | 92 | #endif // EIGEN_SPARSETRANSPOSE_H 93 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/SparseLU/SparseLU_Utils.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | 11 | #ifndef EIGEN_SPARSELU_UTILS_H 12 | #define EIGEN_SPARSELU_UTILS_H 13 | 14 | namespace Eigen { 15 | namespace internal { 16 | 17 | /** 18 | * \brief Count Nonzero elements in the factors 19 | */ 20 | template 21 | void SparseLUImpl::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) 22 | { 23 | nnzL = 0; 24 | nnzU = (glu.xusub)(n); 25 | Index nsuper = (glu.supno)(n); 26 | Index jlen; 27 | Index i, j, fsupc; 28 | if (n <= 0 ) return; 29 | // For each supernode 30 | for (i = 0; i <= nsuper; i++) 31 | { 32 | fsupc = glu.xsup(i); 33 | jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); 34 | 35 | for (j = fsupc; j < glu.xsup(i+1); j++) 36 | { 37 | nnzL += jlen; 38 | nnzU += j - fsupc + 1; 39 | jlen--; 40 | } 41 | } 42 | } 43 | 44 | /** 45 | * \brief Fix up the data storage lsub for L-subscripts. 46 | * 47 | * It removes the subscripts sets for structural pruning, 48 | * and applies permutation to the remaining subscripts 49 | * 50 | */ 51 | template 52 | void SparseLUImpl::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) 53 | { 54 | Index fsupc, i, j, k, jstart; 55 | 56 | StorageIndex nextl = 0; 57 | Index nsuper = (glu.supno)(n); 58 | 59 | // For each supernode 60 | for (i = 0; i <= nsuper; i++) 61 | { 62 | fsupc = glu.xsup(i); 63 | jstart = glu.xlsub(fsupc); 64 | glu.xlsub(fsupc) = nextl; 65 | for (j = jstart; j < glu.xlsub(fsupc + 1); j++) 66 | { 67 | glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A 68 | nextl++; 69 | } 70 | for (k = fsupc+1; k < glu.xsup(i+1); k++) 71 | glu.xlsub(k) = nextl; // other columns in supernode i 72 | } 73 | 74 | glu.xlsub(n) = nextl; 75 | } 76 | 77 | } // end namespace internal 78 | 79 | } // end namespace Eigen 80 | #endif // EIGEN_SPARSELU_UTILS_H 81 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/SparseLU/SparseLU_relax_snode.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | /* This file is a modified version of heap_relax_snode.c file in SuperLU 11 | * -- SuperLU routine (version 3.0) -- 12 | * Univ. of California Berkeley, Xerox Palo Alto Research Center, 13 | * and Lawrence Berkeley National Lab. 14 | * October 15, 2003 15 | * 16 | * Copyright (c) 1994 by Xerox Corporation. All rights reserved. 17 | * 18 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY 19 | * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. 20 | * 21 | * Permission is hereby granted to use or copy this program for any 22 | * purpose, provided the above notices are retained on all copies. 23 | * Permission to modify the code and to distribute modified code is 24 | * granted, provided the above notices are retained, and a notice that 25 | * the code was modified is included with the above copyright notice. 26 | */ 27 | 28 | #ifndef SPARSELU_RELAX_SNODE_H 29 | #define SPARSELU_RELAX_SNODE_H 30 | 31 | namespace Eigen { 32 | 33 | namespace internal { 34 | 35 | /** 36 | * \brief Identify the initial relaxed supernodes 37 | * 38 | * This routine is applied to a column elimination tree. 39 | * It assumes that the matrix has been reordered according to the postorder of the etree 40 | * \param n the number of columns 41 | * \param et elimination tree 42 | * \param relax_columns Maximum number of columns allowed in a relaxed snode 43 | * \param descendants Number of descendants of each node in the etree 44 | * \param relax_end last column in a supernode 45 | */ 46 | template 47 | void SparseLUImpl::relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end) 48 | { 49 | 50 | // compute the number of descendants of each node in the etree 51 | Index parent; 52 | relax_end.setConstant(emptyIdxLU); 53 | descendants.setZero(); 54 | for (Index j = 0; j < n; j++) 55 | { 56 | parent = et(j); 57 | if (parent != n) // not the dummy root 58 | descendants(parent) += descendants(j) + 1; 59 | } 60 | // Identify the relaxed supernodes by postorder traversal of the etree 61 | Index snode_start; // beginning of a snode 62 | for (Index j = 0; j < n; ) 63 | { 64 | parent = et(j); 65 | snode_start = j; 66 | while ( parent != n && descendants(parent) < relax_columns ) 67 | { 68 | j = parent; 69 | parent = et(j); 70 | } 71 | // Found a supernode in postordered etree, j is the last column 72 | relax_end(snode_start) = StorageIndex(j); // Record last column 73 | j++; 74 | // Search for a new leaf 75 | while (descendants(j) != 0 && j < n) j++; 76 | } // End postorder traversal of the etree 77 | 78 | } 79 | 80 | } // end namespace internal 81 | 82 | } // end namespace Eigen 83 | #endif 84 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/StlSupport/details.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STL_DETAILS_H 12 | #define EIGEN_STL_DETAILS_H 13 | 14 | #ifndef EIGEN_ALIGNED_ALLOCATOR 15 | #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator 16 | #endif 17 | 18 | namespace Eigen { 19 | 20 | // This one is needed to prevent reimplementing the whole std::vector. 21 | template 22 | class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR 23 | { 24 | public: 25 | typedef size_t size_type; 26 | typedef ptrdiff_t difference_type; 27 | typedef T* pointer; 28 | typedef const T* const_pointer; 29 | typedef T& reference; 30 | typedef const T& const_reference; 31 | typedef T value_type; 32 | 33 | template 34 | struct rebind 35 | { 36 | typedef aligned_allocator_indirection other; 37 | }; 38 | 39 | aligned_allocator_indirection() {} 40 | aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR() {} 41 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 42 | template 43 | aligned_allocator_indirection(const aligned_allocator_indirection& ) {} 44 | template 45 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 46 | ~aligned_allocator_indirection() {} 47 | }; 48 | 49 | #if EIGEN_COMP_MSVC 50 | 51 | // sometimes, MSVC detects, at compile time, that the argument x 52 | // in std::vector::resize(size_t s,T x) won't be aligned and generate an error 53 | // even if this function is never called. Whence this little wrapper. 54 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \ 55 | typename Eigen::internal::conditional< \ 56 | Eigen::internal::is_arithmetic::value, \ 57 | T, \ 58 | Eigen::internal::workaround_msvc_stl_support \ 59 | >::type 60 | 61 | namespace internal { 62 | template struct workaround_msvc_stl_support : public T 63 | { 64 | inline workaround_msvc_stl_support() : T() {} 65 | inline workaround_msvc_stl_support(const T& other) : T(other) {} 66 | inline operator T& () { return *static_cast(this); } 67 | inline operator const T& () const { return *static_cast(this); } 68 | template 69 | inline T& operator=(const OtherT& other) 70 | { T::operator=(other); return *this; } 71 | inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other) 72 | { T::operator=(other); return *this; } 73 | }; 74 | } 75 | 76 | #else 77 | 78 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T 79 | 80 | #endif 81 | 82 | } 83 | 84 | #endif // EIGEN_STL_DETAILS_H 85 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/misc/Image.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_IMAGE_H 11 | #define EIGEN_MISC_IMAGE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class image_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose 27 | // dimension is the number of rows of the original matrix 28 | Dynamic, // we don't know at compile time the dimension of the image (the rank) 29 | MatrixType::Options, 30 | MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix, 31 | MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns. 32 | > ReturnType; 33 | }; 34 | 35 | template struct image_retval_base 36 | : public ReturnByValue > 37 | { 38 | typedef _DecompositionType DecompositionType; 39 | typedef typename DecompositionType::MatrixType MatrixType; 40 | typedef ReturnByValue Base; 41 | 42 | image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) 43 | : m_dec(dec), m_rank(dec.rank()), 44 | m_cols(m_rank == 0 ? 1 : m_rank), 45 | m_originalMatrix(originalMatrix) 46 | {} 47 | 48 | inline Index rows() const { return m_dec.rows(); } 49 | inline Index cols() const { return m_cols; } 50 | inline Index rank() const { return m_rank; } 51 | inline const DecompositionType& dec() const { return m_dec; } 52 | inline const MatrixType& originalMatrix() const { return m_originalMatrix; } 53 | 54 | template inline void evalTo(Dest& dst) const 55 | { 56 | static_cast*>(this)->evalTo(dst); 57 | } 58 | 59 | protected: 60 | const DecompositionType& m_dec; 61 | Index m_rank, m_cols; 62 | const MatrixType& m_originalMatrix; 63 | }; 64 | 65 | } // end namespace internal 66 | 67 | #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \ 68 | typedef typename DecompositionType::MatrixType MatrixType; \ 69 | typedef typename MatrixType::Scalar Scalar; \ 70 | typedef typename MatrixType::RealScalar RealScalar; \ 71 | typedef Eigen::internal::image_retval_base Base; \ 72 | using Base::dec; \ 73 | using Base::originalMatrix; \ 74 | using Base::rank; \ 75 | using Base::rows; \ 76 | using Base::cols; \ 77 | image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ 78 | : Base(dec, originalMatrix) {} 79 | 80 | } // end namespace Eigen 81 | 82 | #endif // EIGEN_MISC_IMAGE_H 83 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/misc/Kernel.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_KERNEL_H 11 | #define EIGEN_MISC_KERNEL_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class kernel_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" 27 | // is the number of cols of the original matrix 28 | // so that the product "matrix * kernel = zero" makes sense 29 | Dynamic, // we don't know at compile-time the dimension of the kernel 30 | MatrixType::Options, 31 | MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter 32 | MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, 33 | // whose dimension is the number of columns of the original matrix 34 | > ReturnType; 35 | }; 36 | 37 | template struct kernel_retval_base 38 | : public ReturnByValue > 39 | { 40 | typedef _DecompositionType DecompositionType; 41 | typedef ReturnByValue Base; 42 | 43 | explicit kernel_retval_base(const DecompositionType& dec) 44 | : m_dec(dec), 45 | m_rank(dec.rank()), 46 | m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank) 47 | {} 48 | 49 | inline Index rows() const { return m_dec.cols(); } 50 | inline Index cols() const { return m_cols; } 51 | inline Index rank() const { return m_rank; } 52 | inline const DecompositionType& dec() const { return m_dec; } 53 | 54 | template inline void evalTo(Dest& dst) const 55 | { 56 | static_cast*>(this)->evalTo(dst); 57 | } 58 | 59 | protected: 60 | const DecompositionType& m_dec; 61 | Index m_rank, m_cols; 62 | }; 63 | 64 | } // end namespace internal 65 | 66 | #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \ 67 | typedef typename DecompositionType::MatrixType MatrixType; \ 68 | typedef typename MatrixType::Scalar Scalar; \ 69 | typedef typename MatrixType::RealScalar RealScalar; \ 70 | typedef Eigen::internal::kernel_retval_base Base; \ 71 | using Base::dec; \ 72 | using Base::rank; \ 73 | using Base::rows; \ 74 | using Base::cols; \ 75 | kernel_retval(const DecompositionType& dec) : Base(dec) {} 76 | 77 | } // end namespace Eigen 78 | 79 | #endif // EIGEN_MISC_KERNEL_H 80 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/misc/RealSvd2x2.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009-2010 Benoit Jacob 5 | // Copyright (C) 2013-2016 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_REALSVD2X2_H 12 | #define EIGEN_REALSVD2X2_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q, 20 | JacobiRotation *j_left, 21 | JacobiRotation *j_right) 22 | { 23 | using std::sqrt; 24 | using std::abs; 25 | Matrix m; 26 | m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)), 27 | numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q)); 28 | JacobiRotation rot1; 29 | RealScalar t = m.coeff(0,0) + m.coeff(1,1); 30 | RealScalar d = m.coeff(1,0) - m.coeff(0,1); 31 | 32 | if(abs(d) < (std::numeric_limits::min)()) 33 | { 34 | rot1.s() = RealScalar(0); 35 | rot1.c() = RealScalar(1); 36 | } 37 | else 38 | { 39 | // If d!=0, then t/d cannot overflow because the magnitude of the 40 | // entries forming d are not too small compared to the ones forming t. 41 | RealScalar u = t / d; 42 | RealScalar tmp = sqrt(RealScalar(1) + numext::abs2(u)); 43 | rot1.s() = RealScalar(1) / tmp; 44 | rot1.c() = u / tmp; 45 | } 46 | m.applyOnTheLeft(0,1,rot1); 47 | j_right->makeJacobi(m,0,1); 48 | *j_left = rot1 * j_right->transpose(); 49 | } 50 | 51 | } // end namespace internal 52 | 53 | } // end namespace Eigen 54 | 55 | #endif // EIGEN_REALSVD2X2_H 56 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /src/alg/Eigen/src/plugins/MatrixCwiseUnaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | // This file is included into the body of the base classes supporting matrix specific coefficient-wise functions. 12 | // This include MatrixBase and SparseMatrixBase. 13 | 14 | 15 | typedef CwiseUnaryOp, const Derived> CwiseAbsReturnType; 16 | typedef CwiseUnaryOp, const Derived> CwiseAbs2ReturnType; 17 | typedef CwiseUnaryOp, const Derived> CwiseSqrtReturnType; 18 | typedef CwiseUnaryOp, const Derived> CwiseSignReturnType; 19 | typedef CwiseUnaryOp, const Derived> CwiseInverseReturnType; 20 | 21 | /// \returns an expression of the coefficient-wise absolute value of \c *this 22 | /// 23 | /// Example: \include MatrixBase_cwiseAbs.cpp 24 | /// Output: \verbinclude MatrixBase_cwiseAbs.out 25 | /// 26 | EIGEN_DOC_UNARY_ADDONS(cwiseAbs,absolute value) 27 | /// 28 | /// \sa cwiseAbs2() 29 | /// 30 | EIGEN_DEVICE_FUNC 31 | EIGEN_STRONG_INLINE const CwiseAbsReturnType 32 | cwiseAbs() const { return CwiseAbsReturnType(derived()); } 33 | 34 | /// \returns an expression of the coefficient-wise squared absolute value of \c *this 35 | /// 36 | /// Example: \include MatrixBase_cwiseAbs2.cpp 37 | /// Output: \verbinclude MatrixBase_cwiseAbs2.out 38 | /// 39 | EIGEN_DOC_UNARY_ADDONS(cwiseAbs2,squared absolute value) 40 | /// 41 | /// \sa cwiseAbs() 42 | /// 43 | EIGEN_DEVICE_FUNC 44 | EIGEN_STRONG_INLINE const CwiseAbs2ReturnType 45 | cwiseAbs2() const { return CwiseAbs2ReturnType(derived()); } 46 | 47 | /// \returns an expression of the coefficient-wise square root of *this. 48 | /// 49 | /// Example: \include MatrixBase_cwiseSqrt.cpp 50 | /// Output: \verbinclude MatrixBase_cwiseSqrt.out 51 | /// 52 | EIGEN_DOC_UNARY_ADDONS(cwiseSqrt,square-root) 53 | /// 54 | /// \sa cwisePow(), cwiseSquare() 55 | /// 56 | EIGEN_DEVICE_FUNC 57 | inline const CwiseSqrtReturnType 58 | cwiseSqrt() const { return CwiseSqrtReturnType(derived()); } 59 | 60 | /// \returns an expression of the coefficient-wise signum of *this. 61 | /// 62 | /// Example: \include MatrixBase_cwiseSign.cpp 63 | /// Output: \verbinclude MatrixBase_cwiseSign.out 64 | /// 65 | EIGEN_DOC_UNARY_ADDONS(cwiseSign,sign function) 66 | /// 67 | EIGEN_DEVICE_FUNC 68 | inline const CwiseSignReturnType 69 | cwiseSign() const { return CwiseSignReturnType(derived()); } 70 | 71 | 72 | /// \returns an expression of the coefficient-wise inverse of *this. 73 | /// 74 | /// Example: \include MatrixBase_cwiseInverse.cpp 75 | /// Output: \verbinclude MatrixBase_cwiseInverse.out 76 | /// 77 | EIGEN_DOC_UNARY_ADDONS(cwiseInverse,inverse) 78 | /// 79 | /// \sa cwiseProduct() 80 | /// 81 | EIGEN_DEVICE_FUNC 82 | inline const CwiseInverseReturnType 83 | cwiseInverse() const { return CwiseInverseReturnType(derived()); } 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/alg/bipartite.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "global.h" 4 | 5 | void MinCostBipartiteMatching( 6 | const vector>>& bigraph, size_t num1, size_t num2, vector>& res, long& cost); 7 | 8 | void LiteMinCostMaxFlow(const vector>>& supplyToDemand, 9 | const vector& demandCap, 10 | size_t num1, 11 | size_t num2, 12 | vector>& res, 13 | int& cost); -------------------------------------------------------------------------------- /src/alg/lpsolve/inc/lp_Hash.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_lp_hash 2 | #define HEADER_lp_hash 3 | 4 | /* For row and column name hash tables */ 5 | 6 | typedef struct _hashelem 7 | { 8 | char *name; 9 | int index; 10 | struct _hashelem *next; 11 | struct _hashelem *nextelem; 12 | } hashelem; 13 | 14 | typedef struct /* _hashtable */ 15 | { 16 | hashelem **table; 17 | int size; 18 | int base; 19 | int count; 20 | struct _hashelem *first; 21 | struct _hashelem *last; 22 | } hashtable; 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | STATIC hashtable *create_hash_table(int size, int base); 29 | STATIC void free_hash_table(hashtable *ht); 30 | STATIC hashelem *findhash(const char *name, hashtable *ht); 31 | STATIC hashelem *puthash(const char *name, int index, hashelem **list, hashtable *ht); 32 | STATIC void drophash(const char *name, hashelem **list, hashtable *ht); 33 | STATIC void free_hash_item(hashelem **hp); 34 | STATIC hashtable *copy_hash_table(hashtable *ht, hashelem **list, int newsize); 35 | STATIC int find_var(lprec *lp, char *name, MYBOOL verbose); 36 | STATIC int find_row(lprec *lp, char *name, MYBOOL Unconstrained_rows_found); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* HEADER_lp_hash */ 43 | 44 | -------------------------------------------------------------------------------- /src/alg/lpsolve/inc/lp_mipbb.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_lp_mipbb 2 | #define HEADER_lp_mipbb 3 | 4 | #include "lp_types.h" 5 | #include "lp_utils.h" 6 | 7 | 8 | /* Bounds storage for B&B routines */ 9 | typedef struct _BBrec 10 | { 11 | struct _BBrec *parent; 12 | struct _BBrec *child; 13 | lprec *lp; 14 | int varno; 15 | int vartype; 16 | int lastvarcus; /* Count of non-int variables of the previous branch */ 17 | int lastrcf; 18 | int nodesleft; 19 | int nodessolved; 20 | int nodestatus; 21 | REAL noderesult; 22 | REAL lastsolution; /* Optimal solution of the previous branch */ 23 | REAL sc_bound; 24 | REAL *upbo, *lowbo; 25 | REAL UPbound, LObound; 26 | int UBtrack, LBtrack; /* Signals that incoming bounds were changed */ 27 | MYBOOL contentmode; /* Flag indicating if we "own" the bound vectors */ 28 | MYBOOL sc_canset; 29 | MYBOOL isSOS; 30 | MYBOOL isGUB; 31 | int *varmanaged; /* Extended list of variables managed by this B&B level */ 32 | MYBOOL isfloor; /* State variable indicating the active B&B bound */ 33 | MYBOOL UBzerobased; /* State variable indicating if bounds have been rebased */ 34 | } BBrec; 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | STATIC BBrec *create_BB(lprec *lp, BBrec *parentBB, MYBOOL dofullcopy); 41 | STATIC BBrec *push_BB(lprec *lp, BBrec *parentBB, int varno, int vartype, int varcus); 42 | STATIC MYBOOL initbranches_BB(BBrec *BB); 43 | STATIC MYBOOL fillbranches_BB(BBrec *BB); 44 | STATIC MYBOOL nextbranch_BB(BBrec *BB); 45 | STATIC MYBOOL strongbranch_BB(lprec *lp, BBrec *BB, int varno, int vartype, int varcus); 46 | STATIC MYBOOL initcuts_BB(lprec *lp); 47 | STATIC int updatecuts_BB(lprec *lp); 48 | STATIC MYBOOL freecuts_BB(lprec *lp); 49 | STATIC BBrec *findself_BB(BBrec *BB); 50 | STATIC int solve_LP(lprec *lp, BBrec *BB); 51 | STATIC int rcfbound_BB(BBrec *BB, int varno, MYBOOL isINT, REAL *newbound, MYBOOL *isfeasible); 52 | STATIC MYBOOL findnode_BB(BBrec *BB, int *varno, int *vartype, int *varcus); 53 | STATIC int solve_BB(BBrec *BB); 54 | STATIC MYBOOL free_BB(BBrec **BB); 55 | STATIC BBrec *pop_BB(BBrec *BB); 56 | 57 | STATIC int run_BB(lprec *lp); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | #endif /* HEADER_lp_mipbb */ 64 | 65 | -------------------------------------------------------------------------------- /src/alg/lpsolve/lib32/liblpsolve55.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple-fpga/059646fcaa0c8d77e4283f55be2bd5692862a039/src/alg/lpsolve/lib32/liblpsolve55.a -------------------------------------------------------------------------------- /src/alg/lpsolve/lib64/liblpsolve55.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple-fpga/059646fcaa0c8d77e4283f55be2bd5692862a039/src/alg/lpsolve/lib64/liblpsolve55.a -------------------------------------------------------------------------------- /src/alg/matching.h: -------------------------------------------------------------------------------- 1 | #ifndef _MATCHING_H_ 2 | #define _MATCHING_H_ 3 | 4 | #include "db/db.h" 5 | using namespace db; 6 | 7 | typedef long long s64; 8 | 9 | const int INF = 2147483647; 10 | 11 | struct Match; 12 | 13 | struct Point2d { 14 | double y, x; 15 | Point2d() : y(0), x(0) {} 16 | }; 17 | 18 | class DisjGraph { 19 | public: 20 | vector vertices; 21 | vector u; 22 | vector v; 23 | vector w; 24 | int CalcMaxWeightMatch(vector &matches); 25 | static void GetDisjointGraphs(const vector> &graph, 26 | vector &vDisjGraph); // ignore single-vertex disjoint graph 27 | static void StatGraphSize(const vector &graphs, unsigned step = 20); 28 | static void DivideByRegions(vector> &pointSets, vector &poss, unsigned maxSize = 2000); 29 | }; 30 | 31 | struct Edge { 32 | int v, u, w; 33 | Edge() {} 34 | Edge(const int &_v, const int &_u, const int &_w) : v(_v), u(_u), w(_w) {} 35 | }; 36 | 37 | struct Match { 38 | int u, v; 39 | Match(int _u, int _v) : u(_u), v(_v) {} 40 | }; 41 | 42 | class GenGraph { 43 | private: 44 | int n; 45 | vector> mat; 46 | 47 | int nMatches; 48 | s64 totWeight; 49 | vector mate; 50 | vector lab; 51 | 52 | int q_n; 53 | vector q; 54 | vector fa; 55 | vector col; 56 | vector slackv; 57 | 58 | int n_x; 59 | vector bel; 60 | vector> blofrom; 61 | vector> bloch; 62 | vector book; 63 | 64 | int GetEdgeDelta(const Edge &e); 65 | void UpdateSlackV(int v, int x); 66 | void CalcSlackV(int x); 67 | void QPush(int x); 68 | void SetMate(int xv, int xu); 69 | void SetBel(int x, int b); 70 | void Augment(int xv, int xu); 71 | int GetLca(int xv, int xu); 72 | void AddBlossom(int xv, int xa, int xu); 73 | void ExpandBlossom(int b); 74 | void ExpandBlossomFinal(int b); 75 | bool OnFoundEdge(const Edge &e); 76 | bool DoMatching(); 77 | 78 | public: 79 | GenGraph(int n); 80 | ~GenGraph(); 81 | void AddEdge(int u, int v, int w); 82 | void CalcMaxWeightMatch(); 83 | s64 GetTotWeight(); 84 | vector GetMate(); 85 | }; 86 | 87 | #endif -------------------------------------------------------------------------------- /src/alg/patoh/libpatoh.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple-fpga/059646fcaa0c8d77e4283f55be2bd5692862a039/src/alg/patoh/libpatoh.a -------------------------------------------------------------------------------- /src/cong/cong.h: -------------------------------------------------------------------------------- 1 | #include "cong_est_bb.h" 2 | #include "cong_gp.h" 3 | #include "cong_partition.h" -------------------------------------------------------------------------------- /src/cong/cong_est_base.cpp: -------------------------------------------------------------------------------- 1 | #include "cong_est_base.h" 2 | 3 | using namespace db; 4 | 5 | void CongEstBase::Run(bool stat) { 6 | InitDemand(); 7 | if (stat) StatDemand(); 8 | } 9 | 10 | bool CongEstBase::IsLUT2FF(Net* net) { 11 | if (net->pins.size() != 2) return false; 12 | unsigned iLUT = 0; 13 | unsigned iFF = 1; 14 | if (net->pins[iLUT]->instance->IsFF() && net->pins[iFF]->instance->IsLUT()) swap(iLUT, iFF); 15 | if (net->pins[iLUT]->instance->IsLUT() && net->pins[iFF]->instance->IsFF() && net->pins[iLUT]->type->name == "O" && 16 | net->pins[iFF]->type->name == "D" && net->pins[0]->instance->pack == net->pins[1]->instance->pack) { 17 | ++noNeedRoute; 18 | return true; 19 | } else 20 | return false; 21 | } 22 | 23 | void CongEstBase::StatDemand() const { 24 | const unsigned step = 50; 25 | double sum = 0, sumNonEmpty = 0; 26 | unsigned num = 0, numNonEmpty = 0; 27 | vector stat; 28 | vector statNonEmpty; 29 | for (int x = 0; x < database.sitemap_nx; ++x) 30 | for (int y = 0; y < database.sitemap_ny; ++y) { 31 | double d = siteDemand[x][y]; 32 | if (d > minDem) { 33 | sum += d; 34 | ++num; 35 | unsigned i = d / step; 36 | if (i >= stat.size()) { 37 | stat.resize(i + 1, 0); 38 | statNonEmpty.resize(i + 1, 0); 39 | } 40 | ++stat[i]; 41 | if (database.sites[x][y]->pack != NULL) { 42 | sumNonEmpty += d; 43 | ++numNonEmpty; 44 | ++statNonEmpty[i]; 45 | } 46 | } 47 | } 48 | printlog(LOG_INFO, "%u nets (LUT-FF) don't need routing", noNeedRoute); 49 | printlog(LOG_INFO, 50 | "all sites: avg_demand = %lf, #site = %u ; nonempty sites: avg_demand = %lf, #site = %u", 51 | sum / num, 52 | num, 53 | sumNonEmpty / numNonEmpty, 54 | numNonEmpty); 55 | for (unsigned i = 0; i < stat.size(); ++i) 56 | printlog(LOG_INFO, "#site in [%4d, %4d): %5d (%5d)", i * step, (i + 1) * step, stat[i], statNonEmpty[i]); 57 | } -------------------------------------------------------------------------------- /src/cong/cong_est_base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "db/db.h" 4 | 5 | class CongEstBase { 6 | public: 7 | vector> siteDemand; 8 | int noNeedRoute = 0; 9 | const double minDem = 0.00001; // ignore sites with demand smaller than this 10 | // supply under the most optimistic assumption 11 | const int horiSup = 208; // (24*1+16*2+8*6) * 2 12 | const int vertiSup = 256; // (21*1+14*2+2*3+8*4+7*5+1*6) + (20*1+18*2+8*4+8*5) 13 | 14 | void Run(bool stat = true); 15 | 16 | protected: 17 | bool IsLUT2FF(db::Net* net); // ignore nets from lut-o to ff-d 18 | virtual void InitDemand() = 0; 19 | void StatDemand() const; 20 | }; 21 | 22 | template 23 | void SwMapToSiteMap(vector>& swMap, vector>& siteMap) { 24 | assert((int)swMap.size() == db::database.switchbox_nx && (int)swMap[0].size() == db::database.switchbox_ny); 25 | siteMap = vector>(db::database.sitemap_nx, vector(db::database.sitemap_ny, 0)); 26 | for (int x = 0; x < db::database.sitemap_nx; ++x) 27 | for (int y = 0; y < db::database.sitemap_ny; ++y) siteMap[x][y] = swMap[db::SWCol(x)][y]; 28 | } -------------------------------------------------------------------------------- /src/cong/cong_est_bb.cpp: -------------------------------------------------------------------------------- 1 | #include "cong_est_bb.h" 2 | 3 | using namespace db; 4 | 5 | void CongEstBB::InitDemand() { 6 | noNeedRoute = 0; 7 | vector> swDemand(database.switchbox_nx, vector(database.switchbox_ny, 0)); 8 | database.setSwitchBoxPins(); 9 | vector> net2sw(database.nets.size()); 10 | for (const auto& sws : database.switchboxes) 11 | for (auto sw : sws) 12 | for (auto pin : sw->pins) 13 | if (pin != NULL && pin->net != NULL) net2sw[pin->net->id].push_back(sw); 14 | 15 | for (auto net : database.nets) { 16 | if (IsLUT2FF(net)) continue; 17 | Box bbox; 18 | for (auto sw : net2sw[net->id]) bbox.update(sw->x, sw->y); 19 | double totW = bbox.hp() + 1; 20 | unsigned nPins = net->pins.size(); 21 | if (nPins < 10) 22 | totW *= 1.06; 23 | else if (nPins < 20) 24 | totW *= 1.2; 25 | else if (nPins < 30) 26 | totW *= 1.4; 27 | else if (nPins < 50) 28 | totW *= 1.6; 29 | else if (nPins < 100) 30 | totW *= 1.8; 31 | else if (nPins < 200) 32 | totW *= 2.1; 33 | else 34 | totW *= 3.0; 35 | int numGCell = (bbox.x() + 1) * (bbox.y() + 1); 36 | double indW = totW / numGCell; 37 | for (int x = bbox.lx(); x <= bbox.ux(); ++x) 38 | for (int y = bbox.ly(); y <= bbox.uy(); ++y) swDemand[x][y] += indW; 39 | } 40 | SwMapToSiteMap(swDemand, siteDemand); 41 | } -------------------------------------------------------------------------------- /src/cong/cong_est_bb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cong_est_base.h" 4 | 5 | class CongEstBB : public CongEstBase { 6 | private: 7 | void InitDemand(); 8 | }; -------------------------------------------------------------------------------- /src/cong/cong_gp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "db/db.h" 4 | 5 | void AdjAreaByCong(vector &groups); 6 | 7 | void gp_cong(vector &groups, int iteration); -------------------------------------------------------------------------------- /src/cong/cong_partition.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "db/db.h" 4 | 5 | using namespace db; 6 | 7 | class Cluster { 8 | public: 9 | static unsigned numNonEmpty; 10 | static unsigned numEmpty; 11 | unsigned id; 12 | 13 | vector instIds; 14 | array children; 15 | unsigned cutSize = 0; 16 | 17 | Box bbox; 18 | double avgY; 19 | double area; 20 | 21 | Cluster() { 22 | children[0] = NULL; 23 | children[1] = NULL; 24 | } 25 | ~Cluster() { 26 | delete children[0]; 27 | delete children[1]; 28 | } 29 | void InitSeed(); 30 | void Partition(); 31 | void UpdateInfo(const vector>& instXY); 32 | unsigned maxCutSize(); 33 | void PrintLeaf() const; 34 | void Print() const; 35 | void GetResult(vector& clusters); 36 | }; 37 | 38 | bool ReallocByCluster(vector& groups); 39 | 40 | void PartitionPlFile(); 41 | 42 | // return cut size 43 | unsigned Bipartition(const vector& inputCluster, array, 2>& outputClusters); -------------------------------------------------------------------------------- /src/db/clkrgn.cpp: -------------------------------------------------------------------------------- 1 | #include "clkrgn.h" 2 | 3 | #include "db.h" 4 | using namespace db; 5 | 6 | ClkRgn::ClkRgn(string _name, int _lx, int _ly, int _hx, int _hy, int _cr_x, int _cr_y) { 7 | name = _name; 8 | lx = _lx; 9 | ly = _ly; 10 | hx = _hx + 1; 11 | hy = _hy + 1; 12 | cr_x = _cr_x; 13 | cr_y = _cr_y; 14 | 15 | hfcols.assign(hx - lx, vector(2, NULL)); 16 | for (int x = lx; x < hx; x++) { 17 | for (int y = 0; y < 2; y++) { 18 | database.hfcols[x][ly / 30 + y] = new HfCol(x, ly + y * 30, ly + (y + 1) * 30, this); 19 | hfcols[x - lx][y] = database.hfcols[x][ly / 30 + y]; 20 | } 21 | } 22 | } 23 | 24 | void ClkRgn::Init() { 25 | for (int x = lx; x < hx; x++) { 26 | for (int y = ly; y < hy; y++) { 27 | sites.push_back(database.getSite(x, y)); 28 | } 29 | } 30 | for (int x = lx; x < hx; x++) { 31 | for (int y = 0; y < 2; y++) { 32 | hfcols[x - lx][y]->Init(); 33 | } 34 | } 35 | } 36 | 37 | HfCol::HfCol(int _x, int _ly, int _hy, ClkRgn* _clkrgn) { 38 | x = _x; 39 | ly = _ly; 40 | hy = _hy; 41 | clkrgn = _clkrgn; 42 | } 43 | 44 | void HfCol::Init() { 45 | for (int y = ly; y < hy; y++) { 46 | sites.push_back(database.getSite(x, y)); 47 | } 48 | } -------------------------------------------------------------------------------- /src/db/clkrgn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | #include "net.h" 5 | 6 | namespace db { 7 | 8 | class Site; 9 | class ClkRgn; 10 | class HfCol; 11 | 12 | class ClkRgn { 13 | public: 14 | string name; 15 | int lx, ly, hx, hy; 16 | int cr_x, cr_y; 17 | 18 | std::vector sites; 19 | 20 | unordered_set clknets; 21 | vector> hfcols; 22 | 23 | ClkRgn(string _name, int _lx, int _ly, int _hx, int _hy, int _cr_x, int _cr_y); 24 | void Init(); 25 | }; 26 | 27 | class HfCol { 28 | public: 29 | int x, ly, hy; 30 | vector sites; 31 | unordered_set clknets; 32 | 33 | ClkRgn* clkrgn; 34 | 35 | HfCol(int _x, int _lx, int _hy, ClkRgn* _clkrgn); 36 | void Init(); 37 | }; 38 | } // namespace db 39 | -------------------------------------------------------------------------------- /src/db/group.cpp: -------------------------------------------------------------------------------- 1 | #include "group.h" 2 | #include "db.h" 3 | 4 | #include "../alg/matching.h" 5 | 6 | using namespace db; 7 | 8 | void Group::WriteGroups(const vector& groups, const string& fileNamePreFix) { 9 | #ifdef WRITE_GROUP 10 | ofstream os(fileNamePreFix + "_" + database.bmName + ".group"); 11 | if (os.fail()) { 12 | cerr << "Group::WriteGroups: cannot open file" << endl; 13 | return; 14 | } 15 | os.precision(numeric_limits::digits10 + 2); 16 | 17 | os << groups.size() << endl; 18 | for (auto g : groups) { 19 | os << g.id << endl; 20 | os << g.instances.size() << endl; 21 | for (auto inst : g.instances) { 22 | if (inst != NULL) { 23 | os << inst->id << ' '; 24 | // 2 conditions: 1. placed, 2. fixed. 25 | if (inst->slot != -1 && inst->fixed) 26 | os << inst->slot << ' '; 27 | else 28 | os << -1 << ' '; 29 | } else 30 | os << -1 << ' '; 31 | } 32 | os << endl; 33 | os << g.y << endl; 34 | os << g.x << endl; 35 | os << g.lastY << endl; 36 | os << g.lastX << endl; 37 | } 38 | 39 | os.close(); 40 | #else 41 | printlog(LOG_ERROR, "Group::WriteGroups: cannot be used in release mode"); 42 | #endif 43 | } 44 | 45 | void Group::ReadGroups(vector& groups, const string& fileNamePreFix) { 46 | #ifdef WRITE_GROUP 47 | groups.clear(); 48 | ifstream is(fileNamePreFix + "_" + database.bmName + ".group"); 49 | if (is.fail()) { 50 | cerr << "Group::ReadGroups: cannot open file" << endl; 51 | return; 52 | } 53 | 54 | unsigned int gsize; 55 | is >> gsize; 56 | groups.resize(gsize); 57 | for (auto& g : groups) { 58 | is >> g.id; 59 | unsigned int isize; 60 | is >> isize; 61 | g.instances.resize(isize, NULL); 62 | for (unsigned int i = 0; i < isize; ++i) { 63 | int instId; 64 | is >> instId; 65 | if (instId != -1) { 66 | g.instances[i] = database.instances[instId]; 67 | is >> g.instances[i]->slot; 68 | } 69 | } 70 | is >> g.y; 71 | is >> g.x; 72 | is >> g.lastY; 73 | is >> g.lastX; 74 | for (auto inst : g.instances) { 75 | if (inst != NULL && inst->slot != -1 && !inst->inputFixed) { 76 | database.place(inst, g.x, g.y, inst->slot); 77 | inst->fixed = true; 78 | } 79 | } 80 | } 81 | 82 | is.close(); 83 | #else 84 | printlog(LOG_ERROR, "Group::ReadGroups: cannot be used in release mode"); 85 | #endif 86 | } 87 | 88 | void Group::Print() { 89 | string instList = ""; 90 | for (auto inst : instances) 91 | if (inst != NULL) instList = instList + " " + to_string(inst->id); 92 | printlog(LOG_INFO, 93 | "group %d:(x,y)=(%.3lf,%.3lf),(lastX,lastY)=(%.3lf,%.3lf),instances=[%s]", 94 | id, 95 | x, 96 | y, 97 | lastX, 98 | lastY, 99 | instList.c_str()); 100 | } 101 | 102 | bool Group::IsBLE() { return instances[0]->IsLUTFF(); } 103 | 104 | SiteType::Name Group::GetSiteType() const { 105 | for (auto inst : instances) 106 | if (inst != NULL) return inst->master->resource->siteType->name; 107 | printlog(LOG_ERROR, "unknow type"); 108 | return SiteType::SLICE; 109 | } 110 | 111 | bool Group::IsTypeMatch(Site* site) const { return site->type->name == GetSiteType(); } 112 | 113 | bool Group::InClkBox(Site* site) const { return lgBox.dist(site->x, site->y) == 0; } -------------------------------------------------------------------------------- /src/db/group.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | #include "site.h" 5 | 6 | namespace db { 7 | 8 | class Instance; 9 | class SiteType; 10 | 11 | class Group { 12 | public: 13 | int id; 14 | vector instances; 15 | double x, y; 16 | double lastX, lastY; 17 | double areaScale; 18 | Box lgBox; 19 | 20 | Group() 21 | : id(-1), x(0.0), y(0.0), lastX(0.0), lastY(0.0), areaScale(1.0), lgBox(INT_MAX, INT_MAX, INT_MIN, INT_MIN) {} 22 | void Print(); 23 | bool IsBLE(); 24 | bool IsTypeMatch(Site* site) const; 25 | bool InClkBox(Site* site) const; 26 | SiteType::Name GetSiteType() const; 27 | 28 | static void WriteGroups(const vector& groups, const string& fileNamePreFix); 29 | static void ReadGroups(vector& groups, const string& fileNamePreFix); 30 | }; 31 | } // namespace db -------------------------------------------------------------------------------- /src/db/instance.cpp: -------------------------------------------------------------------------------- 1 | #include "instance.h" 2 | #include "db.h" 3 | 4 | using namespace db; 5 | 6 | /***** Master *****/ 7 | Master::Name Master::NameString2Enum(const string &name) { 8 | if (name == "LUT1") 9 | return LUT1; 10 | else if (name == "LUT2") 11 | return LUT2; 12 | else if (name == "LUT3") 13 | return LUT3; 14 | else if (name == "LUT4") 15 | return LUT4; 16 | else if (name == "LUT5") 17 | return LUT5; 18 | else if (name == "LUT6") 19 | return LUT6; 20 | else if (name == "FDRE") 21 | return FDRE; 22 | else if (name == "CARRY8") 23 | return CARRY8; 24 | else if (name == "DSP48E2") 25 | return DSP48E2; 26 | else if (name == "RAMB36E2") 27 | return RAMB36E2; 28 | else if (name == "IBUF") 29 | return IBUF; 30 | else if (name == "OBUF") 31 | return OBUF; 32 | else if (name == "BUFGCE") 33 | return BUFGCE; 34 | else { 35 | cerr << "unknown master name: " << name << endl; 36 | exit(1); 37 | } 38 | } 39 | 40 | string masterNameStrs[] = { 41 | "LUT1", "LUT2", "LUT3", "LUT4", "LUT5", "LUT6", "FDRE", "CARRY8", "DSP48E2", "RAMB36E2", "IBUF", "OBUF", "BUFGCE"}; 42 | string Master::NameEnum2String(const Master::Name &name) { return masterNameStrs[name]; } 43 | 44 | Master::Master(Name n) { 45 | this->name = n; 46 | this->resource = NULL; 47 | } 48 | 49 | Master::Master(const Master &master) { 50 | name = master.name; 51 | resource = master.resource; 52 | pins.resize(master.pins.size()); 53 | for (int i = 0; i < (int)master.pins.size(); i++) { 54 | pins[i] = new PinType(*master.pins[i]); 55 | } 56 | } 57 | 58 | Master::~Master() { 59 | for (int i = 0; i < (int)pins.size(); i++) { 60 | delete pins[i]; 61 | } 62 | } 63 | 64 | void Master::addPin(PinType &pin) { pins.push_back(new PinType(pin)); } 65 | 66 | PinType *Master::getPin(const string &name) { 67 | for (int i = 0; i < (int)pins.size(); i++) { 68 | if (pins[i]->name == name) { 69 | return pins[i]; 70 | } 71 | } 72 | return NULL; 73 | } 74 | 75 | /***** Instance *****/ 76 | Instance::Instance() { 77 | id = -1; 78 | master = NULL; 79 | pack = NULL; 80 | slot = -1; 81 | fixed = false; 82 | inputFixed = false; 83 | } 84 | 85 | Instance::Instance(const string &name, Master *master) { 86 | this->id = -1; 87 | this->name = name; 88 | this->master = master; 89 | this->pack = NULL; 90 | this->slot = -1; 91 | this->fixed = false; 92 | this->inputFixed = false; 93 | this->pins.resize(master->pins.size()); 94 | for (int i = 0; i < (int)master->pins.size(); i++) { 95 | this->pins[i] = new Pin(this, i); 96 | } 97 | } 98 | 99 | Instance::Instance(const Instance &instance) { 100 | id = -1; 101 | name = instance.name; 102 | master = instance.master; 103 | pack = NULL; 104 | slot = -1; 105 | fixed = instance.fixed; 106 | inputFixed = instance.inputFixed; 107 | pins.resize(instance.pins.size()); 108 | for (int i = 0; i < (int)instance.pins.size(); i++) { 109 | // pins[i] = new Pin(*instance.pins[i]); 110 | pins[i] = new Pin(this, i); 111 | } 112 | } 113 | 114 | Instance::~Instance() { 115 | for (int i = 0; i < (int)pins.size(); i++) { 116 | delete pins[i]; 117 | } 118 | } 119 | 120 | Pin *Instance::getPin(const string &name) { 121 | for (int i = 0; i < (int)pins.size(); i++) { 122 | if (pins[i]->type->name == name) { 123 | return pins[i]; 124 | } 125 | } 126 | return NULL; 127 | } 128 | 129 | bool Instance::matchSiteType(SiteType *type) { return type->matchInstance(this); } 130 | -------------------------------------------------------------------------------- /src/db/instance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | #include "site.h" 5 | 6 | namespace db { 7 | 8 | class PinType; 9 | class Pin; 10 | class Resource; 11 | class SiteType; 12 | class Pack; 13 | 14 | // TODO: rename to CellType 15 | class Master { 16 | public: 17 | enum Name { 18 | LUT1, 19 | LUT2, 20 | LUT3, 21 | LUT4, 22 | LUT5, 23 | LUT6, // LUT 24 | FDRE, // FF 25 | CARRY8, // CARRY 26 | DSP48E2, // DSP 27 | RAMB36E2, // RAM 28 | IBUF, 29 | OBUF, 30 | BUFGCE // IO: input buf, output buf, clock buf 31 | }; 32 | static Name NameString2Enum(const string &name); 33 | static string NameEnum2String(const Master::Name &name); 34 | 35 | Name name; 36 | Resource *resource; 37 | vector pins; 38 | 39 | Master(Name n); 40 | Master(const Master &master); 41 | ~Master(); 42 | 43 | void addPin(PinType &pin); 44 | PinType *getPin(const string &name); 45 | }; 46 | 47 | // TODO: rename to Cell 48 | class Instance { 49 | public: 50 | int id; 51 | string name; 52 | Master *master; 53 | Pack *pack; 54 | int slot; 55 | bool fixed; 56 | bool inputFixed; 57 | vector pins; 58 | 59 | Instance(); 60 | Instance(const string &name, Master *master); 61 | Instance(const Instance &instance); 62 | ~Instance(); 63 | 64 | inline bool IsLUT() { return master->resource->name == Resource::LUT; } 65 | inline bool IsFF() { return master->name == Master::FDRE; } 66 | inline bool IsCARRY() { return master->name == Master::CARRY8; } 67 | inline bool IsLUTFF() { return IsLUT() || IsFF(); } // TODO: check CARRY8 68 | inline bool IsDSP() { return master->name == Master::DSP48E2; } 69 | inline bool IsRAM() { return master->name == Master::RAMB36E2; } 70 | inline bool IsDSPRAM() { return IsDSP() || IsRAM(); } 71 | inline bool IsIO() { return master->resource->name == Resource::IO; } 72 | 73 | Pin *getPin(const string &name); 74 | bool matchSiteType(SiteType *type); 75 | }; 76 | 77 | } // namespace db -------------------------------------------------------------------------------- /src/db/net.cpp: -------------------------------------------------------------------------------- 1 | #include "net.h" 2 | #include "db.h" 3 | 4 | using namespace db; 5 | 6 | /***** PinType *****/ 7 | PinType::PinType() { type = 'x'; } 8 | 9 | PinType::PinType(const string &name, char type) { 10 | this->name = name; 11 | this->type = type; 12 | } 13 | 14 | PinType::PinType(const PinType &pintype) { 15 | name = pintype.name; 16 | type = pintype.type; 17 | } 18 | 19 | /***** Pin *****/ 20 | Pin::Pin() { 21 | this->instance = NULL; 22 | this->net = NULL; 23 | this->type = NULL; 24 | } 25 | 26 | Pin::Pin(Instance *instance, int i) { 27 | this->instance = instance; 28 | this->net = NULL; 29 | this->type = instance->master->pins[i]; 30 | } 31 | 32 | Pin::Pin(Instance *instance, const string &pin) { 33 | this->instance = instance; 34 | this->net = NULL; 35 | this->type = instance->master->getPin(pin); 36 | } 37 | 38 | Pin::Pin(const Pin &pin) { 39 | instance = pin.instance; 40 | net = pin.net; 41 | type = pin.type; 42 | } 43 | 44 | /***** Net *****/ 45 | Net::Net() {} 46 | 47 | Net::Net(const string &name) { 48 | this->name = name; 49 | this->pins.resize(1, NULL); 50 | this->isClk = false; 51 | } 52 | 53 | Net::Net(const Net &net) { 54 | name = net.name; 55 | pins = net.pins; 56 | isClk = net.isClk; 57 | id = net.id; 58 | } 59 | 60 | Net::~Net() {} 61 | 62 | void Net::addPin(Pin *pin) { 63 | if (pin->type->type == 'o' || pin->type->type == 'I') { 64 | if (pins[0] != NULL) { 65 | cerr << "source pin duplicated" << endl; 66 | } else { 67 | pins[0] = pin; 68 | pin->net = this; 69 | return; 70 | } 71 | } 72 | pins.push_back(pin); 73 | pin->net = this; 74 | } -------------------------------------------------------------------------------- /src/db/net.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | 5 | namespace db { 6 | 7 | class Instance; 8 | class Net; 9 | class Site; 10 | 11 | class PinType { 12 | public: 13 | string name; 14 | char type; 15 | /* 16 | I = primary input 17 | O = primary output 18 | i = input 19 | o = output 20 | c = clock 21 | e = control 22 | */ 23 | PinType(); 24 | PinType(const string &name, char type); 25 | PinType(const PinType &pintype); 26 | }; 27 | 28 | class Pin { 29 | public: 30 | Instance *instance; 31 | Net *net; 32 | PinType *type; 33 | 34 | Pin(); 35 | Pin(Instance *instance, int i); 36 | Pin(Instance *instance, const string &pin); 37 | Pin(const Pin &pin); 38 | }; 39 | 40 | class Net { 41 | public: 42 | int id; 43 | std::string name; 44 | std::vector pins; 45 | bool isClk; 46 | 47 | Net(); 48 | Net(const string &name); 49 | Net(const Net &net); 50 | ~Net(); 51 | 52 | void addPin(Pin *pin); 53 | }; 54 | 55 | } // namespace db -------------------------------------------------------------------------------- /src/db/site.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | 5 | namespace db { 6 | 7 | class Master; 8 | class Instance; 9 | class SiteType; 10 | class Pack; 11 | 12 | class Resource { 13 | public: 14 | enum Name { LUT, FF, CARRY8, DSP48E2, RAMB36E2, IO }; 15 | static Name NameString2Enum(const string &name); 16 | static string NameEnum2String(const Resource::Name &name); 17 | 18 | Name name; 19 | SiteType *siteType; 20 | vector masters; 21 | 22 | Resource(Name n); 23 | Resource(const Resource &resource); 24 | 25 | void addMaster(Master *master); 26 | }; 27 | 28 | class SiteType { 29 | public: 30 | enum Name { SLICE, DSP, BRAM, IO }; 31 | static Name NameString2Enum(const string &name); 32 | static string NameEnum2String(const SiteType::Name &name); 33 | 34 | int id; 35 | Name name; 36 | vector resources; 37 | 38 | SiteType(Name n); 39 | SiteType(const SiteType &sitetype); 40 | 41 | void addResource(Resource *resource); 42 | void addResource(Resource *resource, int count); 43 | 44 | bool matchInstance(Instance *instance); 45 | }; 46 | 47 | class Site { 48 | public: 49 | SiteType *type; 50 | Pack *pack; 51 | int x, y; 52 | int w, h; 53 | Site(); 54 | Site(int x, int y, SiteType *sitetype); 55 | // center 56 | inline double cx() { return x + 0.5 * w; } 57 | inline double cy() { return y + 0.5 * h; } 58 | }; 59 | 60 | class Pack { 61 | public: 62 | SiteType *type; 63 | Site *site; 64 | vector instances; 65 | int id; 66 | void print(); 67 | bool IsEmpty(); 68 | Pack(); 69 | Pack(SiteType *type); 70 | }; 71 | 72 | } // namespace db -------------------------------------------------------------------------------- /src/db/swbox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | 5 | namespace db { 6 | 7 | class Site; 8 | class Pin; 9 | 10 | class SwitchBox { 11 | public: 12 | int x, y; 13 | std::vector sites; 14 | std::vector connections; 15 | std::vector pins; 16 | // for global routing 17 | std::vector supply; 18 | std::vector demand; 19 | 20 | SwitchBox(); 21 | SwitchBox(int x, int y); 22 | SwitchBox(const SwitchBox &switchbox); 23 | 24 | static bool getSwitchBoxOffset(int i, int &x, int &y); 25 | }; 26 | 27 | } // namespace db -------------------------------------------------------------------------------- /src/dp/dp.cpp: -------------------------------------------------------------------------------- 1 | #include "db/db.h" 2 | #include "dp_main.h" 3 | #include "dp_data.h" 4 | #include "pack/pack.h" 5 | #include "global.h" 6 | 7 | using namespace db; 8 | 9 | void dplace(vector &groups, const int numIter) { 10 | srand(0); // fix the seed for consistence 11 | 12 | printlog(LOG_INFO, ""); 13 | printlog(LOG_INFO, " = = = = begin detailed placement = = = = "); 14 | 15 | DPData dpData(groups); 16 | DPPack dpPack(groups, dpData); 17 | DPBle dpBle(groups, dpData); 18 | 19 | double originHpwl = database.getHPWL(), befHpwl, aftHpwl = 0, finalHpwl; 20 | for (int i = 0; i < numIter; i++) { 21 | befHpwl = (i == 0) ? originHpwl : database.getHPWL(); 22 | 23 | dpBle.Run(); 24 | dpPack.Run(); 25 | 26 | aftHpwl = database.getHPWL(); 27 | double improveRatio = (befHpwl - aftHpwl) * 100.0 / befHpwl; 28 | printlog(LOG_INFO, 29 | "dp iter %d:\tbefHpwl=%.0lf, aftHpwl=%.0lf, impr_rate=%.3lf%%", 30 | i, 31 | befHpwl, 32 | aftHpwl, 33 | improveRatio); 34 | printlog(LOG_INFO, "***********"); 35 | 36 | if (abs(improveRatio) < 0.1) { 37 | break; 38 | } 39 | } 40 | 41 | finalHpwl = aftHpwl; 42 | printlog(LOG_INFO, 43 | "WL Before DP: %.0lf, WL After DP: %.0lf, improveRatio: %.3lf%%", 44 | originHpwl, 45 | finalHpwl, 46 | (originHpwl - finalHpwl) * 100.0 / originHpwl); 47 | 48 | if (!database.isPlacementValid()) { 49 | printlog(LOG_ERROR, "dp not legal"); 50 | } 51 | 52 | maxLutFfCon(dpData); 53 | } -------------------------------------------------------------------------------- /src/dp/dp.h: -------------------------------------------------------------------------------- 1 | #ifndef _DP_DP_H_ 2 | #define _DP_DP_H_ 3 | 4 | void dplace(vector &groups, const int numIter = 10); 5 | 6 | #endif -------------------------------------------------------------------------------- /src/dp/dp_data.cpp: -------------------------------------------------------------------------------- 1 | #include "dp_data.h" 2 | 3 | using namespace db; 4 | 5 | extern bool legCLB1Succ; // true; 6 | 7 | DPData::DPData(vector& _groups) : groups(_groups) { 8 | useCLB1 = legCLB1Succ; 9 | 10 | // build clb map and group map 11 | clbMap.assign(database.sitemap_nx, vector(database.sitemap_ny, NULL)); 12 | for (int x = 0; x < database.sitemap_nx; x++) { 13 | for (int y = 0; y < database.sitemap_ny; y++) { 14 | if (database.getSite(x, y)->type->name == SiteType::SLICE) { 15 | clbMap[x][y] = NewCLB(); 16 | } 17 | } 18 | } 19 | groupMap.resize(database.sitemap_nx, vector>(database.sitemap_ny)); 20 | for (unsigned g = 0; g < groups.size(); g++) { 21 | int gx = groups[g].x; 22 | int gy = groups[g].y; 23 | groupMap[gx][gy].push_back(groups[g].id); 24 | if (groups[g].IsBLE()) { 25 | if (!clbMap[gx][gy]->AddInsts(groups[g])) assert(false); 26 | } 27 | } 28 | 29 | vector inst2Gid(database.instances.size(), -1); 30 | for (const auto& group : groups) { 31 | for (unsigned i = 0; i < group.instances.size(); i++) { 32 | if (group.instances[i] != NULL) { 33 | inst2Gid[group.instances[i]->id] = group.id; 34 | } 35 | } 36 | } 37 | colrgnData.Init(groups, inst2Gid); 38 | 39 | congEst.Run(); 40 | } 41 | 42 | DPData::~DPData() { 43 | for (int x = 0; x < database.sitemap_nx; x++) { 44 | for (int y = 0; y < database.sitemap_ny; y++) { 45 | if (database.getSite(x, y)->type->name == SiteType::SLICE) { 46 | delete clbMap[x][y]; 47 | } 48 | } 49 | } 50 | 51 | vector resultGroups; 52 | for (int x = 0; x < database.sitemap_nx; x++) { 53 | for (int y = 0; y < database.sitemap_ny; y++) { 54 | for (auto gid : groupMap[x][y]) { 55 | resultGroups.push_back(groups[gid]); 56 | resultGroups[resultGroups.size() - 1].id = resultGroups.size() - 1; 57 | } 58 | } 59 | } 60 | groups = move(resultGroups); 61 | } 62 | 63 | bool DPData::IsClkMoveLeg(Group& group, Site* site) { 64 | vector gid2Move = {group.id}; 65 | 66 | return colrgnData.IsClkMoveLeg(gid2Move, site, groups); 67 | } 68 | 69 | bool DPData::IsClkMoveLeg(Pack* pack, Site* site) { 70 | vector gid2Move = groupMap[pack->site->cx()][pack->site->cy()]; 71 | 72 | return colrgnData.IsClkMoveLeg(gid2Move, site, groups); 73 | } 74 | 75 | bool DPData::IsClkMoveLeg(const vector>& pairs) { 76 | vector> gid2Move(pairs.size()); 77 | vector sites(pairs.size()); 78 | 79 | for (unsigned i = 0; i < pairs.size(); i++) { 80 | gid2Move[i] = groupMap[pairs[i].first->site->cx()][pairs[i].first->site->cy()]; 81 | sites[i] = pairs[i].second; 82 | } 83 | 84 | return colrgnData.IsClkMoveLeg(gid2Move, sites, groups); 85 | } 86 | 87 | bool DPData::WorsenCong(Site* src, Site* dst) { 88 | // auto d = congEst.siteDemand[dst->x][dst->y]; 89 | // return d > 500 && d > congEst.siteDemand[src->x][src->y]; 90 | return false; 91 | } -------------------------------------------------------------------------------- /src/dp/dp_data.h: -------------------------------------------------------------------------------- 1 | #ifndef _DP_DP_DATA_H_ 2 | #define _DP_DP_DATA_H_ 3 | 4 | #include "db/db.h" 5 | #include "pack/clb.h" 6 | #include "lgclk/lgclk_data.h" 7 | #include "cong/cong.h" 8 | 9 | using namespace db; 10 | 11 | class DPData { 12 | private: 13 | CongEstBB congEst; 14 | bool useCLB1; 15 | vector& groups; 16 | 17 | public: 18 | ColrgnData colrgnData; 19 | vector> clbMap; 20 | vector>> groupMap; 21 | 22 | inline CLBBase* NewCLB() { 23 | if (useCLB1) 24 | return new CLB1; 25 | else 26 | return new CLB2; 27 | } 28 | 29 | bool IsClkMoveLeg(Group& group, Site* site); 30 | bool IsClkMoveLeg(Pack* pack, Site* site); 31 | bool IsClkMoveLeg(const vector>& pairs); 32 | 33 | bool WorsenCong(Site* src, Site* dst); 34 | 35 | DPData(vector& groups); 36 | ~DPData(); 37 | }; 38 | 39 | #endif -------------------------------------------------------------------------------- /src/dp/dp_main.h: -------------------------------------------------------------------------------- 1 | #ifndef _DP_DP_MAIN_H_ 2 | #define _DP_DP_MAIN_H_ 3 | 4 | #include "db/db.h" 5 | #include "pack/clb.h" 6 | #include "./dp_data.h" 7 | 8 | using namespace db; 9 | 10 | class DPPack { 11 | private: 12 | vector> netToPacks; 13 | vector> packToNets; 14 | vector> netBox; 15 | 16 | vector& groups; 17 | DPData& dpData; 18 | 19 | void UpdatePackInfo(); 20 | void PartialUpdate(Pack* curPack, Site* targetSite, bool updateClk = true); 21 | void UpdateGroupXY(Site* site); 22 | void UpdateDpData(const vector>& pairs, SiteType::Name type); 23 | 24 | double GetHpwl(); 25 | 26 | void SwapPack(Site* curSite, Site* candSite); 27 | double TrySwap(Site* curSite, Site* candSite); 28 | void ClkAndCongFilter(Pack* pack, vector& candSites); 29 | 30 | void GlobalPackSwap(SiteType::Name type); 31 | void BipartiteDP(SiteType::Name type, int minNumSites); 32 | 33 | public: 34 | DPPack(vector& _groups, DPData& _dpData); 35 | void Run(); 36 | }; 37 | 38 | class DPBle { 39 | private: 40 | vector> netToGids; 41 | vector& groups; 42 | 43 | void PartialUpdate(Group& group, Site* targetSite, bool updateClk = true); 44 | void ChainUpdate(vector& path, vector& clbChain, vector>& lgorderChain); 45 | void UpdateGroupInfo(); 46 | void DumpToDB(); 47 | bool IsGroupMovable(Group& group, CLBBase*& sourceCLB, vector& sourceGroup); 48 | bool MoveGroupToSite(Site* site, Group& group, CLBBase*& sourceCLB, vector& sourceGroup); 49 | 50 | double GetHpwl(); 51 | 52 | void SortCandSitesByAlign(Group& group, vector& candSites); 53 | void SortCandSitesByDisp(Group& group, vector& candSites); 54 | 55 | Site* MoveTowardOptrgn(Group& group, Box& optrgn, CLBBase*& sourceCLB, vector& sourceGroup); 56 | bool OptrgnChainMove(Group& group); 57 | void GlobalEleSwap(); 58 | void GlobalEleMove(); 59 | 60 | public: 61 | vector> groupToNets; 62 | vector> netBox; 63 | DPData& dpData; 64 | 65 | DPBle(vector& _groups, DPData& _dpData); 66 | void Run(); 67 | }; 68 | 69 | #endif -------------------------------------------------------------------------------- /src/eval.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BM_PATH=${BENCHMARK_PATH?"Need to set environment variable BENCHMARK_PATH"} 3 | 4 | BM_ABBR=(e{1..4} f{01..12} c{1..5} cf{01..13}) 5 | BM_LONG=(FPGA-example{1..4} FPGA{01..12} clk_design{1..5} CLK-FPGA{01..13}) 6 | BM16_NUM=16 7 | BM_NUM=${#BM_ABBR[@]} 8 | 9 | DATE=`date +"%m%d"` 10 | BM=$1 11 | 12 | DONE="false" 13 | for ((i=0; i<$BM_NUM; ++i)); do 14 | if [ $BM = ${BM_ABBR[i]} ] ; then 15 | if [ $i -lt $BM16_NUM ] ; then 16 | YEAR=16 17 | VIVADO_VERSION=2015.4 18 | else 19 | YEAR=17 20 | VIVADO_VERSION=2016.4 21 | fi 22 | INPUT_DCP=${BM_PATH}/ispd20$YEAR/${BM_LONG[i]}/design.dcp 23 | INPUT_PL=${BM_LONG[i]}.pl 24 | DONE="yes" 25 | break 26 | fi 27 | done 28 | if [ $DONE != "yes" ] ; then 29 | echo "ERROR: no benchmark with name: $BM" 30 | fi 31 | 32 | rm -f tmp.tcl 33 | 34 | echo "open_checkpoint $INPUT_DCP" >> tmp.tcl 35 | echo "place_design -placement $INPUT_PL" >> tmp.tcl 36 | # echo "report_utilization -file $BM_$DATE.util" >> tmp.tcl 37 | echo "route_design" >> tmp.tcl 38 | echo "report_route_status" >> tmp.tcl 39 | # echo "write_checkpoint -force $BM_$DATE.dcp" >> tmp.tcl 40 | 41 | echo "/opt/Xilinx/Vivado/${VIVADO_VERSION}/bin/vivado -mode batch -source tmp.tcl -log vivado_$DATE.log" 42 | /opt/Xilinx/Vivado/${VIVADO_VERSION}/bin/vivado -mode batch -source tmp.tcl -log vivado_$DATE.log 43 | 44 | rm -f tmp.tcl 45 | -------------------------------------------------------------------------------- /src/global.h: -------------------------------------------------------------------------------- 1 | #ifndef _GLOBAL_H_ 2 | #define _GLOBAL_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include "utils/log.h" 32 | #include "utils/misc.h" 33 | #include "utils/geo.h" 34 | 35 | using namespace std; 36 | 37 | class Setting { 38 | public: 39 | string io_out; 40 | string io_aux; 41 | string io_nodes; 42 | string io_nets; 43 | string io_pl; 44 | string io_wts; 45 | string io_scl; 46 | string io_lib; 47 | }; 48 | 49 | extern Setting setting; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/gp/gp.cpp: -------------------------------------------------------------------------------- 1 | #include "../global.h" 2 | 3 | #include "gp_data.h" 4 | #include "gp_main.h" 5 | #include "gp.h" 6 | 7 | void gplace(vector &groups) { 8 | printlog(LOG_INFO, ""); 9 | gp_copy_in(groups, true); 10 | GP_Main(); 11 | gp_copy_out(); 12 | } 13 | -------------------------------------------------------------------------------- /src/gp/gp.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_GP_H_ 2 | #define _GP_GP_H_ 3 | 4 | #include "gp_setting.h" 5 | 6 | void gplace(vector &groups); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/gp/gp_data.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_DATA_H_ 2 | #define _GP_DATA_H_ 3 | 4 | #include "db/db.h" 5 | #include "gp_spread.h" 6 | 7 | using namespace db; 8 | 9 | // BASICS 10 | extern int numNodes; 11 | extern int numCells; 12 | extern int numMacros; 13 | extern int numPads; 14 | 15 | extern int numNets; 16 | extern int numPins; 17 | extern int numFences; 18 | 19 | extern double coreLX, coreLY; 20 | extern double coreHX, coreHY; 21 | 22 | extern vector > cellNet; 23 | extern vector > netCell; 24 | 25 | extern vector netWeight; 26 | 27 | extern vector cellX; 28 | extern vector cellY; 29 | extern vector cellW; 30 | extern vector cellH; 31 | 32 | // LOWER BOUND 33 | // last positions 34 | extern vector lastVarX; 35 | extern vector lastVarY; 36 | // nearest fence region 37 | extern vector cellFenceX; 38 | extern vector cellFenceY; 39 | extern vector cellFenceDist; 40 | extern vector cellFenceRect; 41 | extern vector cellFence; 42 | 43 | // UPPER BOUND 44 | // local target density 45 | extern vector > binTD; 46 | extern int numDBinX; 47 | extern int numDBinY; 48 | extern double DBinW; 49 | extern double DBinH; 50 | // legalization bin 51 | extern vector > > LGGrid; // information of each bin [fence][binx][biny] 52 | extern vector > LGTD; // target density of each bin [binx][biny] 53 | extern vector > OFBins; // [fence][bin] 54 | extern vector > > OFMap; // mark if a bin is handled [fence][binx][biny] 55 | extern int LGNumX; 56 | extern int LGNumY; 57 | extern double LGBinW; 58 | extern double LGBinH; 59 | extern int LGBinSize; // in number of rows 60 | // area 61 | extern vector totalFArea; 62 | extern vector totalUArea; 63 | extern vector totalCArea; 64 | // region 65 | class FRect { 66 | public: 67 | double lx, ly; 68 | double hx, hy; 69 | FRect(); 70 | FRect(double lx, double ly, double hx, double hy); 71 | ~FRect(); 72 | }; 73 | class FRegion { 74 | public: 75 | SiteType *type; 76 | vector rects; 77 | FRegion(); 78 | FRegion(SiteType *type); 79 | 80 | void addRect(FRect rect); 81 | }; 82 | extern vector regions; 83 | 84 | void gp_copy_in(vector &group, bool layout); 85 | void gp_copy_out(); 86 | 87 | double hpwl(double *wx = NULL, double *wy = NULL); 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/gp/gp_main.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_GP_MAIN_ 2 | #define _GP_GP_MAIN_ 3 | 4 | void GP_Main(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/gp/gp_qsolve.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_QSOLVE_H_ 2 | #define _GP_QSOLVE_H_ 3 | 4 | #include "gp_setting.h" 5 | 6 | void lowerBound(double epsilon, double pseudoAlpha, int repeat, LBMode mode, double maxDisp = -1); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/gp/gp_region.cpp: -------------------------------------------------------------------------------- 1 | #include "gp_data.h" 2 | #include "gp_region.h" 3 | 4 | void findCellRegionDist() { 5 | for (int i = 0; i < numCells; i++) { 6 | // for each cell, find nearest region block 7 | double x = cellX[i]; 8 | double y = cellY[i]; 9 | int region = cellFence[i]; 10 | vector::iterator ri = regions[region].rects.begin(); 11 | vector::iterator re = regions[region].rects.end(); 12 | double dist = -1; 13 | double regionx = -1; 14 | double regiony = -1; 15 | int regionr = -1; 16 | for (int r = 0; ri != re; ++ri, r++) { 17 | double distx = 0; 18 | double disty = 0; 19 | double rx = x; 20 | double ry = y; 21 | double lx = ri->lx; 22 | double ly = ri->ly; 23 | double hx = ri->hx; 24 | double hy = ri->hy; 25 | if (x < lx) { 26 | distx = lx - x; 27 | rx = lx; 28 | } else if (x > hx) { 29 | distx = x - hx; 30 | rx = hx; 31 | } 32 | if (y < ly) { 33 | disty = ly - y; 34 | ry = ly; 35 | } else if (y > hy) { 36 | disty = y - hy; 37 | ry = hy; 38 | } 39 | if (r == 0 || distx + disty < dist) { 40 | dist = distx + disty; 41 | regionx = rx; 42 | regiony = ry; 43 | regionr = r; 44 | if (dist == 0) { 45 | break; 46 | } 47 | } 48 | } 49 | if (regionr < 0) { 50 | cerr << "no rect defined for region " << region << endl; 51 | exit(1); 52 | } 53 | cellFenceX[i] = regionx; 54 | cellFenceY[i] = regiony; 55 | cellFenceRect[i] = regionr; 56 | cellFenceDist[i] = dist; 57 | } 58 | } -------------------------------------------------------------------------------- /src/gp/gp_region.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_REGION_H_ 2 | #define _GP_REGION_H_ 3 | 4 | void findCellRegionDist(); 5 | void legalizeRegion(); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/gp/gp_setting.h: -------------------------------------------------------------------------------- 1 | #ifndef _GP_SETTING_H_ 2 | #define _GP_SETTING_H_ 3 | 4 | #include "global.h" 5 | 6 | enum LBMode { LBModeSimple = 1, LBModeFenceBBox = 2, LBModeFenceRect = 3 }; 7 | 8 | class GPSetting { 9 | public: 10 | int nThreads; 11 | 12 | int initIter; 13 | int mainWLIter; 14 | int mainCongIter; 15 | int finalIter; 16 | int lbIter; 17 | int ubIter; 18 | double pseudoNetWeightBegin; 19 | double pseudoNetWeightEnd; 20 | bool degreeNetWeight; 21 | double ioNetWeight; 22 | double expandBoxRatio; 23 | double expandBoxLimit; 24 | 25 | double pseudoNetWeightRatioX; 26 | double pseudoNetWeightRatioY; 27 | 28 | double lutArea, ffArea, dspArea, ramArea; // standard area for lut and ff 29 | double areaScale; 30 | 31 | bool enableFence; 32 | bool packed; 33 | bool useLastXY; 34 | 35 | void setDefault(); 36 | void init(); 37 | void set0(); 38 | void set1(); 39 | void set2(); 40 | void set2c(); 41 | void set3(); 42 | void set3c(); 43 | void print(); 44 | }; 45 | 46 | extern GPSetting gpSetting; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/gp/gp_spread.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPREAD_H_ 2 | #define _SPREAD_H_ 3 | 4 | class LGBin { 5 | public: 6 | double lx, ly, hx, hy; 7 | vector cells; 8 | double uArea; // usable area 9 | double fArea; // free area 10 | double cArea; // cell area 11 | LGBin() { 12 | lx = ly = hx = hy = -1; 13 | uArea = fArea = cArea = 0; 14 | } 15 | LGBin(double lx, double ly, double hx, double hy) { 16 | this->lx = lx; 17 | this->ly = ly; 18 | this->hx = hx; 19 | this->hy = hy; 20 | uArea = fArea = cArea = 0; 21 | } 22 | }; 23 | 24 | class OFBin { 25 | public: 26 | int x, y; // overfill center 27 | int region; 28 | double ofArea; 29 | double ofRatio; 30 | double aofArea; 31 | double aofRatio; 32 | int lx, ly; // expanded region 33 | int hx, hy; // expanded region 34 | double exCArea; 35 | double exUArea; 36 | double exFArea; 37 | OFBin(int _r, int _x, int _y) { 38 | lx = hx = x = _x; 39 | ly = hy = y = _y; 40 | region = _r; 41 | ofArea = 0.0; 42 | ofRatio = 0.0; 43 | aofArea = 0.0; 44 | aofRatio = 0.0; 45 | exCArea = 0.0; 46 | exFArea = 0.0; 47 | exUArea = 0.0; 48 | } 49 | OFBin() { 50 | lx = hx = x = -1; 51 | ly = hy = y = -1; 52 | region = -1; 53 | ofArea = 0.0; 54 | ofRatio = 0.0; 55 | aofArea = 0.0; 56 | aofRatio = 0.0; 57 | exCArea = 0.0; 58 | exFArea = 0.0; 59 | exUArea = 0.0; 60 | } 61 | 62 | bool operator<(const OFBin &b) const { return ofRatio > b.ofRatio; } 63 | }; 64 | 65 | void spreadCells(int binSize, int times); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/lg/lg.cpp: -------------------------------------------------------------------------------- 1 | #include "lg.h" 2 | #include "lg_main.h" 3 | #include "../lgclk/lgclk.h" 4 | #include "../lgclk/lgclk_plan.h" 5 | 6 | bool legCLB1Succ = false; // true; 7 | 8 | void legalize(vector &groups, lgSiteOrder siteOrder, lgRetrunGroup retGroup) { 9 | printlog(LOG_INFO, " = = = = legalization = = = = "); 10 | 11 | double begHpwl = 0; 12 | 13 | Legalizer legalizer(groups); 14 | legalizer.Init(USE_CLB2); 15 | 16 | begHpwl = legalizer.GetHpwl(); 17 | 18 | if (!legalizer.RunAll(siteOrder, DEFAULT)) { 19 | // perform lg with SortGroupsByLGBox 20 | legalizer.Init(USE_CLB2); 21 | legalizer.RunAll(siteOrder, GROUP_LGBOX); 22 | } 23 | 24 | legalizer.GetResult(retGroup); 25 | double aftHpwl = legalizer.GetHpwl(); 26 | printlog(LOG_INFO, 27 | "WL Before LG: %.0f, WL After LG:%.0f, Gap: %.2f%%", 28 | begHpwl, 29 | aftHpwl, 30 | (aftHpwl - begHpwl) / begHpwl * 100); 31 | 32 | if (retGroup == UPDATE_XY_ORDER) { 33 | ClkLegalize(groups); 34 | if (!database.isPlacementValid()) printlog(LOG_ERROR, "legalization failed"); 35 | } 36 | } 37 | 38 | void legalize_partial(vector &groups) { 39 | printlog(LOG_INFO, ""); 40 | printlog(LOG_INFO, " = = = = legalize DSP and BRAM = = = = "); 41 | Legalizer legalizer(groups); 42 | legalizer.Init(USE_CLB2); 43 | 44 | double begHpwl = legalizer.GetHpwl(); 45 | legalizer.RunPartial(); 46 | legalizer.GetResult(UPDATE_XY); 47 | double aftHpwl = legalizer.GetHpwl(); 48 | printlog(LOG_INFO, 49 | "WL Before LG: %.0f, WL After LG:%.0f, Gap: %.2f%%", 50 | begHpwl, 51 | aftHpwl, 52 | (aftHpwl - begHpwl) / begHpwl * 100); 53 | } 54 | 55 | void planning(vector &groups) { 56 | if (database.crmap_nx == 0) return; 57 | printlog(LOG_INFO, ""); 58 | printlog(LOG_INFO, " = = = = clock region planning = = = = "); 59 | 60 | ClkrgnPlan plan; 61 | 62 | plan.Init(groups); 63 | plan.Shrink(groups); 64 | plan.Expand(groups); 65 | plan.Apply(groups); 66 | } -------------------------------------------------------------------------------- /src/lg/lg.h: -------------------------------------------------------------------------------- 1 | #ifndef _LG_H_ 2 | #define _LG_H_ 3 | 4 | #include "db/db.h" 5 | 6 | using namespace db; 7 | 8 | enum lgSiteOrder { SITE_HPWL, SITE_HPWL_SMALL_WIN, SITE_ALIGN }; 9 | 10 | enum lgGroupOrder { DEFAULT, GROUP_LGBOX }; 11 | 12 | enum lgRetrunGroup { GET_SLICE, UPDATE_XY, UPDATE_XY_ORDER, NO_UPDATE }; 13 | 14 | enum lgPackMethod { USE_CLB1, USE_CLB2 }; 15 | 16 | void planning(vector &groups); 17 | void legalize(vector &groups, lgSiteOrder siteOrder, lgRetrunGroup retGroup); 18 | void legalize_partial(vector &groups); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/lg/lg_data.h: -------------------------------------------------------------------------------- 1 | #ifndef _LG_DATA_H_ 2 | #define _LG_DATA_H_ 3 | 4 | #include "../db/db.h" 5 | #include "../global.h" 6 | #include "../pack/clb.h" 7 | #include "lg.h" 8 | 9 | using namespace db; 10 | 11 | class LGData { 12 | private: 13 | vector &groups; 14 | 15 | void InitNetInfo(); 16 | void InitGroupInfo(); 17 | void InitLGStat(); 18 | void InitClkInfo(); 19 | 20 | void Group2Pack(); 21 | void UpdateGroupXY(); 22 | void UpdateGroupXYnOrder(); 23 | 24 | public: 25 | vector groupsX; 26 | vector groupsY; 27 | vector groupIds; 28 | 29 | vector>> groupMap; 30 | vector>> placedGroupMap; 31 | vector> clbMap; 32 | 33 | vector> netBox; 34 | 35 | vector inst2Gid; 36 | vector> group2Nets; 37 | vector> net2Gids; 38 | 39 | void PartialUpdate(Group &group, Site *targetSite); 40 | void ChainUpdate(vector &path, vector &clbChain, vector> &lgorderChain); 41 | 42 | LGData(vector &_groups); 43 | void Init(lgPackMethod packMethod); 44 | void GetResult(lgRetrunGroup retGroup); 45 | 46 | // statistic variables 47 | int invokeCount; 48 | int successCount; 49 | vector> dispPerSite; 50 | vector dispPerGroup; 51 | vector> nPinPerSite; 52 | vector nPinPerGroup; 53 | 54 | void GetDispStatics(); 55 | void GetPackStatics(); 56 | double GetHpwl(); 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/lg/lg_dp_chain.h: -------------------------------------------------------------------------------- 1 | #ifndef _LG_CHAIN_H_ 2 | #define _LG_CHAIN_H_ 3 | 4 | #include "db/db.h" 5 | #include "./lg_data.h" 6 | #include "./lg_main.h" 7 | #include "dp/dp_main.h" 8 | 9 | using namespace db; 10 | 11 | class ChainFinder { 12 | private: 13 | vector &groups; 14 | 15 | const unsigned depth = 5; 16 | const unsigned breadth = 35; 17 | double maxTotDisp; 18 | double maxDisp; 19 | 20 | vector> clbMap; 21 | vector inChain; 22 | 23 | bool checkColrgn; 24 | 25 | void Backtrack(int gid2Move); 26 | 27 | public: 28 | vector gidChain; 29 | vector clbChain; 30 | vector> orderChain; 31 | vector posChain; 32 | vector> colrgnChain; 33 | 34 | bool DFS(LGData &lgData, ChainmoveTarget optTarget); 35 | bool Init(Group &group, LGData &lgData); 36 | 37 | bool DFS(DPBle &dpBle); 38 | void Init(Group &group, DPBle &dpBle); 39 | 40 | ChainFinder(vector &_groups); 41 | }; 42 | 43 | #endif -------------------------------------------------------------------------------- /src/lg/lg_dp_utils.cpp: -------------------------------------------------------------------------------- 1 | #include "lg_dp_utils.h" 2 | 3 | void SqueezeCandSites(vector& candSites, const Group& group, bool rmDup) { 4 | if (!rmDup) { 5 | // squeeze out the invalid cand sites 6 | unsigned num = 0; 7 | for (unsigned i = 0; i < candSites.size(); ++i) { 8 | if (group.IsTypeMatch(candSites[i]) && group.InClkBox(candSites[i])) candSites[num++] = candSites[i]; 9 | } 10 | candSites.resize(num); 11 | } else { 12 | // squeeze out the duplicate and invalid cand sites 13 | unordered_set sites; 14 | 15 | for (auto site : candSites) { 16 | if (group.IsTypeMatch(site) && group.InClkBox(site)) sites.insert(site); 17 | } 18 | candSites.clear(); 19 | for (auto site : sites) candSites.push_back(site); 20 | sort(candSites.begin(), candSites.end(), [](Site* a, Site* b) { 21 | return a->x < b->x || (a->x == b->x && a->y < b->y); 22 | }); // avoid machine diff 23 | } 24 | } 25 | 26 | // squeeze out the duplicate and wrong type cand sites 27 | void SqueezeCandSites(vector& candSites, SiteType::Name type) { 28 | unordered_set sites; 29 | for (auto site : candSites) { 30 | if (site->type->name == type) sites.insert(site); 31 | } 32 | candSites.clear(); 33 | for (auto site : sites) candSites.push_back(site); 34 | sort(candSites.begin(), candSites.end(), [](Site* a, Site* b) { 35 | return a->x < b->x || (a->x == b->x && a->y < b->y); 36 | }); // avoid machine diff 37 | } 38 | 39 | // squeeze out the invalid cand sites and those father from the optrgn 40 | void SqueezeCandSites(vector& candSites, const Group& group, Site* orgSite, Box& optrgn) { 41 | double orgDist2Optrgn = optrgn.udist(orgSite->cx(), orgSite->cy()); 42 | 43 | unsigned num = 0; 44 | for (unsigned i = 0; i < candSites.size(); ++i) { 45 | if (group.IsTypeMatch(candSites[i]) && group.InClkBox(candSites[i])) { 46 | double tarDist2Optrgn = optrgn.udist(candSites[i]->cx(), candSites[i]->cy()); 47 | 48 | if (orgDist2Optrgn >= tarDist2Optrgn) { 49 | candSites[num++] = candSites[i]; 50 | } 51 | } 52 | } 53 | candSites.resize(num); 54 | } 55 | 56 | Box GetOptimalRegion(const pair pinLoc, 57 | const vector& nets, 58 | const vector>& netBox) { 59 | double lx, hx, ly, hy; 60 | vector boxX, boxY; 61 | 62 | bool selfConn = true; 63 | 64 | for (auto net : nets) { 65 | if (net->isClk) continue; 66 | const auto& b = netBox[net->id]; 67 | if (b.size() == 1) continue; 68 | boxX.push_back(b.x.ol(pinLoc.first)); 69 | boxX.push_back(b.x.ou(pinLoc.first)); 70 | boxY.push_back(b.y.ol(pinLoc.second)); 71 | boxY.push_back(b.y.ou(pinLoc.second)); 72 | 73 | selfConn = false; 74 | } 75 | 76 | if (!selfConn) { 77 | GetMedianTwo(boxX, lx, hx); 78 | GetMedianTwo(boxY, ly, hy); 79 | } else { 80 | // smaller region? 81 | lx = ly = 0; 82 | hx = database.sitemap_nx - 1; 83 | hy = database.sitemap_ny - 1; 84 | } 85 | 86 | return Box(hx, hy, lx, ly); 87 | } -------------------------------------------------------------------------------- /src/lg/lg_dp_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "db/db.h" 4 | using namespace db; 5 | 6 | // squeeze out the invalid cand sites 7 | void SqueezeCandSites(vector &candSites, const Group &group, bool rmDup = false); 8 | // squeeze out the duplicate and wrong type cand sites 9 | void SqueezeCandSites(vector &candSites, SiteType::Name type); 10 | // squeeze out the invalid cand sites and those father from the optrgn 11 | void SqueezeCandSites(vector &candSites, const Group &group, Site *orgSite, Box &optrgn); 12 | 13 | Box GetOptimalRegion(const pair pinLoc, 14 | const vector &nets, 15 | const vector> &netBox); -------------------------------------------------------------------------------- /src/lg/lg_main.h: -------------------------------------------------------------------------------- 1 | #ifndef _LG_MAIN_H_ 2 | #define _LG_MAIN_H_ 3 | 4 | #include "db/db.h" 5 | #include "./lg_data.h" 6 | using namespace db; 7 | 8 | enum ChainmoveTarget { DISP_OPT, MAX_DISP_OPT }; 9 | 10 | class Legalizer { 11 | private: 12 | lgSiteOrder siteOrder; 13 | lgGroupOrder groupOrder; 14 | 15 | vector &groups; 16 | 17 | bool MergeGroupToSite(Site *site, Group &group, bool fixDspRam = true); 18 | bool AssignPackToSite(Site *site, Group &group); 19 | 20 | void SortCandSitesByHpwl(vector &candSites, const Group &group); 21 | void SortCandSitesByPins(vector &candSites, const Group &group); 22 | void SortCandSitesByAlign(vector &candSites, const Group &group); 23 | void SortGroupsByGroupsize(); 24 | void SortGroupsByPins(); 25 | void SortGroupsByLGBox(); 26 | void SortGroupsByOptRgnDist(); 27 | 28 | void BipartiteLeg(SiteType::Name type, int minNumSites); 29 | int ChainMove(Group &group, ChainmoveTarget optTarget); 30 | 31 | public: 32 | LGData lgData; 33 | 34 | Legalizer(vector &_groups); 35 | void Init(lgPackMethod packMethod); 36 | void GetResult(lgRetrunGroup retGroup); 37 | 38 | bool RunAll(lgSiteOrder siteOrder, lgGroupOrder groupOrder); 39 | void RunPartial(); 40 | 41 | double GetHpwl(); 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/lgclk/lgclk.cpp: -------------------------------------------------------------------------------- 1 | #include "lgclk.h" 2 | #include "lgclk_colrgn.h" 3 | 4 | void ClkLegalize(vector &groups) { 5 | if (database.crmap_nx == 0) return; 6 | printlog(LOG_INFO, ""); 7 | printlog(LOG_INFO, " = = = = column region legalization = = = = "); 8 | 9 | double begHpwl = database.getHPWL(); 10 | 11 | ColrgnLG colrgnLG; 12 | 13 | colrgnLG.Init(groups); 14 | colrgnLG.RunLG(groups); 15 | colrgnLG.Clear(); 16 | 17 | double aftHpwl = database.getHPWL(); 18 | printlog(LOG_INFO, 19 | "WL Before LG: %.0f, WL After LG:%.0f, Gap: %.2f%%", 20 | begHpwl, 21 | aftHpwl, 22 | (aftHpwl - begHpwl) / begHpwl * 100); 23 | 24 | return; 25 | } -------------------------------------------------------------------------------- /src/lgclk/lgclk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | #include "../db/db.h" 5 | 6 | using namespace db; 7 | 8 | void ClkLegalize(vector &groups); -------------------------------------------------------------------------------- /src/lgclk/lgclk_colrgn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "lgclk_data.h" 4 | #include "../global.h" 5 | #include "../db/db.h" 6 | #include "../pack/clb.h" 7 | 8 | using namespace db; 9 | 10 | class MapUpdater { 11 | public: 12 | vector updatedClbs; 13 | vector> updatedGroups; 14 | vector sites; 15 | 16 | void Update(vector> &clbMap, vector>> &groupMap); 17 | }; 18 | 19 | class ColrgnLG { 20 | private: 21 | vector> clbMap; 22 | vector>> groupMap; 23 | 24 | vector inst2Gid; 25 | vector groupIds; 26 | 27 | ColrgnData colrgnData; 28 | 29 | void InitGroupInfo(vector &groups); 30 | void InitPlInfo(vector &groups); 31 | 32 | void GetResult(vector &groups); 33 | 34 | bool IsClkMovable( 35 | Net *net, LGColrgn *srcColrgn, vector &groups, vector &gid2Move, MapUpdater &srcUpdater); 36 | double GetMove(vector &gid2Move, 37 | LGColrgn *srcColrgn, 38 | vector &groups, 39 | MapUpdater &destUpdater, 40 | double &disp, 41 | const double curMin); 42 | void Update(vector &gid2Move, MapUpdater &srcUpdater, MapUpdater &destUpdater, vector &groups); 43 | 44 | public: 45 | void Init(vector &groups); 46 | void Clear(); 47 | 48 | void RunLG(vector &groups); 49 | }; -------------------------------------------------------------------------------- /src/lgclk/lgclk_data.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | #include "../db/db.h" 5 | 6 | using namespace db; 7 | 8 | class LGHfcol; 9 | class LGColrgn; 10 | class LGClkrgn; 11 | 12 | class LGHfcol { 13 | public: 14 | HfCol *col; 15 | LGColrgn *colrgn; 16 | LGClkrgn *clkrgn; 17 | unordered_set nets; 18 | 19 | LGHfcol(HfCol *_col, vector>>> &clkMap); 20 | 21 | void Update(vector>>> &clkMap); 22 | }; 23 | 24 | class LGColrgn { 25 | public: 26 | int lx, hx, ly, hy; 27 | vector cols; 28 | unordered_set nets; 29 | 30 | LGColrgn(int _lx, int _ly, int _hx, int _hy, const vector> &lgHfcols); 31 | 32 | void Update(); 33 | }; 34 | 35 | class LGClkrgn { 36 | public: 37 | ClkRgn *clkrgn; 38 | unordered_set nets; 39 | 40 | LGClkrgn(ClkRgn *_clkrgn); 41 | }; 42 | 43 | class ClkBox { 44 | public: 45 | Net *net; 46 | int lx, ly, hx, hy; 47 | LGClkrgn *lrgn, *hrgn; 48 | 49 | DynamicBox box; 50 | 51 | vector GetClkrgns(vector> &lgClkrgns); 52 | }; 53 | 54 | class ColrgnData { 55 | public: 56 | vector> lgHfcols; 57 | vector> lgColrgns; 58 | int colrgn_nx, colrgn_ny; 59 | 60 | vector> group2Clk; 61 | 62 | vector>>> clkMap; 63 | void Init(vector &groups, const vector &inst2Gid); 64 | void Clear(); 65 | void Update(vector &gid2Move, vector &sites, vector &groups); 66 | 67 | LGColrgn *GetColrgn(int x, int y); 68 | unordered_map GetColrgnData(int x, int y); 69 | 70 | bool IsClkMoveLeg(const vector &gid2Move, Site *site, vector &groups, bool strict = true); 71 | bool IsClkMoveLeg(const vector> &gid2Move, const vector &sites, vector &groups); 72 | }; -------------------------------------------------------------------------------- /src/lgclk/lgclk_plan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../global.h" 4 | #include "../db/db.h" 5 | #include "lgclk_data.h" 6 | 7 | using namespace db; 8 | 9 | class ClkrgnPlan { 10 | private: 11 | vector> lgClkrgns; 12 | 13 | vector>>> clkMap; 14 | 15 | vector inst2Gid; 16 | vector groupIds; 17 | vector> group2Clk; 18 | 19 | void InitGroupInfo(vector &groups); 20 | void InitClkInfo(vector &groups); 21 | 22 | double GetMove(ClkBox &clkbox, 23 | LGClkrgn *clkrgn, 24 | vector &groups, 25 | vector &gid2Move, 26 | double &pos, 27 | double &disp, 28 | int &dir); 29 | bool IsMoveLeg(vector &gid2Move, double pos, int dir, vector &groups); 30 | void UpdatePl(LGClkrgn *clkrgn, vector &gid2Move, double &tarPos, vector &groups); 31 | 32 | void PrintStat(vector &groups); 33 | 34 | LGClkrgn *GetClkrgn(int x, int y); 35 | 36 | public: 37 | unordered_map clkboxs; 38 | 39 | void Init(vector &groups); 40 | void Shrink(vector &groups); 41 | void Expand(vector &groups); 42 | void Apply(vector &groups); 43 | }; -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "db/db.h" 2 | using namespace db; 3 | #include "gp/gp.h" 4 | #include "pack/pack.h" 5 | #include "lg/lg.h" 6 | #include "dp/dp.h" 7 | #include "cong/cong.h" 8 | 9 | Setting setting; 10 | 11 | bool get_args(int argc, char** argv); 12 | 13 | int main(int argc, char** argv) { 14 | // init_log(LOG_ALL); 15 | init_log(LOG_NORMAL); 16 | 17 | log() << "-----------------------------------" << endl; 18 | log() << " RippleFPGA " << endl; 19 | log() << " Chinese University of Hong Kong " << endl; 20 | log() << "-----------------------------------" << endl; 21 | if (!get_args(argc, argv)) return 1; 22 | database.readAux(setting.io_aux); 23 | database.readLib(setting.io_lib); 24 | database.readNodes(setting.io_nodes); 25 | database.readScl(setting.io_scl); 26 | database.readPl(setting.io_pl); 27 | database.readNets(setting.io_nets); 28 | 29 | database.setup(); 30 | database.print(); 31 | 32 | gpSetting.init(); 33 | 34 | vector groups(database.instances.size()); 35 | for (unsigned int i = 0; i < groups.size(); i++) { 36 | groups[i].instances.push_back(database.instances[i]); 37 | groups[i].id = i; 38 | } 39 | 40 | // reallocate 41 | gpSetting.set0(); 42 | gplace(groups); 43 | ReallocByCluster(groups); 44 | 45 | // pack bles 46 | gpSetting.set1(); 47 | gplace(groups); 48 | packble(groups); 49 | 50 | // gp with bles 51 | gpSetting.set2(); 52 | gplace(groups); 53 | if (database.crmap_nx == 0) { 54 | gpSetting.set2c(); 55 | gp_cong(groups, 3); 56 | } 57 | legalize_partial(groups); 58 | gpSetting.set3(); 59 | gplace(groups); 60 | 61 | // legalize 62 | planning(groups); 63 | legalize_partial(groups); 64 | if (database.crmap_nx == 0) 65 | legalize(groups, SITE_HPWL, UPDATE_XY_ORDER); 66 | else 67 | legalize(groups, SITE_HPWL_SMALL_WIN, UPDATE_XY_ORDER); 68 | dplace(groups); 69 | 70 | database.writePl(setting.io_out); 71 | 72 | printlog(LOG_INFO, "hpwl = %.1lf", database.getHPWL(true)); 73 | printlog(LOG_INFO, "#net = %d / %d", database.getRouteNet(), database.nets.size()); 74 | 75 | database.draw("cells.png", Database::DrawInstances); 76 | 77 | log() << "-----------------------------------" << endl; 78 | log() << " RippleFPGA terminating... " << endl; 79 | log() << "-----------------------------------" << endl; 80 | return 0; 81 | } 82 | 83 | bool get_args(int argc, char** argv) { 84 | bool valid = true; 85 | for (int a = 1; a < argc; a++) { 86 | if (strcmp(argv[a], "-out") == 0) { 87 | setting.io_out.assign(argv[++a]); 88 | unsigned pos = setting.io_out.find_last_of('.'); 89 | database.bmName = setting.io_out.substr(0, pos); 90 | } else if (strcmp(argv[a], "-aux") == 0) { 91 | setting.io_aux.assign(argv[++a]); 92 | } else { 93 | cerr << "unknown parameter: " << argv[a] << endl; 94 | valid = false; 95 | } 96 | } 97 | if (valid && setting.io_aux == "") valid = false; 98 | if (!valid) log() << "usage: " << argv[0] << " -aux [-out ]" << endl; 99 | return valid; 100 | } 101 | -------------------------------------------------------------------------------- /src/pack/ble.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLE_H_ 2 | #define _BLE_H_ 3 | 4 | #include "../alg/matching.h" 5 | 6 | class BleType { // clk, sr should always be checked after ce, in case that ce.size()==0 7 | public: 8 | Net* clk; 9 | Net* sr; 10 | vector ce; // always ordered for a ble 11 | // for dev 12 | void Print() const; 13 | }; 14 | 15 | // For BleGroup 16 | bool IsMatched(BleType& type1, BleType& type2); 17 | 18 | class CLB1; 19 | 20 | class BLE { 21 | friend class BleGroup; 22 | friend class CLB1; 23 | 24 | private: 25 | unsigned int id; 26 | CLB1* clb = NULL; 27 | 28 | vector LUTs; // max size 2 29 | vector FFs; // max size 2 30 | BleType type; 31 | 32 | BLE& operator=(const BLE& rhs); 33 | 34 | public: 35 | BLE(unsigned int i = 0) { id = i; } 36 | 37 | // read only 38 | const unsigned int& id_ = id; 39 | // CLB1* const & clb_ = clb; 40 | const vector& LUTs_ = LUTs; 41 | const vector& FFs_ = FFs; 42 | const BleType& type_ = type; 43 | 44 | void SetId(unsigned int i) { id = i; } 45 | void AddLUT(Instance* inst); 46 | void AddFF(Instance* inst); 47 | bool IsLUTCompatWith(BLE* rhs); 48 | bool IsFFCompatWith(BLE* rhs); 49 | void MergeInto(BLE* ble); 50 | void Empty(); 51 | void Print() const; 52 | void GetResult(Group& group) const; 53 | 54 | // for bles 55 | static void StatBles(const vector& bles); 56 | static void CheckBles(const vector& bles); 57 | }; 58 | 59 | #endif -------------------------------------------------------------------------------- /src/pack/clb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clb1.h" 4 | #include "clb2.h" -------------------------------------------------------------------------------- /src/pack/clb1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ble.h" 4 | #include "clb_base.h" 5 | 6 | struct BleGroupBackup { 7 | vector ble_ptrs; 8 | vector ble_cnts; 9 | BleType type; 10 | }; 11 | 12 | class BleGroup { 13 | friend class CLB1; 14 | 15 | private: 16 | vector bles; 17 | BleType type; 18 | void BackupBleGroup(BleGroupBackup& backup) const; 19 | void RecoverBleGroup(const BleGroupBackup& backup); 20 | void UpdateTypeFrom1FF(const BleType& newType); // for fixBleGroup ONLY 21 | void Empty(); 22 | }; 23 | 24 | class CLB1 : public CLBBase { 25 | using CLBBase::CLBBase; 26 | 27 | private: 28 | BleGroup fixBleGroups[2]; // max size 4 for each, either has 2-FF BLE or is full 29 | BleGroup fleBleGroup; // max 4 types, sr, clk should be the same 30 | BleGroup blesWith0FF; 31 | vector allBles; // ref 32 | 33 | // Small gadgets 34 | void RemoveInBles(const BLE* ble, vector& bles); 35 | void Backup(pair>& backup); // TODO: why it doesn't work? 36 | void Recover(const pair>& backup); 37 | void StatFle( 38 | vector>& fleTypes, unsigned& maxDem, unsigned& minDem, unsigned& maxDemId, unsigned& minDemId); 39 | void MoveOneTypeToOneGroup(vector>& fleTypes, 40 | unsigned tarType, 41 | unsigned tarGroup); // fleTypes is not updated (to destroy) 42 | void MoveTwoTypesToOneGroup(vector>& fleTypes, 43 | unsigned tarType1, 44 | unsigned tarType2, 45 | unsigned tarGroup); 46 | void MoveToOneGroupFirst(vector bles, unsigned tarGroup); 47 | 48 | // Major steps 49 | bool AddBleWith1FF(BLE* const ble); 50 | bool AddBleIntoFixGroup(BleGroup& fixGroup, BLE* const ble); 51 | void MoveFleToFix(); 52 | void PostAdjust(); // ignore updating BleType 53 | 54 | // Interfaces 55 | bool AddBle(BLE* const ble); 56 | 57 | public: 58 | ~CLB1() { 59 | for (auto ble : allBles) delete ble; 60 | allBles.clear(); 61 | } 62 | bool AddInsts(const Group& group); 63 | inline bool IsEmpty() { return allBles.size() == 0; } 64 | void GetResult(Group& group); 65 | void GetFinalResult(Group& group) { GetResult(group); } 66 | void Print() const; 67 | }; -------------------------------------------------------------------------------- /src/pack/clb2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clb_base.h" 4 | #include "clb2_lutpg.h" 5 | 6 | class CLB2ResultBase; 7 | class CLB2Result1; 8 | class CLB2Result2; 9 | 10 | class CLB2 : public CLBBase { 11 | friend CLB2ResultBase; 12 | friend CLB2Result1; 13 | friend CLB2Result2; 14 | 15 | private: 16 | vector> LUTs; // max 8 17 | LUTPairGraph LUTs2; 18 | array, 4> FFs; // max 4 for each 19 | unsigned numLUT = 0, numFF = 0; 20 | bool AddInsts(const vector& insts); 21 | void BreakLUTPairs(); 22 | 23 | public: 24 | CLB2(int i) : CLBBase(i), LUTs2(i) {} 25 | CLB2() : CLBBase(), LUTs2(id) {} 26 | ~CLB2(){}; 27 | bool AddInst(Instance* inst); 28 | bool AddInsts(const Group& group) { return AddInsts(group.instances); } 29 | inline bool IsEmpty() { return numLUT == 0 && numFF == 0; } 30 | void GetResult(Group& group); // const; TODO: make it const 31 | void GetFinalResult(Group& group); 32 | void Print() const; 33 | }; 34 | 35 | class CLB2Stat { 36 | public: 37 | unsigned numConn, numImposs, numBroken; 38 | void Init(); 39 | void Print(); 40 | const CLB2Stat& operator+=(const CLB2Stat& rhs); 41 | }; 42 | 43 | class CLB2TotStat { 44 | public: 45 | unsigned numEasyClb, numTotClb, numShare; 46 | CLB2Stat r1, r2, tot; 47 | void Init(); 48 | void Print(); 49 | }; 50 | 51 | extern CLB2TotStat clb2stat; -------------------------------------------------------------------------------- /src/pack/clb2_lutpg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clb_base.h" 4 | #include "alg/matching.h" 5 | 6 | class LUTPairGraph { 7 | private: 8 | int id; 9 | vector insts; 10 | vector> graph; // id -> num of shared inputs 11 | vector> pairs; // -1 for empty 12 | int tried = 0; // insts [0, tried] have tried 13 | 14 | bool CanMerge(int i, int j); 15 | int NumPossibleFFs(const vector& ffs); 16 | Instance* GetInst(int i); 17 | 18 | public: 19 | LUTPairGraph(int i) { id = i; } 20 | bool AddLUT(Instance* lut, bool check = true); 21 | void CommitGreedy(); 22 | void CommitMinSlots(); 23 | void CommitFast(); 24 | void CommitBalance(const array, 4>& FFs); 25 | void Export(vector>& LUTs); 26 | void Print(); 27 | }; -------------------------------------------------------------------------------- /src/pack/clb2_res1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clb2.h" 4 | #include "clb2_res_base.h" 5 | 6 | class CLB2Result1 : public CLB2ResultBase { 7 | using CLB2ResultBase::CLB2ResultBase; 8 | 9 | public: 10 | void Run(); 11 | 12 | private: 13 | // Major steps 14 | void Prepare(); 15 | void Commit2FF(LUTPair& l2f, FFLoc& ff1, FFLoc& ff2); 16 | void Commit1FF(LUTPair& l2f, FFLoc& ff); 17 | 18 | // Small gadgets 19 | bool CanMoveOrSwapIntoGroup(unsigned g, Instance* ff); 20 | bool CanMoveOrSwapIntoHalf(unsigned h, Instance* ff); 21 | void MoveFF(FFLoc& ff, unsigned tarG); 22 | bool SwapFF(FFLoc& ff, unsigned tarG); 23 | bool MoveOrSwapIntoGroup(FFLoc& ff, unsigned tarG); 24 | bool SwapGroups(unsigned srcG, unsigned tarG); 25 | void CommitEasyFF(Instance* ff, unsigned slot); // for easy mode only 26 | }; -------------------------------------------------------------------------------- /src/pack/clb2_res2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clb2.h" 4 | #include "clb2_res_base.h" 5 | #include "alg/lpsolve/inc/lp_lib.h" 6 | 7 | class CLB2Result2 : public CLB2ResultBase { 8 | using CLB2ResultBase::CLB2ResultBase; 9 | 10 | public: 11 | void Run(); 12 | 13 | private: 14 | // Major steps 15 | void Prepare(); 16 | void SolveByILP(); 17 | 18 | // Small gadgets 19 | unsigned nLUT, nFF, nVar; 20 | // l: lut; h: half; f: ff; g: group; lf: lut-ff conn 21 | // b(l,h): #lut * 2 22 | // b(f,g): #ff * 4 23 | // b(t,g): #ff_type * 4 24 | // b(lf): #lut-ff 25 | // s(lf,g): #lut-ff * 4 26 | vector> varlh; 27 | vector>> varfg; 28 | vector> vartg; 29 | vector> varlf; 30 | vector>> varlfg; 31 | void InitIndex(); 32 | int *colno; 33 | REAL *row; 34 | lprec *lp; 35 | REAL obj; 36 | void AddCons(); 37 | void AddVarNames(); 38 | void Put(); 39 | void Check(); 40 | }; -------------------------------------------------------------------------------- /src/pack/clb2_res_base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clb2.h" 4 | 5 | class FFLoc { 6 | public: 7 | unsigned g, s; // group id, slot id (inside the group) 8 | FFLoc(unsigned gid, unsigned sid) : g(gid), s(sid) {} 9 | void Print(); 10 | }; 11 | 12 | class FFGroup { 13 | public: 14 | vector insts; // lazy deletion will be used 15 | Instance* type = nullptr; 16 | bool assigned = false; // at least one FF is assigned 17 | Instance*& operator[](size_t i) { return insts[i]; } 18 | const Instance* operator[](size_t i) const { return insts[i]; } 19 | size_t size() { return insts.size(); } 20 | void Print(); 21 | }; 22 | 23 | class LUTPair { 24 | public: 25 | array insts; // LUT pair 26 | vector ffs; // FFs (may more than two) 27 | bool assigned = false; 28 | void Print(); 29 | }; 30 | 31 | class CLB2ResultBase { 32 | public: 33 | CLB2ResultBase(const CLB2& c, vector& r); 34 | virtual void Run() = 0; 35 | void Print(); 36 | CLB2Stat stat; 37 | 38 | protected: 39 | const CLB2& clb; 40 | vector ffgs; 41 | vector lutps; 42 | // result 43 | array lutSlots; // first half: 0-7lut, 16-23ff; second half: 8-15lut, 24-31ff 44 | vector& res; 45 | 46 | // LUT pair slot = half*8 + lutSlots[half] 47 | // FF slot = 16 + half*8 + lutSlots[half] + 0/1 48 | // define: shift = half*8 + lutSlots[half] 49 | unsigned GetShift(unsigned half); 50 | void CommitFF(const FFLoc& ff, unsigned slot, bool conn = false); 51 | void CommitLUTPair(LUTPair& l2f, unsigned slot); 52 | 53 | void InitStat(); 54 | void InitLUTPairs(); 55 | virtual void Prepare() = 0; 56 | }; -------------------------------------------------------------------------------- /src/pack/clb_base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "db/db.h" 4 | using namespace db; 5 | 6 | class CLBBase { 7 | public: 8 | int id; 9 | 10 | CLBBase(int i) : id(i) {} 11 | CLBBase() { 12 | static int gid = 0; 13 | id = gid++; 14 | } 15 | virtual ~CLBBase(){}; 16 | virtual bool AddInsts(const Group& group) = 0; 17 | virtual bool IsEmpty() = 0; 18 | virtual void GetResult(Group& group) = 0; 19 | virtual void GetFinalResult(Group& group) = 0; 20 | virtual void Print() const = 0; 21 | }; -------------------------------------------------------------------------------- /src/pack/pack.cpp: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | #include "pack.h" 3 | #include "clb2.h" 4 | 5 | extern bool legCLB1Succ; 6 | 7 | void packble(vector& groups) { 8 | printlog(LOG_INFO, "*******************************************************************"); 9 | PackBLE packble(groups); 10 | printlog(LOG_INFO, "*******************************************************************"); 11 | packble.PairLUTFF(); 12 | printlog(LOG_INFO, "*******************************************************************"); 13 | packble.PairLUTs(); 14 | printlog(LOG_INFO, "*******************************************************************"); 15 | packble.PackSingFF(); 16 | printlog(LOG_INFO, "*******************************************************************"); 17 | packble.GetResult(groups); 18 | } 19 | 20 | void maxLutFfCon(const DPData& dpData) { 21 | if (legCLB1Succ) return; 22 | 23 | clb2stat.Init(); 24 | 25 | log() << endl; 26 | log() << "Reallocate LUTs/FFs in each CLB to maximize LUT-FF direct connection" << endl; 27 | for (int x = 0; x < database.sitemap_nx; ++x) { 28 | for (int y = 0; y < database.sitemap_ny; ++y) { 29 | auto site = database.getSite(x, y); 30 | if (site->type->name != SiteType::SLICE || site->pack == NULL) 31 | continue; 32 | else { 33 | for (auto inst : site->pack->instances) 34 | if (inst) database.unplace(inst); 35 | } 36 | Group res; 37 | dpData.clbMap[x][y]->GetFinalResult(res); 38 | auto& insts = res.instances; 39 | for (unsigned i = 0; i < insts.size(); ++i) 40 | if (insts[i] != NULL) database.place(insts[i], site, i); 41 | } 42 | } 43 | 44 | clb2stat.Print(); 45 | 46 | if (!database.isPlacementValid()) printlog(LOG_ERROR, "max lut ff failed"); 47 | } -------------------------------------------------------------------------------- /src/pack/pack.h: -------------------------------------------------------------------------------- 1 | #ifndef _PACK_H_ 2 | #define _PACK_H_ 3 | 4 | #include "../db/db.h" 5 | #include "dp/dp_data.h" 6 | 7 | using namespace db; 8 | 9 | #include "pack_ble.h" 10 | 11 | // pack clb 12 | void packble(vector& groups); 13 | 14 | void maxLutFfCon(const DPData& dpData); 15 | 16 | #endif -------------------------------------------------------------------------------- /src/pack/pack_ble.h: -------------------------------------------------------------------------------- 1 | #ifndef _PACK_BLE_H_ 2 | #define _PACK_BLE_H_ 3 | 4 | #include "ble.h" 5 | 6 | typedef unsigned short conn_deg_type; 7 | enum InstType { LUT1 = 1, LUT2 = 2, LUT3 = 3, LUT4 = 4, LUT5 = 5, LUT6 = 6, FF = 7, OTHERS = 8 }; 8 | 9 | class PackBLE { 10 | private: 11 | vector bles; // result 12 | vector inst2ble; 13 | vector instPoss; // for GP 14 | 15 | unsigned int numInst; // num of instances 16 | unsigned int numLUT; // num of LUT 17 | unsigned int numFF; // num of FF 18 | vector instType; // instance type 19 | 20 | unsigned int num2LUTBle; 21 | unsigned int num2FFBle; 22 | unsigned int numPackedFF; 23 | 24 | const double mergeRange = 20; // x/2+y 25 | unordered_set ignoreNetId; 26 | vector> 27 | table1StepConn; // 1-step connection degree (ignore FF-FF connections via clk, sr, ce) 28 | 29 | BLE* NewBle(); 30 | void DeleteBle(BLE* ble); 31 | void AddLUT(BLE* ble, Instance* lut); 32 | void AddFF(BLE* ble, Instance* ff); 33 | void MergeBLE(BLE* ble1, BLE* ble2); 34 | 35 | public: 36 | PackBLE(vector& groups); 37 | ~PackBLE(); 38 | 39 | void StatFFType() const; 40 | void StatLUT2FF() const; 41 | 42 | void PairLUTFF(); 43 | void PairLUTs(); 44 | void PackSingFF(); 45 | 46 | void GetResult(vector& groups) const; 47 | }; 48 | 49 | #endif -------------------------------------------------------------------------------- /src/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BM_PATH=${BENCHMARK_PATH?"Need to set environment variable BENCHMARK_PATH"} 3 | 4 | BM_ABBR=(e{1..4} f{01..12} c{1..5} cf{01..13}) 5 | BM_LONG=(FPGA-example{1..4} FPGA{01..12} clk_design{1..5} CLK-FPGA{01..13}) 6 | BM16_NUM=16 7 | BM_NUM=${#BM_ABBR[@]} 8 | 9 | if [ -z $1 ] ; then 10 | echo "Usage:" 11 | echo "$0 [mode] |all [option1] [option2]" 12 | echo "Mode:" 13 | echo " place place by RippleFPGA only (default)" 14 | echo " route route by VIVADO only" 15 | echo " place_route place and route" 16 | echo " gdb place and debug with gdb" 17 | echo " valgrind place and check memory error with valgrind" 18 | echo " vgdb place run valgrind with gdb debugging" 19 | echo "" 20 | echo "Available benchmarks:" 21 | for ((i=0; i<$BM_NUM; ++i)); do 22 | echo ${BM_ABBR[i]} - ${BM_LONG[i]} 23 | done 24 | exit 25 | fi 26 | 27 | PREFIX="" 28 | MODE=$1 29 | if [ $1 = "gdb" ] ; then 30 | shift 31 | PREFIX="gdb --args " 32 | MODE=place_$MODE 33 | elif [ $1 = "valgrind" ] ; then 34 | shift 35 | PREFIX="valgrind " 36 | MODE=place_$MODE 37 | elif [ $1 = "vgdb" ] ; then 38 | shift 39 | PREFIX="valgrind --vgdb-error=0" 40 | MODE=place_$MODE 41 | elif [ $1 = "route" -o $1 = "place_route" -o $1 = "place" ] ; then 42 | shift 43 | else 44 | MODE="place" 45 | fi 46 | echo "Mode: $MODE" 47 | 48 | DATE=`date +"%m%d"` 49 | BM=$1 50 | shift 51 | OPTIONS="$@" 52 | BINARY="placer" 53 | 54 | FOUND="false" 55 | 56 | for ((i=0; i<$BM_NUM; ++i)); do 57 | if [ $BM = "all" -o $BM = ${BM_ABBR[i]} \ 58 | -o \( $BM = "all16" -a $i -lt $BM16_NUM \) \ 59 | -o \( $BM = "all17" -a $i -ge $BM16_NUM \) ] ; then 60 | if [ $i -lt $BM16_NUM ] ; then 61 | YEAR=16 62 | else 63 | YEAR=17 64 | fi 65 | INPUT_AUX=$BM_PATH/ispd20$YEAR/${BM_LONG[i]}/design.aux 66 | OUTPUT_PL=${BM_LONG[i]}.pl 67 | BENCHMARK=${BM_ABBR[i]} 68 | BM_DATED=${BENCHMARK}_${DATE} 69 | 70 | if [[ $MODE == *"place"* ]] ; then 71 | mkdir -p $BENCHMARK/ 72 | cd $BENCHMARK/ 73 | echo "$PREFIX ../$BINARY -aux $INPUT_AUX -out $OUTPUT_PL $OPTIONS" 74 | $PREFIX ../$BINARY -aux $INPUT_AUX -out $OUTPUT_PL $OPTIONS | tee $BM_DATED.log 75 | cd .. 76 | fi 77 | if [[ $MODE == *"route"* ]] ; then 78 | cd $BENCHMARK 79 | ../eval.sh $BENCHMARK 80 | cd .. 81 | fi 82 | 83 | FOUND="yes" 84 | fi 85 | done 86 | 87 | if [ $FOUND != "yes" ] ; then 88 | echo "ERROR: no benchmark with name: $BM" 89 | fi 90 | -------------------------------------------------------------------------------- /src/utils/draw.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | using namespace std; 14 | 15 | #define uchar unsigned char 16 | 17 | class DrawCanvas { 18 | private: 19 | gdImagePtr _image; 20 | gdFontPtr _font; 21 | int _lineColor; 22 | int _fillColor; 23 | double _lineSize; 24 | 25 | double COLOR_KEY[4][10] = {{0.000, 0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 0.875, 1.000}, 26 | {0.000, 0.501, 0.501, 1.000}, 27 | {0.000, 0.501, 0.501, 1.000}, 28 | {0.000, 1.000}}; 29 | double COLOR_R[4][10] = {{0, 0, 0, 0, 128, 255, 255, 255, 128}, {0, 0, 255, 255}, {0, 128, 128, 255}, {0, 255}}; 30 | double COLOR_G[4][10] = {{0, 0, 128, 255, 255, 255, 128, 0, 0}, {0, 255, 255, 0}, {0, 128, 0, 0}, {0, 255}}; 31 | double COLOR_B[4][10] = {{128, 255, 255, 255, 128, 0, 0, 0, 0}, {255, 0, 0, 0}, {0, 128, 0, 0}, {0, 255}}; 32 | unsigned COLOR_POINTS[4] = {9, 4, 4, 2}; 33 | 34 | protected: 35 | double _lx, _ly; 36 | double _hx, _hy; 37 | int _imgw; 38 | int _imgh; 39 | bool _fx; 40 | bool _fy; 41 | 42 | private: 43 | int getImgX(double x); 44 | int getImgY(double y); 45 | 46 | public: 47 | enum Font { FontTiny, FontSmall, FontMediumBold, FontLarge, FontGiant }; 48 | 49 | DrawCanvas(); 50 | DrawCanvas(int w, int h, bool fx = false, bool fy = false); 51 | DrawCanvas(int w, int h, double lx, double ly, double hx, double hy, bool fx = false, bool fy = true); 52 | ~DrawCanvas(); 53 | 54 | void SetViewPort(int w, int h, double lx, double ly, double hx, double hy); 55 | void Init(); 56 | void Free(); 57 | 58 | void scale_to_rgb(double v, uchar *r, uchar *g, uchar *b, int key); 59 | 60 | void Clear(); 61 | void Clear(int color); 62 | void Clear(char r, char g, char b); 63 | void DrawLine(double x1, double y1, double x2, double y2, double size = -1.0); 64 | void DrawRect(double x1, double y1, double x2, double y2, bool fill = true, double size = -1.0); 65 | void DrawPoint(double x, double y, double size = 0.0); 66 | void DrawString(string str, double x, double y); 67 | void DrawNumber(int num, double x, double y); 68 | void DrawNumber(double num, double x, double y); 69 | void SetLineColor(double v, int key); 70 | void SetFillColor(double v, int key); 71 | void SetLineColor(unsigned char r, unsigned char g, unsigned char b); 72 | void SetFillColor(unsigned char r, unsigned char g, unsigned char b); 73 | void SetLineColor(int color); 74 | void SetFillColor(int color); 75 | void SetLineThickness(double size); 76 | void SetFont(Font size); 77 | void Save(string file); 78 | }; -------------------------------------------------------------------------------- /src/utils/log.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "log.h" 7 | 8 | using namespace std; 9 | 10 | //////////TIMER FUNTIONS////////// 11 | 12 | namespace timer { 13 | timer::timer() { start(); } 14 | void timer::start() { _start = clock::now(); } 15 | double timer::elapsed() const { return std::chrono::duration(clock::now() - _start).count(); } 16 | } // namespace timer 17 | 18 | timer::timer tstamp; 19 | 20 | inline ostream& operator<<(ostream& os, const timer::timer& t) { 21 | return os << "[" << setprecision(3) << setw(8) << fixed << t.elapsed() << " ] "; 22 | } 23 | 24 | inline string to_string(const timer::timer& t) { 25 | ostringstream oss; 26 | oss << t; 27 | return oss.str(); 28 | } 29 | 30 | ///////////////LOGGING FUNCTIONS/////////////////////// 31 | 32 | ostream& log(ostream& os) { 33 | os << to_string(tstamp); 34 | return os; 35 | } 36 | 37 | int _active_levels = 0; 38 | int _color_levels = LOG_FATAL | LOG_ERROR | LOG_WARN; 39 | 40 | void init_log(int log_level) { _active_levels = log_level; } 41 | 42 | void printlog(int level, const char* format, ...) { 43 | if ((level & _active_levels) == 0) return; 44 | char c; 45 | switch (level) { 46 | case LOG_FATAL: 47 | c = '!'; 48 | printf(ESC_BG_RED); 49 | break; 50 | case LOG_ERROR: 51 | c = 'E'; 52 | printf(ESC_RED); 53 | break; 54 | case LOG_WARN: 55 | c = 'W'; 56 | printf(ESC_YELLOW); 57 | break; 58 | case LOG_NOTICE: 59 | c = 'N'; 60 | break; 61 | default: 62 | c = ' '; 63 | break; 64 | } 65 | printf(LOG_PREFIX, tstamp.elapsed(), c); 66 | va_list ap; 67 | va_start(ap, format); 68 | vfprintf(stdout, format, ap); 69 | if (level & _color_levels) printf(ESC_RESET); 70 | printf(LOG_SUFFIX); 71 | fflush(stdout); 72 | } -------------------------------------------------------------------------------- /src/utils/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | //////////TIMER FUNTIONS////////// 7 | 8 | namespace timer { 9 | class timer { 10 | typedef std::chrono::steady_clock clock; 11 | 12 | private: 13 | clock::time_point _start; 14 | 15 | public: 16 | timer(); 17 | void start(); 18 | double elapsed() const; // seconds 19 | }; 20 | } // namespace timer 21 | 22 | inline std::ostream& operator<<(std::ostream& os, const timer::timer& t); 23 | inline std::string to_string(const timer::timer& t); 24 | 25 | //////////ESCAPE CODE DEFINIATION////////// 26 | 27 | #define ESC_RESET "\033[0m" 28 | #define ESC_BOLD "\033[1m" 29 | #define ESC_UNDERLINE "\033[4m" 30 | #define ESC_BLINK "\033[5m" 31 | #define ESC_REVERSE "\033[7m" 32 | #define ESC_BLACK "\033[30m" 33 | #define ESC_RED "\033[31m" 34 | #define ESC_GREEN "\033[32m" 35 | #define ESC_YELLOW "\033[33m" 36 | #define ESC_BLUE "\033[34m" 37 | #define ESC_MAGENTA "\033[35m" 38 | #define ESC_CYAN "\033[36m" 39 | #define ESC_WHITE "\033[37m" 40 | #define ESC_DEFAULT "\033[39m" 41 | #define ESC_BG_BLACK "\033[40m" 42 | #define ESC_BG_RED "\033[41m" 43 | #define ESC_BG_GREEN "\033[42m" 44 | #define ESC_BG_YELLOW "\033[43m" 45 | #define ESC_BG_BLUE "\033[44m" 46 | #define ESC_BG_MAGENTA "\033[45m" 47 | #define ESC_BG_CYAN "\033[46m" 48 | #define ESC_BG_WHITE "\033[47m" 49 | #define ESC_BG_DEFAULT "\033[49m" 50 | #define ESC_OVERLINE "\033[53m" 51 | 52 | ///////////////LOGGING FUNCTIONS/////////////////////// 53 | 54 | std::ostream& log(std::ostream& os = std::cout); 55 | 56 | #define LOG_DEBUG 1 57 | #define LOG_VERBOSE 2 58 | #define LOG_INFO 4 59 | #define LOG_NOTICE 8 60 | #define LOG_WARN 16 61 | #define LOG_ERROR 32 62 | #define LOG_FATAL 64 63 | #define LOG_ALL 127 64 | #define LOG_FAIL LOG_ERROR | LOG_FATAL 65 | #define LOG_NORMAL LOG_ALL ^ (LOG_DEBUG | LOG_VERBOSE) 66 | 67 | #define LOG_PREFIX "[%8.3lf ]%c " 68 | #define LOG_SUFFIX "\n" 69 | 70 | void init_log(int log_level = LOG_NORMAL); 71 | void printlog(int level, const char* format, ...); -------------------------------------------------------------------------------- /src/utils/misc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "log.h" 3 | #include "draw.h" 4 | 5 | inline double getrand(double lo, double hi) { return (((double)rand() / (double)RAND_MAX) * (hi - lo) + lo); } 6 | 7 | template 8 | void WriteMap(const string& fileNamePrefix, const vector>& map) { 9 | #ifndef WRITE 10 | return; 11 | #endif 12 | ofstream oStream; 13 | ostringstream fileName; 14 | oStream.open(fileNamePrefix + ".txt"); 15 | 16 | for (const auto& col : map) { 17 | for (auto el : col) oStream << el << ' '; 18 | oStream << endl; 19 | } 20 | 21 | oStream.close(); 22 | } 23 | 24 | template 25 | void DrawMap(const string& fileNamePrefix, const vector>& map, double xscale = 1.0, double yscale = 1.0) { 26 | #ifndef DRAW 27 | return; 28 | #endif 29 | double minValue = map[0][0], maxValue = map[0][0]; 30 | for (unsigned x = 0; x < map.size(); x++) 31 | for (unsigned y = 0; y < map[0].size(); y++) { 32 | if (map[x][y] > maxValue) 33 | maxValue = map[x][y]; 34 | else if (map[x][y] < minValue) 35 | minValue = map[x][y]; 36 | } 37 | 38 | DrawCanvas canvas(xscale * map[0].size(), yscale * map.size(), 0, 0, map.size(), map[0].size()); 39 | for (unsigned x = 0; x < map.size(); x++) { 40 | for (unsigned y = 0; y < map[0].size(); y++) { 41 | double v = (map[x][y] - minValue) / (maxValue - minValue); 42 | canvas.SetFillColor(v, 1); 43 | canvas.DrawRect(x, y, x + 1, y + 1); 44 | } 45 | } 46 | canvas.Save(fileNamePrefix + ".png"); 47 | } 48 | 49 | template 50 | void DrawMap2(const string& fileNamePrefix, 51 | const vector>& map, 52 | double maxValue, 53 | double minValue = 0.0, 54 | double xscale = 1.0, 55 | double yscale = 1.0) { 56 | #ifndef DRAW 57 | return; 58 | #endif 59 | DrawCanvas canvas(xscale * map[0].size(), yscale * map.size(), 0, 0, map.size(), map[0].size()); 60 | for (unsigned x = 0; x < map.size(); x++) { 61 | for (unsigned y = 0; y < map[0].size(); y++) { 62 | double v = map[x][y]; 63 | if (v >= maxValue) 64 | v = 1; 65 | else if (v <= minValue) 66 | v = 0.0; 67 | else 68 | v = (v - minValue) / (maxValue - minValue); 69 | canvas.SetFillColor(v, 1); 70 | canvas.DrawRect(x, y, x + 1, y + 1); 71 | } 72 | } 73 | canvas.Save(fileNamePrefix + ".png"); 74 | } 75 | 76 | template 77 | void PrintMapStat(const string& name, const vector>& map) { 78 | vector stat; 79 | for (const auto& col : map) { 80 | for (auto el : col) { 81 | if (el > 0) { 82 | if (el >= stat.size()) stat.resize(el + 1, 0); 83 | ++stat[el]; 84 | } 85 | } 86 | } 87 | 88 | printlog(LOG_INFO, "\tStat of %s", name.c_str()); 89 | for (unsigned i = 0; i < stat.size(); ++i) 90 | if (stat[i] != 0) printlog(LOG_INFO, "\t\t%d: %d ", i, stat[i]); 91 | } 92 | 93 | template 94 | struct sorting_order { 95 | static bool desc(const pair& left, const pair& right) { return left.first > right.first; } 96 | static bool asc(const pair& left, const pair& right) { return left.first < right.first; } 97 | }; -------------------------------------------------------------------------------- /toy_example/design.aux: -------------------------------------------------------------------------------- 1 | # version 3.1 02/08/2016 2 | design : design.nodes design.nets design.wts design.pl design.scl design.lib 3 | -------------------------------------------------------------------------------- /toy_example/design.dcp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuhk-eda/ripple-fpga/059646fcaa0c8d77e4283f55be2bd5692862a039/toy_example/design.dcp -------------------------------------------------------------------------------- /toy_example/design.pl: -------------------------------------------------------------------------------- 1 | inst_3330 103 0 25 FIXED 2 | inst_1272 103 90 23 FIXED 3 | inst_1269 103 90 24 FIXED 4 | inst_1270 103 90 25 FIXED 5 | inst_1317 103 90 0 FIXED 6 | inst_3331 103 0 24 FIXED 7 | inst_3328 103 0 29 FIXED 8 | inst_3329 103 0 28 FIXED 9 | inst_3326 103 0 33 FIXED 10 | inst_3327 103 0 32 FIXED 11 | inst_3324 103 0 37 FIXED 12 | inst_3325 103 0 36 FIXED 13 | inst_3322 103 0 41 FIXED 14 | inst_3338 103 0 9 FIXED 15 | inst_3323 103 0 40 FIXED 16 | inst_3320 103 0 45 FIXED 17 | inst_3321 103 0 44 FIXED 18 | inst_3340 103 0 49 FIXED 19 | inst_3319 103 0 48 FIXED 20 | inst_3336 103 0 13 FIXED 21 | inst_3337 103 0 12 FIXED 22 | inst_1315 103 60 2 FIXED 23 | inst_1316 103 60 3 FIXED 24 | inst_1313 103 60 4 FIXED 25 | inst_1314 103 60 5 FIXED 26 | inst_1311 103 60 6 FIXED 27 | inst_1312 103 60 7 FIXED 28 | inst_1309 103 60 8 FIXED 29 | inst_1310 103 60 9 FIXED 30 | inst_3334 103 0 17 FIXED 31 | inst_1307 103 60 10 FIXED 32 | inst_1308 103 60 11 FIXED 33 | inst_1305 103 60 12 FIXED 34 | inst_1306 103 60 13 FIXED 35 | inst_1303 103 60 14 FIXED 36 | inst_1304 103 60 15 FIXED 37 | inst_1301 103 60 16 FIXED 38 | inst_1302 103 60 17 FIXED 39 | inst_1299 103 60 18 FIXED 40 | inst_3335 103 0 16 FIXED 41 | inst_1300 103 60 19 FIXED 42 | inst_1297 103 60 20 FIXED 43 | inst_1298 103 60 21 FIXED 44 | inst_1295 103 60 22 FIXED 45 | inst_1296 103 60 23 FIXED 46 | inst_1293 103 60 24 FIXED 47 | inst_1294 103 60 25 FIXED 48 | inst_1291 103 90 2 FIXED 49 | inst_1292 103 90 3 FIXED 50 | inst_3332 103 0 21 FIXED 51 | inst_1289 103 90 4 FIXED 52 | inst_1290 103 90 5 FIXED 53 | inst_1287 103 90 6 FIXED 54 | inst_1288 103 90 7 FIXED 55 | inst_1285 103 90 8 FIXED 56 | inst_1286 103 90 9 FIXED 57 | inst_1283 103 90 10 FIXED 58 | inst_1284 103 90 11 FIXED 59 | inst_1281 103 90 12 FIXED 60 | inst_1282 103 90 13 FIXED 61 | inst_3333 103 0 20 FIXED 62 | inst_1318 103 90 1 FIXED 63 | inst_1279 103 90 14 FIXED 64 | inst_1280 103 90 15 FIXED 65 | inst_1277 103 90 16 FIXED 66 | inst_1278 103 90 17 FIXED 67 | inst_1275 103 90 18 FIXED 68 | inst_1276 103 90 19 FIXED 69 | inst_1273 103 90 20 FIXED 70 | inst_1274 103 90 21 FIXED 71 | inst_1271 103 90 22 FIXED 72 | inst_4 104 0 0 FIXED 73 | -------------------------------------------------------------------------------- /toy_example/design.wts: -------------------------------------------------------------------------------- 1 | # Intentionally left empty 2 | --------------------------------------------------------------------------------