Skip to content

Commit 04c3355

Browse files
authored
Merge pull request #4 from SCOREC/multi-slice-cab-factory
Fixed issue with vectorLength, removed it from test file
2 parents 685c791 + 54e2d4e commit 04c3355

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/SliceWrapper.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ using namespace Cabana;
2626

2727
template <class ExecutionSpace, class MemorySpace, class... Ts>
2828
class CabSliceFactory {
29-
static constexpr int vecLen = Impl::PerformanceTraits<ExecutionSpace>::vector_length/8;
3029
using TypeTuple = std::tuple<Ts...>;
3130
using DeviceType = Kokkos::Device<ExecutionSpace, MemorySpace>;
3231
using DataTypes = Cabana::MemberTypes<Ts...>;
32+
public:
33+
static constexpr int vecLen = Cabana::AoSoA<DataTypes, DeviceType>::vector_length;
34+
private:
3335
using soa_t = SoA<DataTypes, vecLen>;
3436

3537
template <class T, int stride>
@@ -47,7 +49,7 @@ class CabSliceFactory {
4749
template <std::size_t index>
4850
auto makeSliceCab() {
4951
using type = std::tuple_element_t<index, TypeTuple>;
50-
const int stride = (vecLen * sizeof(soa_t)) / (4 * sizeof(type));
52+
const int stride = sizeof(soa_t) / sizeof(type);
5153
auto slice = Cabana::slice<index>(aosoa);
5254
return wrapper_slice_t< type, stride >(std::move(slice));
5355
}

test/SliceWrapper.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
int main(int argc, char* argv[]) {
44
// AoSoA parameters
5-
const int vecLen = 4;
65
int num_tuples = 10;
76

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

2221
// simd_parallel_for setup
23-
Cabana::SimdPolicy<vecLen, ExecutionSpace> simd_policy(0, num_tuples);
22+
Cabana::SimdPolicy<cabSliceFactory.vecLen, ExecutionSpace> simd_policy(0, num_tuples);
2423

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

0 commit comments

Comments
 (0)