-
Notifications
You must be signed in to change notification settings - Fork 6
CabanaSliceFactory now works with multiple types. #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
34177d0
8a49253
7009fba
9c8249d
d62a009
790cedd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,34 +3,37 @@ | |
| int main(int argc, char* argv[]) { | ||
| // AoSoA parameters | ||
| const int vecLen = 4; | ||
cwsmith marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this still be here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope. It will be removed in the next version |
||
| const int width = 1; | ||
| int num_tuples = 10; | ||
|
|
||
| Kokkos::ScopeGuard scope_guard(argc, argv); | ||
|
|
||
| using member_type = double; | ||
| using DataTypes = Cabana::MemberTypes<member_type[width]>; | ||
| using ExecutionSpace = Kokkos::Cuda; | ||
| using MemorySpace = Kokkos::CudaSpace; | ||
|
|
||
| using ExecutionSpace = Kokkos::DefaultExecutionSpace; | ||
| using MemorySpace = ExecutionSpace::memory_space; | ||
|
|
||
| // Slice Wrapper Factory | ||
| CabSliceFactory<ExecutionSpace, MemorySpace, | ||
| member_type, width, vecLen> cabSliceFactory(num_tuples); | ||
| double, int, float, char> cabSliceFactory(num_tuples); | ||
|
|
||
| auto slice_wrapper = cabSliceFactory.makeSliceCab(); | ||
| auto slice_wrapper0 = cabSliceFactory.makeSliceCab<0>(); | ||
| auto slice_wrapper1 = cabSliceFactory.makeSliceCab<1>(); | ||
| auto slice_wrapper2 = cabSliceFactory.makeSliceCab<2>(); | ||
| auto slice_wrapper3 = cabSliceFactory.makeSliceCab<3>(); | ||
|
|
||
| // simd_parallel_for setup | ||
| Cabana::SimdPolicy<vecLen, ExecutionSpace> simd_policy(0, num_tuples); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we eliminate the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
|
|
||
| // kernel that reads and writes | ||
| auto vector_kernel = KOKKOS_LAMBDA(const int s, const int a) { | ||
| for (int i = 0; i < width; i++) { | ||
| printf("s: %d, a: %d, i: %d\n", s,a,i); | ||
| double x = 42/(s+a+1.3); | ||
| slice_wrapper.access(s,a,i) = x; | ||
| printf("value: %lf\n", slice_wrapper.access(s,a,i)); | ||
| } | ||
| printf("s: %d, a: %d\n", s,a); | ||
| double x = 42/(s+a+1.3); | ||
| slice_wrapper0.access(s,a) = x; | ||
| slice_wrapper1.access(s,a) = s+a; | ||
| slice_wrapper2.access(s,a) = float(x); | ||
| slice_wrapper3.access(s,a) = 'a'+s+a; | ||
| printf("SW0 value: %lf\n", slice_wrapper0.access(s,a)); | ||
| printf("SW1 value: %d\n", slice_wrapper1.access(s,a)); | ||
| printf("SW2 value: %f\n", slice_wrapper2.access(s,a)); | ||
| printf("SW3 value: %c\n", slice_wrapper3.access(s,a)); | ||
| }; | ||
|
|
||
| Cabana::simd_parallel_for(simd_policy, vector_kernel, "parallel_for_cabSliceFactory"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the division by 8? Is the
vector_lengthreported in bits?Can you point me at where Cabana uses this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I divided it by eight because when I changed to this vector length instead of the user defined one, the stride calculation got messed up, being eight times larger than it should have been which gave me errors. I have just revised the calculation to be correct and not divide the vector length by 8.
Cabana uses this here as a default template parameter for the AoSoA
https://github.com/ECP-copa/Cabana/blob/1c44a7fef24b61f73e629ddd2084c4d05b0ec977/core/src/Cabana_AoSoA.hpp#L146:~:text=int%20VectorLength%20%3D%20Impl,DeviceType%3A%3Aexecution_space%3E%3A%3Avector_length