15#ifndef __INTREPID2_PAMATRIX_HPP__
16#define __INTREPID2_PAMATRIX_HPP__
18#include "Intrepid2_ConfigDefs.hpp"
27#include "Kokkos_Core.hpp"
80 template<
typename DeviceType = Kokkos::DefaultExecutionSpace::device_type,
81 typename Scalar =
double>
84 using View1D = Kokkos::View<Scalar*,DeviceType>;
101 return std::tie(C, P, a0, b0, aSpan, bSpan) < std::tie(otherSpec.C, otherSpec.P, otherSpec.a0, otherSpec.b0, otherSpec.aSpan, otherSpec.bSpan);
105 return std::tie(C, P, a0, b0, aSpan, bSpan) == std::tie(otherSpec.C, otherSpec.P, otherSpec.a0, otherSpec.b0, otherSpec.aSpan, otherSpec.bSpan);
130 const ScalarView<Orientation,DeviceType>
orientations = ScalarView<Orientation,DeviceType>(),
131 const BasisPtrType basisLeft = Teuchos::null,
132 const BasisPtrType basisRight = Teuchos::null);
147 const BasisPtrType basis = Teuchos::null);
164 Kokkos::View<Scalar*,DeviceType>
allocateWorkspace(
const ordinal_type &worksetSize)
const;
168 Kokkos::View<Scalar*,DeviceType>
allocateWorkspace(
const ordinal_type &worksetSize,
const ordinal_type &n)
const;
180 template <
typename OutputViewType,
typename InputViewType>
181 void apply(
const OutputViewType &outputVector,
182 const InputViewType & inputVector,
183 const Kokkos::View<Scalar*,DeviceType> &workspace,
184 const bool sumInto =
false,
185 const int worksetSizeIn = 0)
const;
217 const ScalarView<Orientation,DeviceType> &
orientations()
const {
return _orientations; }
220 const BasisPtrType &
leftBasis()
const {
return _basisLeft; }
223 const BasisPtrType &
rightBasis()
const {
return _basisRight; }
226 bool hasOrdinalFilter()
const {
return (leftOrdinalFilter_.extent_int(0) > 0) || (rightOrdinalFilter_.extent_int(0) > 0); }
260 static double gemmThroughputGFlops(
const double baseFlopCount = 0,
const double baseTimeSeconds = 0);
301 template <
typename OutputViewType,
typename InputViewType>
303 const InputViewType &input,
const ordinal_type inputCellOffset,
304 const ordinal_type startCell,
const ordinal_type Cw,
const ordinal_type N,
305 Scalar *workspace1, Scalar *workspace2)
const;
310 std::map<PointDataSpec,View1D> _pointDataCache;
313 ScalarView<Orientation,DeviceType> _orientations;
314 BasisPtrType _basisLeft, _basisRight;
315 bool _hasNontrivialOrientations =
false;
316 size_t maxIntermediateSize_ = 0;
318 std::vector<ComponentSequence> componentIntegralsToSum_;
319 std::vector<std::pair<int,int>> componentIntegralGroups_;
323 Kokkos::View<ordinal_type*,DeviceType> leftOrdinalFilter_, rightOrdinalFilter_;
324 int numUnfilteredFieldsLeft_ = 0, numUnfilteredFieldsRight_ = 0;
Header file for the abstract base class Intrepid2::Basis.
Teuchos::RCP< Basis< DeviceType, OutputType, PointType > > BasisPtr
Basis Pointer.
Defines the Data class, a wrapper around a Kokkos::View that allows data that is constant or repeatin...
Header file for the Intrepid2::Orientation class.
Header file for the Intrepid2::PAMatrix implementations; provides support for matrix partial assembly...
Contains definitions of custom data types in Intrepid2.
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
void assembleByApply(Data< Scalar, DeviceType > &integrals, const PAMatrixAssemblyOptions &options) const
assembles by apply() to blocked unit columns
Kokkos::View< Scalar *, DeviceType > allocateWorkspace(const ordinal_type &worksetSize) const
Allocates and returns workspace storage suitable for providing to apply() to a vector with a workset ...
static void setGEMMStatisticsEnabled(const bool enabled)
Enables or disables recording of GEMM statistics (off by default).
void orientAssembledMatrix(Data< Scalar, DeviceType > &integrals) const
applies orientations in place to an assembled (C,F1,F2) matrix
static double gemmFlopCount()
Returns the cumulative estimated floating-point operation count for recorded GEMM calls.
static bool gemmStatisticsEnabled()
Returns true if GEMM statistics are being recorded.
const BasisPtrType & rightBasis() const
The right basis (null if none was provided).
const TransformedBasisValues< Scalar, DeviceType > & leftBasisValues() const
The left basis values (with transform) from which the matrix was constructed.
bool supportsDirectAssembly() const
True if assemble() can use direct sum factorization (or contraction of unit columns) for this matrix'...
const TensorData< Scalar, DeviceType > & cellMeasures() const
The cell measures (quadrature weights times Jacobian determinants) from which the matrix was construc...
void applyUnorientedWorkset(const OutputViewType &output, const ordinal_type outputCellOffset, const InputViewType &input, const ordinal_type inputCellOffset, const ordinal_type startCell, const ordinal_type Cw, const ordinal_type N, Scalar *workspace1, Scalar *workspace2) const
Applies the unoriented matrix to cells [startCell, startCell+Cw), accumulating into output....
const TransformedBasisValues< Scalar, DeviceType > & rightBasisValues() const
The right basis values (with transform) from which the matrix was constructed.
Data< Scalar, DeviceType > allocateMatrixStorage() const
Allocates storage for a fully-assembled matrix.
const ScalarView< Orientation, DeviceType > & orientations() const
The cell orientations (empty if none were provided).
bool hasOrdinalFilter() const
True if the left or right basis values have an ordinal filter (e.g., for Serendipity bases).
void extractDiagonal(const Data< Scalar, DeviceType > &diagonal) const
Extracts the diagonal of the matrix, placing it in diagonal. If the matrix is not square,...
bool hasNontrivialOrientations() const
True if orientations were provided and at least one cell is not aligned to the reference.
const BasisPtrType & leftBasis() const
The left basis (null if none was provided).
PAMatrix()=default
Constructs an empty PAMatrix, which may be assigned to from a constructed one.
size_t applyWorkspacePerCell() const
the workspace size, in entries per cell and vector, required by apply()
void assemble(Data< Scalar, DeviceType > &integrals, const PAMatrixAssemblyOptions &options=PAMatrixAssemblyOptions::defaultsWithEnvironmentOverrides()) const
Fully assembles the matrix, using sum factorization.
void assembleUnitColumns(Data< Scalar, DeviceType > &integrals, const PAMatrixAssemblyOptions &options) const
assembles by contraction of unit columns (requires supportsDirectAssembly())
void apply(const OutputViewType &outputVector, const InputViewType &inputVector, const Kokkos::View< Scalar *, DeviceType > &workspace, const bool sumInto=false, const int worksetSizeIn=0) const
Applies the matrix to inputVector, placing the result in outputVector, without explicit assembly and ...
static double gemmThroughputGFlops(const double baseFlopCount=0, const double baseTimeSeconds=0)
Returns the GEMM throughput in GFlop/s; baseFlopCount and baseTimeSeconds, if provided,...
PAMatrix(const TransformedBasisValues< Scalar, DeviceType > basisValuesLeft, const TensorData< Scalar, DeviceType > cellMeasures, const TransformedBasisValues< Scalar, DeviceType > basisValuesRight, const ScalarView< Orientation, DeviceType > orientations=ScalarView< Orientation, DeviceType >(), const BasisPtrType basisLeft=Teuchos::null, const BasisPtrType basisRight=Teuchos::null)
Constructs a PAMatrix representing the contraction of basisValuesLeft against basisValuesRight contai...
Data< Scalar, DeviceType > allocateDiagonalStorage() const
Allocates and returns a container with shape (C,F), where F=min(F1,F2).
std::tuple< std::vector< OpSpec >, PointDataSpec, std::vector< OpSpec >, int, int, int, int > ComponentSequence
left, pointData, right, left offset, left output span, right offset, right input span
void assembleUnoriented(Data< Scalar, DeviceType > &integrals, const PAMatrixAssemblyOptions &options) const
assembles the matrix for the unoriented bases
static double gemmTimeSeconds()
Returns the cumulative time spent in recorded GEMM calls.
void assembleDirect(Data< Scalar, DeviceType > &integrals, const PAMatrixAssemblyOptions &options) const
assembles by direct sum factorization (requires supportsDirectAssembly())
View-like interface to tensor data; tensor components are stored separately and multiplied together a...
Options for PAMatrix::assemble(). The defaults are appropriate in most cases; the other settings are ...
static PAMatrixAssemblyOptions defaultsWithEnvironmentOverrides()
Returns default options, overridden by any of the following environment variables (for testing and pe...
Algorithm
Algorithm used by assemble().
@ Automatic
direct sum factorization where the structure supports it, column-blocked unit-column contraction othe...
@ ApplyToColumns
apply() to blocked unit columns (the most general path)
@ UnitColumns
column-blocked unit-column contraction where supported, apply() to unit columns otherwise
SparseLastStage
Use of the sparse last stage in the direct path when ordinal filters are present.
@ Automatic
used when fewer than a quarter of the (row, column) pairs of the unfiltered matrix are kept
@ Always
used whenever there is an ordinal filter
double workspaceMB
Workspace budget, in MB, used to choose the workset size for assembly.