From 18666b75c6e6df09c960b7da978f53e333fe0249 Mon Sep 17 00:00:00 2001 From: Berenger Bramas <Berenger.Bramas@inria.fr> Date: Fri, 27 Nov 2015 09:34:39 +0100 Subject: [PATCH] update hmat --- Addons/HMat/Src/{ => Blocks}/FDenseMatrix.hpp | 0 Addons/HMat/Src/Utils/FHUtils.hpp | 2 + Addons/HMat/Src/Utils/FSvgRect.hpp | 2 + .../HMat/Src/Viewers/FDenseBlockWrapper.hpp | 39 ++++++++++++++++ Addons/HMat/Src/Viewers/FMatGrid.hpp | 34 +------------- Addons/HMat/Tests/testDiv2Bissection.cpp | 4 +- Addons/HMat/Tests/testDiv2Gemv.cpp | 44 +++++++++++++++++++ 7 files changed, 90 insertions(+), 35 deletions(-) rename Addons/HMat/Src/{ => Blocks}/FDenseMatrix.hpp (100%) create mode 100644 Addons/HMat/Src/Viewers/FDenseBlockWrapper.hpp create mode 100644 Addons/HMat/Tests/testDiv2Gemv.cpp diff --git a/Addons/HMat/Src/FDenseMatrix.hpp b/Addons/HMat/Src/Blocks/FDenseMatrix.hpp similarity index 100% rename from Addons/HMat/Src/FDenseMatrix.hpp rename to Addons/HMat/Src/Blocks/FDenseMatrix.hpp diff --git a/Addons/HMat/Src/Utils/FHUtils.hpp b/Addons/HMat/Src/Utils/FHUtils.hpp index 18465931c..83d74543e 100644 --- a/Addons/HMat/Src/Utils/FHUtils.hpp +++ b/Addons/HMat/Src/Utils/FHUtils.hpp @@ -1,6 +1,8 @@ #ifndef FHUTILS_HPP #define FHUTILS_HPP +// @SCALFMM_PRIVATE + #include "Utils/FGlobal.hpp" #include <cstring> diff --git a/Addons/HMat/Src/Utils/FSvgRect.hpp b/Addons/HMat/Src/Utils/FSvgRect.hpp index 943a02b58..444733066 100644 --- a/Addons/HMat/Src/Utils/FSvgRect.hpp +++ b/Addons/HMat/Src/Utils/FSvgRect.hpp @@ -1,6 +1,8 @@ #ifndef FSVGRECT_HPP #define FSVGRECT_HPP +// @SCALFMM_PRIVATE + #include "Utils/FGlobal.hpp" #include "Utils/FAssert.hpp" diff --git a/Addons/HMat/Src/Viewers/FDenseBlockWrapper.hpp b/Addons/HMat/Src/Viewers/FDenseBlockWrapper.hpp new file mode 100644 index 000000000..2e5663250 --- /dev/null +++ b/Addons/HMat/Src/Viewers/FDenseBlockWrapper.hpp @@ -0,0 +1,39 @@ +#ifndef FDENSEBLOCKWRAPPER_HPP +#define FDENSEBLOCKWRAPPER_HPP + +// @SCALFMM_PRIVATE + +template <class FReal> +class FDenseBlockWrapper{ +protected: + const FReal* values; + const int nbRows; + const int nbCols; + const int leadingDim; + +public: + FDenseBlockWrapper(const FReal* inValues, const int inNbRows, const int inNbCols, const int inLeading) + : values(inValues), nbRows(inNbRows), nbCols(inNbCols), leadingDim(inLeading){ + } + + int getNbRows() const { + return nbRows; + } + + int getNbCols() const { + return nbCols; + } + + FReal getValue(const int rowIdx, const int colIdx) const{ + FAssertLF(rowIdx < nbRows); + FAssertLF(colIdx < nbCols); + return values[colIdx*leadingDim + rowIdx]; + } + + constexpr bool existsForReal() const{ + return true; + } +}; + +#endif // FDENSEBLOCKWRAPPER_HPP + diff --git a/Addons/HMat/Src/Viewers/FMatGrid.hpp b/Addons/HMat/Src/Viewers/FMatGrid.hpp index f7332418b..d816041f7 100644 --- a/Addons/HMat/Src/Viewers/FMatGrid.hpp +++ b/Addons/HMat/Src/Viewers/FMatGrid.hpp @@ -6,39 +6,7 @@ #include "Utils/FGlobal.hpp" #include "Utils/FAssert.hpp" - -template <class FReal> -class FDenseBlockWrapper{ -protected: - const FReal* values; - const int nbRows; - const int nbCols; - const int leadingDim; - -public: - FDenseBlockWrapper(const FReal* inValues, const int inNbRows, const int inNbCols, const int inLeading) - : values(inValues), nbRows(inNbRows), nbCols(inNbCols), leadingDim(inLeading){ - } - - int getNbRows() const { - return nbRows; - } - - int getNbCols() const { - return nbCols; - } - - FReal getValue(const int rowIdx, const int colIdx) const{ - FAssertLF(rowIdx < nbRows); - FAssertLF(colIdx < nbCols); - return values[colIdx*leadingDim + rowIdx]; - } - - constexpr bool existsForReal() const{ - return true; - } -}; - +#include "FDenseBlockWrapper.hpp" template <class FReal> class FMatGrid { diff --git a/Addons/HMat/Tests/testDiv2Bissection.cpp b/Addons/HMat/Tests/testDiv2Bissection.cpp index 69157deb2..2524bd101 100644 --- a/Addons/HMat/Tests/testDiv2Bissection.cpp +++ b/Addons/HMat/Tests/testDiv2Bissection.cpp @@ -1,8 +1,8 @@ // @SCALFMM_PRIVATE -#include "../Src/Core/FDiv2Bissection.hpp" -#include "../Src/Containers/FMatGrid.hpp" +#include "../Src/Containers/FDiv2Bissection.hpp" +#include "../Src/Viewers/FMatGrid.hpp" #include "../Src/Utils/FSvgRect.hpp" #include "Utils/FParameters.hpp" diff --git a/Addons/HMat/Tests/testDiv2Gemv.cpp b/Addons/HMat/Tests/testDiv2Gemv.cpp new file mode 100644 index 000000000..cb6fb61d5 --- /dev/null +++ b/Addons/HMat/Tests/testDiv2Gemv.cpp @@ -0,0 +1,44 @@ + +// @SCALFMM_PRIVATE + +#include "../Src/Containers/FDiv2Bissection.hpp" +#include "../Src/Viewers/FMatGrid.hpp" +#include "../Src/Blocks/FDenseMatrix.hpp" + +#include "Utils/FParameters.hpp" +#include "Utils/FParameterNames.hpp" + +int main(int argc, char** argv){ + static const FParameterNames DimParam = { + {"-N", "-nb", "-dim"} , + "Dim of the matrix." + }; + static const FParameterNames HeightParam = { + {"-h", "-height"} , + "Number of dissection (+1)." + }; + + FHelpDescribeAndExit(argc, argv, + "Test the bisection.",SvgOutParam, + DimParam,HeightParam); + + const int dim = FParameters::getValue(argc, argv, DimParam.options, 100); + const int height = FParameters::getValue(argc, argv, HeightParam.options, 4); + + std::cout << "Config : dim = " << dim << "\n"; + std::cout << "Config : height = " << height << "\n"; + + { + typedef double FReal; + typedef FMatGrid<FReal> MatrixClass; + typedef FDenseMatrix<FReal> LeafClass; + typedef FDenseMatrix<FReal> CellClass; + typedef FDiv2Bissection<FReal, LeafClass, CellClass> GridClass; + + GridClass bissection(dim, height); + bissection.fillBlocks(matrix); + } + + return 0; +} + -- GitLab