Commit 7323f196 authored by Carter Edwards's avatar Carter Edwards
Browse files

Kokkos: Row subview of rank-2 layout-right array.

parent 08db0256
......@@ -482,6 +482,36 @@ struct ViewAssignment< LayoutDefault , LayoutDefault , void >
ViewTracking< traits_type >::increment( dst.m_ptr_on_device );
}
//------------------------------------
/** \brief Extract Rank-1 array from LayoutRight Rank-2 array. */
template< class DT , class DL , class DD , class DM ,
class ST , class SL , class SD , class SM >
KOKKOS_INLINE_FUNCTION
ViewAssignment( View<DT,DL,DD,DM,LayoutDefault> & dst ,
const View<ST,SL,SD,SM,LayoutDefault> & src ,
const unsigned i0 ,
const typename enable_if< (
ViewAssignable< ViewTraits<DT,DL,DD,DM> , ViewTraits<ST,SL,SD,SM> >::assignable_value
&&
is_same< typename ViewTraits<ST,SL,SD,SM>::array_layout , LayoutRight >::value
&&
( ViewTraits<ST,SL,SD,SM>::rank == 2 )
&&
( ViewTraits<DT,DL,DD,DM>::rank == 1 )
&&
( ViewTraits<DT,DL,DD,DM>::rank_dynamic == 1 )
), ALL >::type & )
{
typedef ViewTraits<DT,DL,DD,DM> traits_type ;
ViewTracking< traits_type >::decrement( dst.m_ptr_on_device );
dst.m_shape.N0 = src.m_shape.N1 ;
dst.m_ptr_on_device = src.m_ptr_on_device + src.m_stride.value * i0 ;
ViewTracking< traits_type >::increment( dst.m_ptr_on_device );
}
//------------------------------------
/** \brief Extract LayoutRight Rank-N array from range of LayoutRight Rank-N array */
template< class DT , class DL , class DD , class DM ,
......
......@@ -1094,6 +1094,10 @@ public:
vector_type v2 = Kokkos::subview< vector_type >( mv , Kokkos::ALL() , 1 );
vector_type v3 = Kokkos::subview< vector_type >( mv , Kokkos::ALL() , 2 );
vector_type rv1 = Kokkos::subview< vector_type >( mv_right , 0 , Kokkos::ALL() );
vector_type rv2 = Kokkos::subview< vector_type >( mv_right , 1 , Kokkos::ALL() );
vector_type rv3 = Kokkos::subview< vector_type >( mv_right , 2 , Kokkos::ALL() );
multivector_type mv1 = Kokkos::subview< multivector_type >( mv , std::make_pair( 1 , 998 ) ,
std::make_pair( 2 , 5 ) );
......
......@@ -57,6 +57,9 @@
namespace Kokkos {
namespace Example {
/** \brief Generate a distributed unstructured finite element mesh
* from a partitioned NX*NY*NZ box of elements.
*/
template< class Device , BoxElemPart::ElemOrder Order >
class BoxElemFixture {
public:
......@@ -160,11 +163,12 @@ public:
}
}
size_t nwork = m_recv_node.dimension_0()
+ m_send_node.dimension_0()
+ m_send_node_id.dimension_0()
+ m_node_grid.dimension_0()
+ m_elem_node.dimension_0() * m_elem_node.dimension_1() ;
const size_t nwork =
std::max( m_recv_node.dimension_0() ,
std::max( m_send_node.dimension_0() ,
std::max( m_send_node_id.dimension_0() ,
std::max( m_node_grid.dimension_0() ,
m_elem_node.dimension_0() * m_elem_node.dimension_1() ))));
Kokkos::parallel_for( nwork , *this );
}
......@@ -177,49 +181,43 @@ public:
KOKKOS_INLINE_FUNCTION
void operator()( size_t i ) const
{
if ( i < m_elem_node.dimension_0() * m_elem_node.dimension_1() ) {
const size_t ielem = i / ElemNode ;
const size_t inode = i % ElemNode ;
unsigned elem_coord[3] ;
unsigned node_coord[3] ;
m_box_part.uses_elem_coord( ielem , elem_coord );
node_coord[0] = elem_coord[0] + m_elem_node_local[inode][0] ;
node_coord[1] = elem_coord[1] + m_elem_node_local[inode][1] ;
node_coord[2] = elem_coord[2] + m_elem_node_local[inode][2] ;
m_elem_node(ielem,inode) = m_box_part.local_node_id( node_coord );
}
if ( i < m_node_grid.dimension_0() ) {
unsigned node_coord[3] ;
m_box_part.local_node_coord( i , node_coord );
m_node_grid(i,0) = node_coord[0] ;
m_node_grid(i,1) = node_coord[1] ;
m_node_grid(i,2) = node_coord[2] ;
}
if ( i < m_recv_node.dimension_0() ) {
m_recv_node(i,0) = m_box_part.recv_node_rank(i);
m_recv_node(i,1) = m_box_part.recv_node_count(i);
}
else {
i -= m_recv_node.dimension_0();
if ( i < m_send_node.dimension_0() ) {
m_send_node(i,0) = m_box_part.send_node_rank(i);
m_send_node(i,1) = m_box_part.send_node_count(i);
}
else {
i -= m_send_node.dimension_0();
if ( i < m_send_node_id.dimension_0() ) {
m_send_node_id(i) = m_box_part.send_node_id(i);
}
else {
i -= m_send_node_id.dimension_0();
if ( i < m_node_grid.dimension_0() ) {
unsigned node_coord[3] ;
m_box_part.local_node_coord( i , node_coord );
m_node_grid(i,0) = node_coord[0] ;
m_node_grid(i,1) = node_coord[1] ;
m_node_grid(i,2) = node_coord[2] ;
}
else {
i -= m_node_grid.dimension_0();
const size_t ielem = i / ElemNode ;
const size_t inode = i % ElemNode ;
unsigned elem_coord[3] ;
unsigned node_coord[3] ;
m_box_part.uses_elem_coord( ielem , elem_coord );
node_coord[0] = elem_coord[0] + m_elem_node_local[inode][0] ;
node_coord[1] = elem_coord[1] + m_elem_node_local[inode][1] ;
node_coord[2] = elem_coord[2] + m_elem_node_local[inode][2] ;
m_elem_node(ielem,inode) = m_box_part.local_node_id( node_coord );
}
}
}
if ( i < m_send_node.dimension_0() ) {
m_send_node(i,0) = m_box_part.send_node_rank(i);
m_send_node(i,1) = m_box_part.send_node_count(i);
}
if ( i < m_send_node_id.dimension_0() ) {
m_send_node_id(i) = m_box_part.send_node_id(i);
}
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment