Skip to content
Snippets Groups Projects

WIP: Index vectorization

Closed Slattery, Stuart requested to merge (removed):index_opt into master
+ 78
0
@@ -638,6 +638,84 @@ class AoSoA<MemberDataTypes<Types...>,Properties...>
d0, d1, d2, d3 );
}
// -------------------------------
// Access the data value at a given member index and particle index.
// Rank 0
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<(0==std::rank<struct_member_data_type<M> >::value),
struct_member_reference_type<M> >::type
access( const int struct_index, const int array_index ) const
{
return
reinterpret_cast<struct_member_array_type<M> >(
static_cast<struct_member_pointer_type<M> >(_data[struct_index]) + struct_index * stride(M)
)[array_index];
}
// Rank 1
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<(1==std::rank<struct_member_data_type<M> >::value),
struct_member_reference_type<M> >::type
access( const int struct_index, const int array_index,
const int d0 ) const
{
return
reinterpret_cast<struct_member_array_type<M> >(
static_cast<struct_member_pointer_type<M> >(_data[struct_index]) + struct_index * stride(M)
)[array_index][d0];
}
// Rank 2
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<(2==std::rank<struct_member_data_type<M> >::value),
struct_member_reference_type<M> >::type
access( const int struct_index, const int array_index,
const int d0,
const int d1 ) const
{
return
reinterpret_cast<struct_member_array_type<M> >(
static_cast<struct_member_pointer_type<M> >(_data[struct_index]) + struct_index * stride(M)
)[array_index][d0][d1];
}
// Rank 3
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<(3==std::rank<struct_member_data_type<M> >::value),
struct_member_reference_type<M> >::type
access( const int struct_index, const int array_index,
const int d0,
const int d1,
const int d2 ) const
{
return
reinterpret_cast<struct_member_array_type<M> >(
static_cast<struct_member_pointer_type<M> >(_data[struct_index]) + struct_index * stride(M)
)[array_index][d0][d1][d2];
}
// Rank 4
template<std::size_t M>
KOKKOS_FORCEINLINE_FUNCTION
typename std::enable_if<(4==std::rank<struct_member_data_type<M> >::value),
struct_member_reference_type<M> >::type
access( const int struct_index, const int array_index,
const int d0,
const int d1,
const int d2,
const int d3 ) const
{
return
reinterpret_cast<struct_member_array_type<M> >(
static_cast<struct_member_pointer_type<M> >(_data[struct_index]) + struct_index * stride(M)
)[array_index][d0][d1][d2][d3];
}
// -------------------------------
// Raw data access.
Loading