18template <
class LocalOrdinal,
class View>
24 KOKKOS_INLINE_FUNCTION
30 KOKKOS_INLINE_FUNCTION
37 KOKKOS_INLINE_FUNCTION
46#if KOKKOSKERNELS_VERSION >= 50200
48template <
class LOType,
class GOType,
class SCType,
class DeviceType,
class NspType,
class aggRowsType,
class maxAggDofSizeType,
class agg2RowMapLOType,
class statusType,
class rowsType,
class rowsAuxType,
class colsAuxType,
class valsAuxType>
56 typedef typename KokkosKernels::ArithTraits<SC>::val_type
impl_SC;
57 typedef KokkosKernels::ArithTraits<impl_SC>
impl_ATS;
58 typedef typename impl_ATS::magnitudeType
Magnitude;
61 typedef Kokkos::View<impl_SC**, typename execution_space::scratch_memory_space, Kokkos::MemoryUnmanaged>
shared_matrix;
62 typedef Kokkos::View<impl_SC*, typename execution_space::scratch_memory_space, Kokkos::MemoryUnmanaged>
shared_vector;
79 LocalQRDecompFunctor(NspType fineNS_, NspType coarseNS_, aggRowsType aggRows_, maxAggDofSizeType maxAggDofSize_, agg2RowMapLOType agg2RowMapLO_, statusType statusAtomic_, rowsType rows_, rowsAuxType rowsAux_, colsAuxType colsAux_, valsAuxType valsAux_,
bool doQRStep_,
int scratchLevel_)
93 KOKKOS_INLINE_FUNCTION
94 void operator()(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread,
size_t& nnz)
const {
95 auto agg = thread.league_rank();
97 const auto aggOffset =
aggRows(agg);
99 const auto aggSize =
aggRows(agg + 1) - aggOffset;
101 const impl_SC one = impl_ATS::one();
102 const impl_SC zero = impl_ATS::zero();
104 const int m = aggSize;
105 const int n =
fineNS.extent(1);
108 Xpetra::global_size_t offset = agg * n;
121 for (
int j = 0; j < n; j++)
122 for (
int k = 0; k < m; k++)
135 KokkosBatched::SerialQR<KokkosBlas::Algo::QR::Unblocked>::invoke(r, tau, work);
138 KokkosBatched::SerialSetIdentity::invoke(q);
141 KokkosBatched::SerialApplyQ<KokkosBatched::Side::Left, KokkosBlas::Trans::NoTranspose, KokkosBlas::Algo::ApplyQ::Unblocked>::invoke(r, tau, q, work);
144 for (
int j = 0; j < n; j++) {
145 for (
int k = 0; k < n; k++)
146 coarseNS(offset + k, j) = (k <= j) ? r(k, j) : zero;
150 for (
int j = 0; j < m; j++) {
152 size_t rowStart =
rowsAux(localRow);
154 for (
int k = 0; k < n; k++) {
156 if (q(j, k) != zero) {
157 colsAux(rowStart + lnnz) = offset + k;
158 valsAux(rowStart + lnnz) = q(j, k);
162 rows(localRow + 1) = lnnz;
197 for (
int j = 0; j < n; j++)
198 for (
int k = 0; k < n; k++)
202 coarseNS(offset + k, j) = (k == j ? one : zero);
208 for (
int j = 0; j < m; j++) {
210 size_t rowStart =
rowsAux(localRow);
211 colsAux(rowStart) = offset + j;
213 rows(localRow + 1) = 1;
227 for (
int j = 0; j < m; j++) {
229 size_t rowStart =
rowsAux(localRow);
231 for (
int k = 0; k < n; k++) {
235 colsAux(rowStart + lnnz) = offset + k;
236 valsAux(rowStart + lnnz) = qr_jk;
240 rows(localRow + 1) = lnnz;
244 for (
int j = 0; j < n; j++)
252template <
class LOType,
class GOType,
class SCType,
class DeviceType,
class NspType,
class aggRowsType,
class maxAggDofSizeType,
class agg2RowMapLOType,
class statusType,
class rowsType,
class rowsAuxType,
class colsAuxType,
class valsAuxType>
260 typedef typename KokkosKernels::ArithTraits<SC>::val_type
impl_SC;
261 typedef KokkosKernels::ArithTraits<impl_SC>
impl_ATS;
265 typedef Kokkos::View<impl_SC**, typename execution_space::scratch_memory_space, Kokkos::MemoryUnmanaged>
shared_matrix;
266 typedef Kokkos::View<impl_SC*, typename execution_space::scratch_memory_space, Kokkos::MemoryUnmanaged>
shared_vector;
283 LocalQRDecompFunctor(NspType fineNS_, NspType coarseNS_, aggRowsType aggRows_, maxAggDofSizeType maxAggDofSize_, agg2RowMapLOType agg2RowMapLO_, statusType statusAtomic_, rowsType rows_, rowsAuxType rowsAux_, colsAuxType colsAux_, valsAuxType valsAux_,
bool doQRStep_,
int scratchLevel_)
297 KOKKOS_INLINE_FUNCTION
298 void operator()(
const typename Kokkos::TeamPolicy<execution_space>::member_type& thread,
size_t& nnz)
const {
299 auto agg = thread.league_rank();
304 const impl_SC one = impl_ATS::one();
306 const impl_SC zero = impl_ATS::zero();
307 const auto zeroM = impl_ATS::magnitude(zero);
313 Xpetra::global_size_t offset = agg * n;
318 for (
int j = 0; j < n; j++)
319 for (
int k = 0; k < m; k++)
323 for (
int i = 0; i < m; i++) {
324 for (
int j = 0; j < n; j++)
325 printf(
" %5.3lf ", r(i,j));
333 bool isSingular =
false;
337 for (
int i = 0; i < m; i++) {
338 for (
int j = 0; j < m; j++)
343 for (
int k = 0; k < n; k++) {
346 for (
int i = k + 1; i < m; i++)
347 s += pow(impl_ATS::magnitude(r(i, k)), 2);
348 norm = sqrt(pow(impl_ATS::magnitude(r(k, k)), 2) + s);
355 r(k, k) -= norm * one;
357 norm_x = sqrt(pow(impl_ATS::magnitude(r(k, k)), 2) + s);
358 if (norm_x == zeroM) {
361 r(k, k) = norm * one;
366 for (
int i = k; i < m; i++)
370 for (
int j = k + 1; j < n; j++) {
373 for (
int i = k; i < m; i++)
374 si += r(i, k) * r(i, j);
375 for (
int i = k; i < m; i++)
376 r(i, j) -= two * si * r(i, k);
380 for (
int j = k; j < m; j++) {
383 for (
int i = k; i < m; i++)
384 si += r(i, k) * qt(i, j);
385 for (
int i = k; i < m; i++)
386 qt(i, j) -= two * si * r(i, k);
390 r(k, k) = norm * one;
391 for (
int i = k + 1; i < m; i++)
397 for (
int i = 0; i < m; i++)
398 for (
int j = 0; j < i; j++) {
406 for (
int j = 0; j < n; j++)
407 for (
int k = 0; k <= j; k++)
446 for (
int j = 0; j < n; j++)
447 for (
int k = 0; k < n; k++)
451 coarseNS(offset + k, j) = (k == j ? one : zero);
454 for (
int i = 0; i < m; i++)
455 for (
int j = 0; j < n; j++)
456 q(i, j) = (j == i ? one : zero);
460 for (
int j = 0; j < m; j++) {
462 size_t rowStart =
rowsAux(localRow);
464 for (
int k = 0; k < n; k++) {
466 if (q(j, k) != zero) {
467 colsAux(rowStart + lnnz) = offset + k;
468 valsAux(rowStart + lnnz) = q(j, k);
472 rows(localRow + 1) = lnnz;
478 for (
int i = 0; i < m; i++) {
479 for (
int j = 0; j < n; j++)
485 for (
int i = 0; i < aggSize; i++) {
486 for (
int j = 0; j < aggSize; j++)
487 printf(
" %5.3lf ", q(i,j));
501 for (
int j = 0; j < m; j++) {
503 size_t rowStart =
rowsAux(localRow);
505 for (
int k = 0; k < n; k++) {
509 colsAux(rowStart + lnnz) = offset + k;
510 valsAux(rowStart + lnnz) = qr_jk;
514 rows(localRow + 1) = lnnz;
518 for (
int j = 0; j < n; j++)
LocalQRDecompFunctor(NspType fineNS_, NspType coarseNS_, aggRowsType aggRows_, maxAggDofSizeType maxAggDofSize_, agg2RowMapLOType agg2RowMapLO_, statusType statusAtomic_, rowsType rows_, rowsAuxType rowsAux_, colsAuxType colsAux_, valsAuxType valsAux_, bool doQRStep_, int scratchLevel_)