예제 #1
0
 KOKKOS_FORCEINLINE_FUNCTION
 static void 
 unrollIndex(IdxType &i, IdxType &j, IdxType &k, 
             const DimType dim0,
             const DimType dim1,
             const IterType iter) {
   IdxType tmp;
   unrollIndex(tmp, k, dim0*dim1, iter);
   unrollIndex(  i, j, dim0,      tmp);
 }
      KOKKOS_INLINE_FUNCTION
      void operator()(const size_type iter) const {
        size_type cl, bf, pt;
        size_type leftRank(_leftInput.rank()), rightRank(_rightInput.rank());

        if (_hasField) 
          unrollIndex( cl, bf, pt, 
                             _output.dimension(0),
                             _output.dimension(1), 
                             _output.dimension(2), 
                             iter );
        else          
          unrollIndex( cl, pt,
                             _output.dimension(0),
                             _output.dimension(1),
                             iter);
        
        auto result = ( _hasField ? Kokkos::subview(_output, cl, bf, pt) :
                        /**/        Kokkos::subview(_output, cl,     pt));
        
        const auto left = (_leftInput.dimension(1) == 1) ? Kokkos::subview(_leftInput, cl, 0, Kokkos::ALL(), Kokkos::ALL()) :
                            /**/                           Kokkos::subview(_leftInput, cl, pt, Kokkos::ALL(), Kokkos::ALL());

        
        const auto right = (rightRank == leftRank + int(_hasField)) ?
                             ( _hasField ? Kokkos::subview(_rightInput, cl, bf, pt, Kokkos::ALL(), Kokkos::ALL()) :
                             /**/          Kokkos::subview(_rightInput, cl,     pt, Kokkos::ALL(), Kokkos::ALL())) :
                             ( _hasField ? Kokkos::subview(_rightInput,     bf, pt, Kokkos::ALL(), Kokkos::ALL()) :
                             /**/          Kokkos::subview(_rightInput,         pt, Kokkos::ALL(), Kokkos::ALL()));
        
        const size_type iend  = left.dimension(0);
        const size_type jend  = left.dimension(1);

        value_type tmp(0);
        for(size_type i = 0; i < iend; ++i)
          for(size_type j = 0; j < jend; ++j)
            tmp += left(i, j)*right(i, j);
        result() = tmp;
      }
      KOKKOS_INLINE_FUNCTION
      void operator()(const size_type iter) const {
        size_type cell, pt;
        unrollIndex( cell, pt,
                           _physPoints.dimension(0),
                           _physPoints.dimension(1),
                           iter );
        /**/  auto phys = Kokkos::subdynrankview( _physPoints, cell, pt, Kokkos::ALL());
        const auto dofs = Kokkos::subdynrankview( _worksetCells, cell, Kokkos::ALL(), Kokkos::ALL());

        const auto valRank = _basisVals.rank();
        const auto val = ( valRank == 2 ? Kokkos::subdynrankview( _basisVals,       Kokkos::ALL(), pt) :
                           /**/           Kokkos::subdynrankview( _basisVals, cell, Kokkos::ALL(), pt));

        const auto dim = phys.dimension(0);
        const auto cardinality = val.dimension(0);

        for (size_type i=0;i<dim;++i) {
          phys(i) = 0;
          for (size_type bf=0;bf<cardinality;++bf)
            phys(i) += dofs(bf, i)*val(bf);
        }
      }