Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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,7 +26,9 @@ using namespace Cabana;

template <class ExecutionSpace, class MemorySpace, class... Ts>
class CabSliceFactory {
static constexpr int vecLen = Impl::PerformanceTraits<ExecutionSpace>::vector_length/8;
public:
static constexpr int vecLen = Impl::PerformanceTraits<ExecutionSpace>::vector_length;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is static constexpr in the AoSoA object, would the following work?

static constexpr int vecLen = Cabana::AoSoA<DataTypes, DeviceType, vecLen>::vector_length;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill try it out!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

private:
using TypeTuple = std::tuple<Ts...>;
using DeviceType = Kokkos::Device<ExecutionSpace, MemorySpace>;
using DataTypes = Cabana::MemberTypes<Ts...>;
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