Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/SliceWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ using namespace Cabana;

template <class ExecutionSpace, class MemorySpace, class... Ts>
class CabSliceFactory {
static constexpr int vecLen = Impl::PerformanceTraits<ExecutionSpace>::vector_length/8;
using TypeTuple = std::tuple<Ts...>;
using DeviceType = Kokkos::Device<ExecutionSpace, MemorySpace>;
using DataTypes = Cabana::MemberTypes<Ts...>;
public:
static constexpr int vecLen = Cabana::AoSoA<DataTypes, DeviceType>::vector_length;
private:
using soa_t = SoA<DataTypes, vecLen>;

template <class T, int stride>
Expand All @@ -47,7 +49,7 @@ class CabSliceFactory {
template <std::size_t index>
auto makeSliceCab() {
using type = std::tuple_element_t<index, TypeTuple>;
const int stride = (vecLen * sizeof(soa_t)) / (4 * sizeof(type));
const int stride = sizeof(soa_t) / sizeof(type);
auto slice = Cabana::slice<index>(aosoa);
return wrapper_slice_t< type, stride >(std::move(slice));
}
Expand Down
3 changes: 1 addition & 2 deletions test/SliceWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

int main(int argc, char* argv[]) {
// AoSoA parameters
const int vecLen = 4;
int num_tuples = 10;

Kokkos::ScopeGuard scope_guard(argc, argv);
Expand All @@ -20,7 +19,7 @@ int main(int argc, char* argv[]) {
auto slice_wrapper3 = cabSliceFactory.makeSliceCab<3>();

// simd_parallel_for setup
Cabana::SimdPolicy<vecLen, ExecutionSpace> simd_policy(0, num_tuples);
Cabana::SimdPolicy<cabSliceFactory.vecLen, ExecutionSpace> simd_policy(0, num_tuples);

// kernel that reads and writes
auto vector_kernel = KOKKOS_LAMBDA(const int s, const int a) {
Expand Down